Fixed #4931 (Wrong calculation of constants (simplifying: +,<<,% operations))
This commit is contained in:
parent
094b4c8b6f
commit
8fd62e0cf9
|
@ -3734,6 +3734,14 @@ bool Tokenizer::simplifyTokenList2()
|
|||
|
||||
simplifyCasts();
|
||||
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "%oror%|&& %num% %oror%|&&|,|)") ||
|
||||
Token::Match(tok, "[(,] %num% %oror%|&&")) {
|
||||
tok = tok->next();
|
||||
tok->str(MathLib::isNullValue(tok->str()) ? "0" : "1");
|
||||
}
|
||||
}
|
||||
|
||||
// Simplify simple calculations before replace constants, this allows the replacement of constants that are calculated
|
||||
// e.g. const static int value = sizeof(X)/sizeof(Y);
|
||||
simplifyCalculations();
|
||||
|
|
|
@ -5660,6 +5660,9 @@ private:
|
|||
|
||||
// ticket #3964 - simplify numeric calculations in tokenization
|
||||
ASSERT_EQUALS("char a [ 10 ] ;", tokenizeAndStringify("char a[9+1];"));
|
||||
|
||||
// ticket #4931
|
||||
ASSERT_EQUALS("dostuff ( 1 ) ;", tokenizeAndStringify("dostuff(9&&8);", true));
|
||||
}
|
||||
|
||||
void simplifyCompoundAssignment() {
|
||||
|
|
Loading…
Reference in New Issue