diff --git a/lib/checkother.cpp b/lib/checkother.cpp index e9483fb2b..467552abb 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2672,8 +2672,8 @@ void CheckOther::checkEvaluationOrder() const Token *par = parent; while (Token::simpleMatch(par,",")) par = par->astParent(); - // not function => break - if (!(par && par->str() == "(" && par->astOperand2())) + // not function or in a while clause => break + if (!(par && par->str() == "(" && par->astOperand2() && par->strAt(-1) != "while")) break; // control flow (if|while|etc) => break if (Token::simpleMatch(par->link(),") {")) diff --git a/test/testother.cpp b/test/testother.cpp index 748f8f256..56025d7d4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -7051,6 +7051,28 @@ private: " dostuff((t=1,t),2);\n" "}", "test.c"); ASSERT_EQUALS("", errout.str()); + + // #8230 + check("void hprf(const char* fp) {\n" + " do\n" + " ;\n" + " while (++fp, (*fp) <= 0177);\n" + "}\n", "test.c"); + ASSERT_EQUALS("", errout.str()); + + check("void hprf(const char* fp) {\n" + " do\n" + " ;\n" + " while (i++, ++fp, (*fp) <= 0177);\n" + "}\n", "test.c"); + ASSERT_EQUALS("", errout.str()); + + check("void f(const char* fp) {\n" + " do\n" + " ;\n" + " while (f(++fp, (*fp) <= 7));\n" + "}\n", "test.c"); + ASSERT_EQUALS("[test.c:4]: (error) Expression '++fp,(*fp)<=7' depends on order of evaluation of side effects\n", errout.str()); } void testEvaluationOrderSizeof() {