Fixed #7604 (simplifyCalculation: expression '0 && x[2]' is not simplified properly)
This commit is contained in:
parent
801fd8f96a
commit
45ee29d5dc
|
@ -1032,9 +1032,9 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
|
|||
const Token *tok2 = tok;
|
||||
bool andAnd = (tok->next()->str() == "&&");
|
||||
for (; tok2; tok2 = tok2->next()) {
|
||||
if (tok2->str() == "(")
|
||||
if (tok2->str() == "(" || tok2->str() == "[")
|
||||
++par;
|
||||
else if (tok2->str() == ")") {
|
||||
else if (tok2->str() == ")" || tok2->str() == "]") {
|
||||
if (par == 0)
|
||||
break;
|
||||
--par;
|
||||
|
|
|
@ -5720,6 +5720,8 @@ private:
|
|||
// ticket #3723 - Simplify condition (0 && a < 123)
|
||||
ASSERT_EQUALS("( 0 )",
|
||||
tokenizeAndStringify("( 0 && a < 123 )", true));
|
||||
ASSERT_EQUALS("( 0 )",
|
||||
tokenizeAndStringify("( 0 && a[123] )", true));
|
||||
|
||||
// ticket #3964 - simplify numeric calculations in tokenization
|
||||
ASSERT_EQUALS("char a [ 10 ] ;", tokenizeAndStringify("char a[9+1];"));
|
||||
|
|
Loading…
Reference in New Issue