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();
|
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
|
// 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);
|
// e.g. const static int value = sizeof(X)/sizeof(Y);
|
||||||
simplifyCalculations();
|
simplifyCalculations();
|
||||||
|
|
|
@ -5660,6 +5660,9 @@ private:
|
||||||
|
|
||||||
// ticket #3964 - simplify numeric calculations in tokenization
|
// ticket #3964 - simplify numeric calculations in tokenization
|
||||||
ASSERT_EQUALS("char a [ 10 ] ;", tokenizeAndStringify("char a[9+1];"));
|
ASSERT_EQUALS("char a [ 10 ] ;", tokenizeAndStringify("char a[9+1];"));
|
||||||
|
|
||||||
|
// ticket #4931
|
||||||
|
ASSERT_EQUALS("dostuff ( 1 ) ;", tokenizeAndStringify("dostuff(9&&8);", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyCompoundAssignment() {
|
void simplifyCompoundAssignment() {
|
||||||
|
|
Loading…
Reference in New Issue