[PPL-devel] [GIT] ppl/ppl(master): Fixed wrong type uses.
Abramo Bagnara
abramo.bagnara at gmail.com
Sun Oct 30 11:57:50 CET 2011
Module: ppl/ppl
Branch: master
Commit: c5f8aeb2c48c426585f21c69ed8561d470d607c6
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=c5f8aeb2c48c426585f21c69ed8561d470d607c6
Author: Abramo Bagnara <abramo.bagnara at gmail.com>
Date: Sun Oct 30 11:42:38 2011 +0100
Fixed wrong type uses.
Detected by ECLAIR service utypflag.
---
demos/ppl_lcdd/ppl_lcdd.cc | 12 +++++++-----
demos/ppl_pips/ppl_pips.cc | 4 ++--
src/Concrete_Expression.inlines.hh | 2 +-
src/Float.defs.hh | 18 +++++++++---------
src/Float.inlines.hh | 28 ++++++++++++++++------------
src/checked_float.inlines.hh | 2 +-
src/globals.defs.hh | 4 ++--
7 files changed, 38 insertions(+), 32 deletions(-)
diff --git a/demos/ppl_lcdd/ppl_lcdd.cc b/demos/ppl_lcdd/ppl_lcdd.cc
index af49457..c1f47b8 100644
--- a/demos/ppl_lcdd/ppl_lcdd.cc
+++ b/demos/ppl_lcdd/ppl_lcdd.cc
@@ -301,7 +301,7 @@ warning(const char* format, ...) {
extern "C" typedef void (*sig_handler_type)(int);
void
-set_alarm_on_cpu_time(const unsigned seconds, sig_handler_type handler) {
+set_alarm_on_cpu_time(const unsigned long seconds, sig_handler_type handler) {
sigset_t mask;
sigemptyset(&mask);
@@ -489,13 +489,14 @@ void
normalize(const std::vector<mpq_class>& source,
std::vector<mpz_class>& dest,
mpz_class& denominator) {
- unsigned n = source.size();
+ typedef std::vector<mpq_class> size_type;
+ size_type n = source.size();
denominator = 1;
- for (unsigned i = 0; i < n; ++i)
+ for (size_type i = 0; i < n; ++i)
mpz_lcm(denominator.get_mpz_t(),
denominator.get_mpz_t(),
source[i].get_den().get_mpz_t());
- for (unsigned i = 0; i < n; ++i)
+ for (size_type i = 0; i < n; ++i)
dest[i] = denominator*source[i];
}
@@ -545,7 +546,8 @@ read_coefficients(std::istream& in,
const Number_Type number_type,
std::vector<mpz_class>& coefficients,
mpz_class& denominator) {
- unsigned num_coefficients = coefficients.size();
+ typedef std::vector<mpz_class>::size_type size_type;
+ size_type num_coefficients = coefficients.size();
switch (number_type) {
case INTEGER:
{
diff --git a/demos/ppl_pips/ppl_pips.cc b/demos/ppl_pips/ppl_pips.cc
index ca4c0e1..c3a2f31 100644
--- a/demos/ppl_pips/ppl_pips.cc
+++ b/demos/ppl_pips/ppl_pips.cc
@@ -113,7 +113,7 @@ PPL::PIP_Problem::Control_Parameter_Value cutting_strategy
PPL::PIP_Problem::Control_Parameter_Value pivot_row_strategy
= PPL::PIP_Problem::PIVOT_ROW_STRATEGY_FIRST;
-int loop_iterations = 1;
+long loop_iterations = 1;
void
pip_display_sol(std::ostream& out,
@@ -824,7 +824,7 @@ main(int argc, char* argv[]) try {
else {
std::auto_ptr<PPL::PIP_Problem> pipp;
// Perform a time benchmark loop executing the resolution several times.
- for (int i = 0; i < loop_iterations; ++i) {
+ for (long i = 0; i < loop_iterations; ++i) {
pipp.reset(new PPL::PIP_Problem(pip));
pipp->solve();
}
diff --git a/src/Concrete_Expression.inlines.hh b/src/Concrete_Expression.inlines.hh
index b12963a..875677a 100644
--- a/src/Concrete_Expression.inlines.hh
+++ b/src/Concrete_Expression.inlines.hh
@@ -37,7 +37,7 @@ Concrete_Expression_Type
const Bounded_Integer_Type_Representation representation,
const Bounded_Integer_Type_Overflow overflow) {
Implementation impl;
- impl.bounded_integer = 1;
+ impl.bounded_integer = 1U;
impl.bounded_integer_type_width = width;
impl.bounded_integer_type_representation = representation;
impl.bounded_integer_type_overflow = overflow;
diff --git a/src/Float.defs.hh b/src/Float.defs.hh
index 1c1929c..3148095 100644
--- a/src/Float.defs.hh
+++ b/src/Float.defs.hh
@@ -215,10 +215,10 @@ struct float_intel_double_extended {
static const uint32_t MSP_NEG_INF = 0x0000ffff;
static const uint32_t MSP_POS_ZERO = 0x00000000;
static const uint32_t MSP_NEG_ZERO = 0x00008000;
- static const uint64_t LSP_INF = 0x8000000000000000ULL;
+ static const uint64_t LSP_INF = (uint64_t)0x8000000000000000ULL;
static const uint64_t LSP_ZERO = 0;
- static const uint64_t LSP_DMAX = 0x7fffffffffffffffULL;
- static const uint64_t LSP_NMAX = 0xffffffffffffffffULL;
+ static const uint64_t LSP_DMAX = (uint64_t)0x7fffffffffffffffULL;
+ static const uint64_t LSP_NMAX = (uint64_t)0xffffffffffffffffULL;
static const unsigned int BASE = 2;
static const unsigned int EXPONENT_BITS = 15;
static const unsigned int MANTISSA_BITS = 63;
@@ -252,14 +252,14 @@ struct float_ieee754_quad {
uint64_t lsp;
uint64_t msp;
#endif
- static const uint64_t MSP_SGN_MASK = 0x8000000000000000ULL;
- static const uint64_t MSP_POS_INF = 0x7fff000000000000ULL;
- static const uint64_t MSP_NEG_INF = 0xffff000000000000ULL;
- static const uint64_t MSP_POS_ZERO = 0x0000000000000000ULL;
- static const uint64_t MSP_NEG_ZERO = 0x8000000000000000ULL;
+ static const uint64_t MSP_SGN_MASK = (uint64_t)0x8000000000000000ULL;
+ static const uint64_t MSP_POS_INF = (uint64_t)0x7fff000000000000ULL;
+ static const uint64_t MSP_NEG_INF = (uint64_t)0xffff000000000000ULL;
+ static const uint64_t MSP_POS_ZERO = (uint64_t)0x0000000000000000ULL;
+ static const uint64_t MSP_NEG_ZERO = (uint64_t)0x8000000000000000ULL;
static const uint64_t LSP_INF = 0;
static const uint64_t LSP_ZERO = 0;
- static const uint64_t LSP_MAX = 0xffffffffffffffffULL;
+ static const uint64_t LSP_MAX = (uint64_t)0xffffffffffffffffULL;
static const unsigned int BASE = 2;
static const unsigned int EXPONENT_BITS = 15;
static const unsigned int MANTISSA_BITS = 112;
diff --git a/src/Float.inlines.hh b/src/Float.inlines.hh
index 9ae573f..ba3a42b 100644
--- a/src/Float.inlines.hh
+++ b/src/Float.inlines.hh
@@ -82,7 +82,8 @@ float_ieee754_half::set_max(bool negative) {
inline void
float_ieee754_half::build(bool negative, mpz_t mantissa, int exponent) {
- word = mpz_get_ui(mantissa) & ((1UL << MANTISSA_BITS) - 1);
+ word = static_cast<uint16_t>(mpz_get_ui(mantissa)
+ & ((1UL << MANTISSA_BITS) - 1));
if (negative)
word |= SGN_MASK;
int exponent_repr = exponent + EXPONENT_BIAS;
@@ -142,7 +143,8 @@ float_ieee754_single::set_max(bool negative) {
inline void
float_ieee754_single::build(bool negative, mpz_t mantissa, int exponent) {
- word = mpz_get_ui(mantissa) & ((1UL << MANTISSA_BITS) - 1);
+ word = static_cast<uint32_t>(mpz_get_ui(mantissa)
+ & ((1UL << MANTISSA_BITS) - 1));
if (negative)
word |= SGN_MASK;
int exponent_repr = exponent + EXPONENT_BIAS;
@@ -218,16 +220,17 @@ float_ieee754_double::set_max(bool negative) {
inline void
float_ieee754_double::build(bool negative, mpz_t mantissa, int exponent) {
+ unsigned long m;
#if ULONG_MAX == 0xffffffffUL
lsp = mpz_get_ui(mantissa);
mpz_tdiv_q_2exp(mantissa, mantissa, 32);
- unsigned long m = mpz_get_ui(mantissa);
+ m = mpz_get_ui(mantissa);
#else
- unsigned long m = mpz_get_ui(mantissa);
- lsp = m;
+ m = mpz_get_ui(mantissa);
+ lsp = static_cast<uint32_t>(m & LSP_MAX);
m >>= 32;
#endif
- msp = m & ((1UL << (MANTISSA_BITS - 32)) - 1);
+ msp = static_cast<uint32_t>(m & ((1UL << (MANTISSA_BITS - 32)) - 1));
if (negative)
msp |= MSP_SGN_MASK;
int exponent_repr = exponent + EXPONENT_BIAS;
@@ -287,7 +290,8 @@ float_ibm_single::set_max(bool negative) {
inline void
float_ibm_single::build(bool negative, mpz_t mantissa, int exponent) {
- word = mpz_get_ui(mantissa) & ((1UL << MANTISSA_BITS) - 1);
+ word = static_cast<uint32_t>(mpz_get_ui(mantissa)
+ & ((1UL << MANTISSA_BITS) - 1));
if (negative)
word |= SGN_MASK;
int exponent_repr = exponent + EXPONENT_BIAS;
@@ -358,7 +362,7 @@ float_intel_double_extended::inc() {
inline void
float_intel_double_extended::set_max(bool negative) {
msp = 0x00007ffe;
- lsp = 0xffffffffffffffffULL;
+ lsp = (uint64_t)0xffffffffffffffffULL;
if (negative)
msp |= MSP_SGN_MASK;
}
@@ -437,8 +441,8 @@ float_ieee754_quad::inc() {
inline void
float_ieee754_quad::set_max(bool negative) {
- msp = 0x7ffeffffffffffffULL;
- lsp = 0xffffffffffffffffULL;
+ msp = (uint64_t)0x7ffeffffffffffffULL;
+ lsp = (uint64_t)0xffffffffffffffffULL;
if (negative)
msp |= MSP_SGN_MASK;
}
@@ -449,7 +453,7 @@ float_ieee754_quad::build(bool negative, mpz_t mantissa, int exponent) {
mpz_export(parts, 0, -1, 8, 0, 0, mantissa);
lsp = parts[0];
msp = parts[1];
- msp &= ((1ULL << (MANTISSA_BITS - 64)) - 1);
+ msp &= ((((uint64_t)1) << (MANTISSA_BITS - 64)) - 1);
if (negative)
msp |= MSP_SGN_MASK;
int exponent_repr = exponent + EXPONENT_BIAS;
@@ -464,7 +468,7 @@ is_less_precise_than(Floating_Point_Format f1, Floating_Point_Format f2) {
#if defined(__GNUC__)
inline unsigned int ld2(unsigned long long a) {
- return __builtin_clzll(a) ^ (sizeof(a)*8 - 1);
+ return __builtin_clzll(a) ^ (sizeof(a)*8 - 1);
}
#else
unsigned int ld2(unsigned long long v) {
diff --git a/src/checked_float.inlines.hh b/src/checked_float.inlines.hh
index b8685b2..5f91f67 100644
--- a/src/checked_float.inlines.hh
+++ b/src/checked_float.inlines.hh
@@ -986,7 +986,7 @@ output_float(std::ostream& os, const Type from, const Numeric_Format&,
else if (is_nan<Policy>(from))
os << "nan";
else {
- int old_precision = os.precision(10000);
+ std::streamsize old_precision = os.precision(10000);
// FIXME: here correctness depends on the behavior of the standard
// output operator which, in turn, may depend on the behavior
// of printf(). The C99 standard, 7.19.16.1#13, does not give
diff --git a/src/globals.defs.hh b/src/globals.defs.hh
index 95edcd4..4f4de80 100644
--- a/src/globals.defs.hh
+++ b/src/globals.defs.hh
@@ -356,13 +356,13 @@ struct Fit<T, v, typename Enable_If<C_Integer<T>::value>::type> {
};
};
-template <typename T, long long v>
+template <typename T, T v>
struct TConstant {
static const T value = v;
};
-template <typename T, long long v>
+template <typename T, T v>
const T TConstant<T, v>::value;
template <typename T, long long v, bool prefer_signed = true,
More information about the PPL-devel
mailing list