parent
31d704e4bc
commit
3dc2c0bd42
|
@ -1866,6 +1866,8 @@ static bool isConstTop(const Token *tok)
|
|||
if (!bracTok->astParent())
|
||||
return true;
|
||||
}
|
||||
if (tok->str() == "," && tok->astParent() && tok->astParent()->isAssignmentOp())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1908,7 +1910,8 @@ void CheckOther::checkIncompleteStatement()
|
|||
!Token::Match(tok->previous(), ";|}|{ %any% ;") &&
|
||||
!(mTokenizer->isCPP() && tok->isCast() && !tok->astParent()) &&
|
||||
!Token::simpleMatch(tok->tokAt(-2), "for (") &&
|
||||
!Token::Match(tok->tokAt(-1), "%var% ["))
|
||||
!Token::Match(tok->tokAt(-1), "%var% [") &&
|
||||
!(tok->str() == "," && tok->astParent() && tok->astParent()->isAssignmentOp()))
|
||||
continue;
|
||||
// Skip statement expressions
|
||||
if (Token::simpleMatch(rtok, "; } )"))
|
||||
|
|
|
@ -357,13 +357,19 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// #8827
|
||||
void commaoperator1() {
|
||||
check("void foo(int,const char*,int);\n"
|
||||
check("void foo(int,const char*,int);\n" // #8827
|
||||
"void f(int value) {\n"
|
||||
" foo(42,\"test\",42),(value&42);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Found suspicious operator ',', result is not used.\n", errout.str());
|
||||
|
||||
check("int f() {\n" // #11257
|
||||
" int y;\n"
|
||||
" y = (3, 4);\n"
|
||||
" return y;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Found suspicious operator ',', result is not used.\n", errout.str());
|
||||
}
|
||||
|
||||
void commaoperator2() {
|
||||
|
|
Loading…
Reference in New Issue