Fixed #7238 (False positive unknownEvaluationOrder for comma operator on C code)
This commit is contained in:
parent
5b6758b03b
commit
0ddb5c12ce
|
@ -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())
|
||||
|
|
|
@ -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));"
|
||||
|
|
Loading…
Reference in New Issue