diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 71accd870..ed0a0a787 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -496,6 +496,13 @@ private: " else if (bar() >1 && b) {}\n" "}"); ASSERT_EQUALS("[test.cpp:5]: (style) Expression is always false because 'else if' condition matches previous condition at line 4.\n", errout.str()); + + // 7284 + check("void foo() {\n" + " if (a) {}\n" + " else if (!!a) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3]: (style) Expression is always false because 'else if' condition matches previous condition at line 2.\n", errout.str()); } void checkPureFunction(const char code[]) { diff --git a/test/testother.cpp b/test/testother.cpp index ca9c31534..71c675cb8 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4082,6 +4082,19 @@ private: " return a && b && c;\n" "}\n"); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Same expression on both sides of '&&' because 'a' and 'c' represent the same value.\n", errout.str()); + + // 6906 + check("void f(const bool b) {\n" + " const bool b1 = !b;\n" + " if(!b && b1){}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Same expression on both sides of '&&' because '!b' and 'b1' represent the same value.\n", errout.str()); + + // 7482 + check("void f(void) {\n" + " if (a || !!a) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2]: (style) Same expression on both sides of '||' because 'a' and '!!a' represent the same value.\n", errout.str()); } void duplicateExpression8() {