diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 4f68418da..6d4f0be91 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2509,7 +2509,8 @@ void CheckOther::checkEvaluationOrder() const Token *par = parent; while (Token::simpleMatch(par,",")) par = par->astParent(); - if (!par || par->str() != "(") + // not function => break + if (!(par && par->str() == "(" && par->astOperand2())) break; } if (parent->str() == "(" && parent->astOperand2()) diff --git a/test/testother.cpp b/test/testother.cpp index b5e20882c..660791776 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6131,19 +6131,32 @@ private: // sequence points { - // FP + // function call: FP check("void f(int id) {\n" " id = dostuff(id += 42);\n" "}", "test.c"); ASSERT_EQUALS("", errout.str()); - // FN + // function call: FN check("void f(int id) {\n" " id = id + dostuff(id += 42);\n" "}", "test.c"); TODO_ASSERT_EQUALS("error", "", errout.str()); } + // comma + check("int f(void) {\n" + " int t;\n" + " return (unsigned char)(t=1,t^c);\n" + "}", "test.c"); + ASSERT_EQUALS("", errout.str()); + + check("void f(void) {\n" + " int t;\n" + " dostuff(t=1,t^c);\n" + "}", "test.c"); + TODO_ASSERT_EQUALS("error", "", errout.str()); + // sizeof check("void f(char *buf) {\n" " dostuff(buf++, sizeof(*buf));"