#8801: Quick fix for false positives
This commit is contained in:
parent
ea4e6a60f7
commit
2348dcde6c
|
@ -1285,6 +1285,10 @@ void CheckCondition::alwaysTrueFalse()
|
||||||
const bool returnStatement = Token::simpleMatch(tok->astTop(), "return") &&
|
const bool returnStatement = Token::simpleMatch(tok->astTop(), "return") &&
|
||||||
Token::Match(tok->astParent(), "%oror%|&&|return");
|
Token::Match(tok->astParent(), "%oror%|&&|return");
|
||||||
|
|
||||||
|
// FIXME checking of return statements does not work well. See #8801
|
||||||
|
if (returnStatement)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!(constIfWhileExpression || constValExpr || compExpr || returnStatement))
|
if (!(constIfWhileExpression || constValExpr || compExpr || returnStatement))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -2479,7 +2479,7 @@ private:
|
||||||
" if(x == 0) { x++; return x == 0; } \n"
|
" if(x == 0) { x++; return x == 0; } \n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Condition 'x==0' is always false\n", errout.str());
|
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Condition 'x==0' is always false\n", "", errout.str());
|
||||||
|
|
||||||
check("void f() {\n" // #6898 (Token::expressionString)
|
check("void f() {\n" // #6898 (Token::expressionString)
|
||||||
" int x = 0;\n"
|
" int x = 0;\n"
|
||||||
|
|
Loading…
Reference in New Issue