#6645 false negative: condition is always false. Add a regression test

This commit is contained in:
amai2012 2018-07-03 08:25:37 +02:00
parent 24dd4c9c26
commit c2f0828a61
1 changed files with 9 additions and 0 deletions

View File

@ -1911,6 +1911,15 @@ private:
check("void f2(int a, int b) { if(a!=b) if(a!=b) {}}"); 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()); 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() { void identicalConditionAfterEarlyExit() {