Fixed #7243 (False positive unknownEvaluationOrder - comma operator inside while-clause)

This commit is contained in:
Daniel Marjamäki 2016-01-18 16:10:51 +01:00
parent 5a28bce631
commit 79aec559d5
2 changed files with 9 additions and 0 deletions

View File

@ -2534,6 +2534,9 @@ void CheckOther::checkEvaluationOrder()
// not function => break
if (!(par && par->str() == "(" && par->astOperand2()))
break;
// control flow (if|while|etc) => break
if (Token::simpleMatch(par->link(),") {"))
break;
// sequence point in function argument: dostuff((1,2),3) => break
par = par->next();
while (par && (par->previous() != parent))

View File

@ -6127,6 +6127,12 @@ private:
" return dostuff(++exp, exp, 10);\n"
"}", "test.c");
ASSERT_EQUALS("[test.c:2]: (error) Expression '++exp,exp' depends on order of evaluation of side effects\n", errout.str());
check("void f() {\n"
" int a;\n"
" while (a=x(), a==123) {}\n"
"}", "test.c");
ASSERT_EQUALS("", errout.str());
}
void testEvaluationOrderSelfAssignment() {