parent
f6fb3334f3
commit
cae27c5ec7
|
@ -205,8 +205,8 @@ void CheckType::checkIntegerOverflow()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// For left shift, it's common practice to shift into the sign bit
|
// For left shift, it's common practice to shift into the sign bit
|
||||||
//if (tok->str() == "<<" && value->intvalue > 0 && value->intvalue < (((MathLib::bigint)1) << bits))
|
if (tok->str() == "<<" && value->intvalue > 0 && value->intvalue < (((MathLib::bigint)1) << bits))
|
||||||
// continue;
|
continue;
|
||||||
|
|
||||||
integerOverflowError(tok, *value);
|
integerOverflowError(tok, *value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,6 +295,11 @@ private:
|
||||||
" return 123456U * x;\n"
|
" return 123456U * x;\n"
|
||||||
"}",settings);
|
"}",settings);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("int f(int i) {\n" // #12117
|
||||||
|
" return (i == 31) ? 1 << i : 0;\n"
|
||||||
|
"}", settings);
|
||||||
|
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (warning) Shifting signed 32-bit value by 31 bits is undefined behaviour. See condition at line 2.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void signConversion() {
|
void signConversion() {
|
||||||
|
|
Loading…
Reference in New Issue