diff --git a/lib/platform.h b/lib/platform.h index 9c15c5462..65ba91b33 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -34,27 +34,27 @@ namespace cppcheck { */ class CPPCHECKLIB Platform { private: - long long min_value(int sz) const { - if (sz >= 64) + long long min_value(int bit) const { + if (bit >= 64) return 1LL << 63; - return -(1LL << (sz-1)); + return -(1LL << (bit-1)); } - long long max_value(int sz) const { - if (sz >= 64) + long long max_value(int bit) const { + if (bit >= 64) return (~0ULL) >> 1; - return (1LL << (sz-1)) - 1LL; + return (1LL << (bit-1)) - 1LL; } public: Platform(); virtual ~Platform() {} bool isIntValue(long long value) const { - return value >= min_value(sizeof_int) && value <= max_value(sizeof_int); + return value >= min_value(int_bit) && value <= max_value(int_bit); } bool isLongValue(long long value) const { - return value >= min_value(sizeof_long) && value <= max_value(sizeof_long); + return value >= min_value(long_bit) && value <= max_value(long_bit); } unsigned int char_bit; /// bits in char diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index d14cd4bd9..739c551ea 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -3862,9 +3862,9 @@ private: ASSERT_EQUALS("", ValueType().str()); Settings s; - s.sizeof_int = 16; - s.sizeof_long = 32; - s.sizeof_long_long = 64; + s.int_bit = 16; + s.long_bit = 32; + s.long_long_bit = 64; // numbers ASSERT_EQUALS("signed int", typeOf("1", "1", "test.c", &s));