File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -2949,6 +2949,23 @@ class TestCondition : public TestFixture {
29492949 }
29502950
29512951 void alwaysTrue () {
2952+
2953+ check (" void f ()\n " // #8220
2954+ " {\n "
2955+ " int a;\n "
2956+ " int b = 0;\n "
2957+ " int ret;\n "
2958+ " \n "
2959+ " a = rand();\n "
2960+ " while (((0 < a) && (a < 2)) && ((8 < a) && (a < 10))) \n "
2961+ " {\n "
2962+ " b += a;\n "
2963+ " a ++;\n "
2964+ " }\n "
2965+ " ret = b;\n "
2966+ " }" );
2967+ ASSERT_EQUALS (" [test.cpp:8] -> [test.cpp:8]: (style) Condition '8<a' is always false\n " , errout.str ());
2968+
29522969 check (" void f() {\n " // #4842
29532970 " int x = 0;\n "
29542971 " if (a) { return; }\n " // <- this is just here to fool simplifyKnownVariabels
@@ -4355,8 +4372,8 @@ class TestCondition : public TestFixture {
43554372 " if (b == true) {}\n "
43564373 " }" , &settingsUnix64);
43574374 ASSERT_EQUALS (" " , errout.str ());
4358- }
4359-
4375+ }
4376+
43604377 void knownConditionCast () { // #9976
43614378 check (" void f(int i) {\n "
43624379 " if (i < 0 || (unsigned)i > 5) {}\n "
You can’t perform that action at this time.
0 commit comments