Fixed #7238 (False positive unknownEvaluationOrder for comma operator on C code)

This commit is contained in:
Daniel Marjamäki 2015-12-28 13:45:55 +01:00
parent 5b6758b03b
commit 0ddb5c12ce
2 changed files with 17 additions and 3 deletions

View File

@ -2509,7 +2509,8 @@ void CheckOther::checkEvaluationOrder()
const Token *par = parent;
while (Token::simpleMatch(par,","))
par = par->astParent();
if (!par || par->str() != "(")
// not function => break
if (!(par && par->str() == "(" && par->astOperand2()))
break;
}
if (parent->str() == "(" && parent->astOperand2())

View File

@ -6131,19 +6131,32 @@ private:
// sequence points
{
// FP
// function call: FP
check("void f(int id) {\n"
" id = dostuff(id += 42);\n"
"}", "test.c");
ASSERT_EQUALS("", errout.str());
// FN
// function call: FN
check("void f(int id) {\n"
" id = id + dostuff(id += 42);\n"
"}", "test.c");
TODO_ASSERT_EQUALS("error", "", errout.str());
}
// comma
check("int f(void) {\n"
" int t;\n"
" return (unsigned char)(t=1,t^c);\n"
"}", "test.c");
ASSERT_EQUALS("", errout.str());
check("void f(void) {\n"
" int t;\n"
" dostuff(t=1,t^c);\n"
"}", "test.c");
TODO_ASSERT_EQUALS("error", "", errout.str());
// sizeof
check("void f(char *buf) {\n"
" dostuff(buf++, sizeof(*buf));"