unusedScopedObject: Don't warn for void statements (#4370)
* Fix unusedScopedObject FPs * Simplify * Simplify * Fix test * Don't warn for void statements * Format
This commit is contained in:
parent
e9f1665d4f
commit
4a64e20592
|
@ -2062,7 +2062,8 @@ void CheckOther::checkMisusedScopedObject()
|
|||
&& Token::Match(tok->linkAt(2), ")|} ; !!}")
|
||||
&& (!tok->next()->function() || // is not a function on this scope
|
||||
tok->next()->function()->isConstructor()) // or is function in this scope and it's a ctor
|
||||
&& !Token::simpleMatch(tok->tokAt(2)->astParent(), ";")) { // for loop condition
|
||||
&& !Token::simpleMatch(tok->tokAt(2)->astParent(), ";") // for loop condition
|
||||
&& tok->next()->str() != "void") {
|
||||
if (const Token* arg = tok->tokAt(2)->astOperand2()) {
|
||||
if (!isConstStatement(arg, mTokenizer->isCPP()))
|
||||
continue;
|
||||
|
|
|
@ -5060,6 +5060,12 @@ private:
|
|||
" float (*p);\n"
|
||||
"}\n", "test.cpp");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int f(int i) {\n"
|
||||
" void();\n"
|
||||
" return i;\n"
|
||||
"}\n", "test.cpp");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void trac2084() {
|
||||
|
|
Loading…
Reference in New Issue