#8499 Added regression test: (style) Condition 'i==0||i==1' is always true (for loop index)

This commit is contained in:
orbitcowboy 2023-03-17 19:06:17 +01:00
parent 3ccd0505cd
commit b2263d9475
1 changed files with 15 additions and 0 deletions

View File

@ -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"