From 2348dcde6cbcdc931821c0d9304e5fa80d8b660a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 24 Oct 2018 19:57:50 +0200 Subject: [PATCH] #8801: Quick fix for false positives --- lib/checkcondition.cpp | 4 ++++ test/testcondition.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index f40903fae..4d0ab6254 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -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; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 5f53c6944..828bd972c 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -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"