Evaluation order: don't warn for 'dostuff(expr++, &expr)'

This commit is contained in:
Daniel Marjamäki 2015-12-26 15:48:43 +01:00
parent 32455e8441
commit c672210e06
2 changed files with 8 additions and 2 deletions

View File

@ -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)) {

View File

@ -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