Fixed #7232 (False positive unknownEvaluationOrder on id = Remap( id += 42 );)
This commit is contained in:
parent
0bdd353062
commit
90a54b1fae
|
@ -2495,6 +2495,7 @@ void CheckOther::checkEvaluationOrder()
|
|||
if (!tok->astOperand1())
|
||||
continue;
|
||||
for (const Token *tok2 = tok; tok2 && tok2->astParent(); tok2 = tok2->astParent()) {
|
||||
// If ast parent is a sequence point then break
|
||||
const Token * const parent = tok2->astParent();
|
||||
if (Token::Match(parent, "%oror%|&&|?|:|;"))
|
||||
break;
|
||||
|
@ -2505,6 +2506,8 @@ void CheckOther::checkEvaluationOrder()
|
|||
if (!par || par->str() != "(")
|
||||
break;
|
||||
}
|
||||
if (parent->str() == "(" && parent->astOperand2())
|
||||
break;
|
||||
|
||||
// Is expression used?
|
||||
bool foundError = false;
|
||||
|
|
|
@ -6111,6 +6111,12 @@ private:
|
|||
" return strtol(++exp, (char **)&exp, 10);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Expression '++exp,(char**)&exp' depends on order of evaluation of side effects\n", errout.str());
|
||||
|
||||
// sequence points
|
||||
check("void f(int id) {\n"
|
||||
" id = dostuff(id += 42);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue