@@ -6406,6 +6406,50 @@ class TestCondition : public TestFixture {
64066406 " [test.cpp:7:19]: note: Assignment 'b=false'\n "
64076407 " [test.cpp:7:13]: note: Condition '!b' is redundant\n " ,
64086408 errout_str ());
6409+
6410+ check (" void f(bool& b) {\n " // #14915
6411+ " if (b == true)\n "
6412+ " b = false;\n "
6413+ " }\n "
6414+ " void g(bool& b) {\n "
6415+ " if (b == false)\n "
6416+ " b = false;\n "
6417+ " }\n "
6418+ " void h(bool& b) {\n "
6419+ " if (b != true)\n "
6420+ " b = false;\n "
6421+ " }\n "
6422+ " void i(bool& b) {\n "
6423+ " if (b != false)\n "
6424+ " b = false;\n "
6425+ " }\n "
6426+ " void j(bool& b) {\n "
6427+ " if (b == true)\n "
6428+ " b = true;\n "
6429+ " }\n "
6430+ " void k(bool& b) {\n "
6431+ " if (true == b)\n "
6432+ " b = false;\n "
6433+ " }\n " );
6434+ ASSERT_EQUALS (" [test.cpp:2:11]: style: The statement 'if (b==true) b=false' is logically equivalent to 'b=false'. [duplicateConditionalAssign]\n "
6435+ " [test.cpp:3:11]: note: Assignment 'b=false'\n "
6436+ " [test.cpp:2:11]: note: Condition 'b==true' is redundant\n "
6437+ " [test.cpp:6:11]: style: The statement 'if (b==false) b=false' is redundant. [duplicateConditionalAssign]\n "
6438+ " [test.cpp:7:11]: note: Assignment 'b=false'\n "
6439+ " [test.cpp:6:11]: note: Condition 'b==false' is redundant\n "
6440+ " [test.cpp:10:11]: style: The statement 'if (b!=true) b=false' is redundant. [duplicateConditionalAssign]\n "
6441+ " [test.cpp:11:11]: note: Assignment 'b=false'\n "
6442+ " [test.cpp:10:11]: note: Condition 'b!=true' is redundant\n "
6443+ " [test.cpp:14:11]: style: The statement 'if (b!=false) b=false' is logically equivalent to 'b=false'. [duplicateConditionalAssign]\n "
6444+ " [test.cpp:15:11]: note: Assignment 'b=false'\n "
6445+ " [test.cpp:14:11]: note: Condition 'b!=false' is redundant\n "
6446+ " [test.cpp:18:11]: style: The statement 'if (b==true) b=true' is redundant. [duplicateConditionalAssign]\n "
6447+ " [test.cpp:19:11]: note: Assignment 'b=true'\n "
6448+ " [test.cpp:18:11]: note: Condition 'b==true' is redundant\n "
6449+ " [test.cpp:22:14]: style: The statement 'if (true==b) b=false' is logically equivalent to 'b=false'. [duplicateConditionalAssign]\n "
6450+ " [test.cpp:23:11]: note: Assignment 'b=false'\n "
6451+ " [test.cpp:22:14]: note: Condition 'true==b' is redundant\n " ,
6452+ errout_str ());
64096453 }
64106454
64116455 void checkAssignmentInCondition () {
0 commit comments