From c672210e060426002353075b104a1974fbc542c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 26 Dec 2015 15:48:43 +0100 Subject: [PATCH] Evaluation order: don't warn for 'dostuff(expr++, &expr)' --- lib/checkother.cpp | 2 ++ test/testother.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 84ec60836..98085b740 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2535,6 +2535,8 @@ void CheckOther::checkEvaluationOrder() tokens.pop(); if (!tok3) continue; + if (tok3->str() == "&" && !tok3->astOperand2()) + continue; // don't handle adress-of for now tokens.push(tok3->astOperand1()); tokens.push(tok3->astOperand2()); if (isSameExpression(_tokenizer->isCPP(), false, tok->astOperand1(), tok3, _settings->library.functionpure)) { diff --git a/test/testother.cpp b/test/testother.cpp index 917d98f15..d44726f03 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6110,7 +6110,12 @@ private: check("long int f1(const char *exp) {\n" " return strtol(++exp, (char **)&exp, 10);\n" "}", "test.c"); - ASSERT_EQUALS("[test.c:2]: (error) Expression '++exp,(char**)&exp' depends on order of evaluation of side effects\n", errout.str()); + ASSERT_EQUALS("", errout.str()); + + check("long int f1(const char *exp) {\n" + " 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()); // self assignment check("void f() {\n" @@ -6124,7 +6129,6 @@ private: "}").c_str(), "test.c"); ASSERT_EQUALS("[test.c:2]: (error) Expression 'x+x++' depends on order of evaluation of side effects\n", errout.str()); - // sequence points { // FP