Too big shift: fix FP when cast is used
This commit is contained in:
parent
0ab7abded1
commit
7119550dde
|
@ -44,19 +44,20 @@ public:
|
|||
|
||||
/** @brief Run checks against the normal token list */
|
||||
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) {
|
||||
(void)tokenizer;
|
||||
(void)settings;
|
||||
(void)errorLogger;
|
||||
}
|
||||
|
||||
/** @brief Run checks against the simplified token list */
|
||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) {
|
||||
// These are not "simplified" because casts can't be ignored
|
||||
CheckType checkType(tokenizer, settings, errorLogger);
|
||||
checkType.checkTooBigBitwiseShift();
|
||||
checkType.checkIntegerOverflow();
|
||||
checkType.checkSignConversion();
|
||||
}
|
||||
|
||||
/** @brief Run checks against the simplified token list */
|
||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) {
|
||||
(void)tokenizer;
|
||||
(void)settings;
|
||||
(void)errorLogger;
|
||||
}
|
||||
|
||||
/** @brief %Check for bitwise shift with too big right operand */
|
||||
void checkTooBigBitwiseShift();
|
||||
|
||||
|
|
|
@ -59,12 +59,6 @@ private:
|
|||
// Check..
|
||||
CheckType checkType(&tokenizer, settings, this);
|
||||
checkType.runChecks(&tokenizer, settings, this);
|
||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||
tokenizer.simplifyTokenList2();
|
||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||
if (str1 != str2)
|
||||
warn(("Unsimplified code in test case\nstr1="+str1+"\nstr2="+str2).c_str());
|
||||
checkType.runSimplifiedChecks(&tokenizer, settings, this);
|
||||
}
|
||||
|
||||
void checkTooBigShift() {
|
||||
|
@ -80,6 +74,11 @@ private:
|
|||
" return x << 2;\n"
|
||||
"}",&settings);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int foo(int x) {\n"
|
||||
" return (long long)x << 40;\n"
|
||||
"}",&settings);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkIntegerOverflow() {
|
||||
|
|
Loading…
Reference in New Issue