From c2f0828a61553a9c414a151ff4ef92839e89a290 Mon Sep 17 00:00:00 2001 From: amai2012 Date: Tue, 3 Jul 2018 08:25:37 +0200 Subject: [PATCH] #6645 false negative: condition is always false. Add a regression test --- test/testcondition.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 5ee9766ff..bd595ad21 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1911,6 +1911,15 @@ private: check("void f2(int a, int b) { if(a!=b) if(a!=b) {}}"); ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (warning) Identical inner 'if' condition is always true.\n", errout.str()); + + // #6645 false negative: condition is always false + check("void f(bool a, bool b) {\n" + " if(a && b) {\n" + " if(a) {}\n" + " else {}\n" + " }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Identical inner 'if' condition is always true.\n", errout.str()); } void identicalConditionAfterEarlyExit() {