AST: fixed isSameExpressions handling of ({..})

This commit is contained in:
Daniel Marjamäki 2013-11-25 04:08:28 +01:00
parent 94e2bf7a11
commit abdf2bb9d4
2 changed files with 7 additions and 0 deletions

View File

@ -62,6 +62,9 @@ static bool isSameExpression(const Token *tok1, const Token *tok2, const std::se
if (!t1 || !t2 || t1->str() != ")" || t2->str() != ")")
return false;
}
// bailout when we see ({..})
if (tok1->str() == "{")
return false;
if (!isSameExpression(tok1->astOperand1(), tok2->astOperand1(), constFunctions))
return false;
if (!isSameExpression(tok1->astOperand2(), tok2->astOperand2(), constFunctions))

View File

@ -4831,6 +4831,10 @@ private:
NULL // settings
);
ASSERT_EQUALS("", errout.str());
// make sure there are not "same expression" fp when there are different ({}) expressions
check("void f(long x) { if (({ 1+2; }) == ({3+4};)) {} }");
ASSERT_EQUALS("", errout.str());
}
void duplicateIf1() { // ticket 3689 ( avoid false positive )