#8801: Quick fix for false positives

This commit is contained in:
Daniel Marjamäki 2018-10-24 19:57:50 +02:00
parent ea4e6a60f7
commit 2348dcde6c
2 changed files with 5 additions and 1 deletions

View File

@ -1285,6 +1285,10 @@ void CheckCondition::alwaysTrueFalse()
const bool returnStatement = Token::simpleMatch(tok->astTop(), "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))
continue;

View File

@ -2479,7 +2479,7 @@ private:
" if(x == 0) { x++; return x == 0; } \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)
" int x = 0;\n"