From 79aec559d5c8a92603f8cb0b1460e1179d632720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 18 Jan 2016 16:10:51 +0100 Subject: [PATCH] Fixed #7243 (False positive unknownEvaluationOrder - comma operator inside while-clause) --- lib/checkother.cpp | 3 +++ test/testother.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index c24250473..2efbb2ea4 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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)) diff --git a/test/testother.cpp b/test/testother.cpp index ee393fb23..1aee29424 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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() {