From bd1037e95b4794a6d81d25cb98f33d81ccda1c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 29 Dec 2015 12:06:42 +0100 Subject: [PATCH] Fixed #7242 (False positive unknownEvaluationOrder - comma expression in function argument) --- lib/checkother.cpp | 6 ++++++ test/testother.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 6d4f0be91..4bf014205 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2512,6 +2512,12 @@ void CheckOther::checkEvaluationOrder() // not function => break if (!(par && par->str() == "(" && par->astOperand2())) break; + // sequence point in function argument: dostuff((1,2),3) => break + par = par->next(); + while (par && (par->previous() != parent)) + par = par->nextArgument(); + if (!par) + break; } if (parent->str() == "(" && parent->astOperand2()) break; diff --git a/test/testother.cpp b/test/testother.cpp index 494c90936..a5a891308 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6165,6 +6165,12 @@ private: " dostuff(t=1,t^c);\n" "}", "test.c"); ASSERT_EQUALS("[test.c:3]: (error) Expression 't=1,t^c' depends on order of evaluation of side effects\n", errout.str()); + + check("void f(void) {\n" + " int t;\n" + " dostuff((t=1,t),2);\n" + "}", "test.c"); + ASSERT_EQUALS("", errout.str()); } void testEvaluationOrderSizeof() {