File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4098,6 +4098,35 @@ class TestCondition : public TestFixture {
40984098 // #8358
40994099 check (" void f(double d) { if ((d * 0) != 0) {} }" );
41004100 ASSERT_EQUALS (" " , errout.str ());
4101+
4102+ // #6870
4103+ check (" struct S {\n "
4104+ " int* p;\n "
4105+ " void f() const;\n "
4106+ " int g();\n "
4107+ " };\n "
4108+ " void S::f() {\n "
4109+ " if ((p == NULL) || ((p) && (g() >= *p))) {}\n "
4110+ " }\n " );
4111+ ASSERT_EQUALS (" [test.cpp:7]: (style) Condition 'p' is always true\n " , errout.str ());
4112+
4113+ // #10749
4114+ check (" struct Interface {\n "
4115+ " virtual int method() = 0;\n "
4116+ " };\n "
4117+ " struct Child : Interface {\n "
4118+ " int method() override { return 0; }\n "
4119+ " auto foo() {\n "
4120+ " if (method() == 0)\n "
4121+ " return true;\n "
4122+ " else\n "
4123+ " return false;\n "
4124+ " }\n "
4125+ " };\n "
4126+ " struct GrandChild : Child {\n "
4127+ " int method() override { return 1; }\n "
4128+ " };\n " );
4129+ ASSERT_EQUALS (" " , errout.str ());
41014130 }
41024131
41034132 void alwaysTrueSymbolic ()
You can’t perform that action at this time.
0 commit comments