From b2263d947523c599b61c109effc0820d2b1c794f Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Fri, 17 Mar 2023 19:06:17 +0100 Subject: [PATCH] #8499 Added regression test: (style) Condition 'i==0||i==1' is always true (for loop index) --- test/testcondition.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 8b64d8d4e..0610a9a75 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -5046,6 +5046,21 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + // #8499 + check("void f(void)\n" + "{\n" + " for (int i = 0; i < 2; ++i)\n" + " {\n" + " for (int j = 0; j < 8; ++j)\n" + " {\n" + " if ( (i==0|| i==1)\n" // << always true + " && (j==0) )\n" + " {;}\n" + " }\n" + " }\n" + "}"); + ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:7]: (style) Condition 'i==1' is always true\n", errout.str()); + // #10863 check("void f(const int A[], int Len) {\n" " if (Len <= 0)\n"