Added a regression test for ticket #8892 - FN: knownConditionTrueFalse

This commit is contained in:
orbitcowboy 2022-05-24 09:21:21 +02:00
parent 7405ea039d
commit c30333425b
1 changed files with 6 additions and 0 deletions

View File

@ -1642,6 +1642,12 @@ private:
} }
void secondAlwaysTrueFalseWhenFirstTrueError() { void secondAlwaysTrueFalseWhenFirstTrueError() {
check("void f(void) {\n" // #8892
" const char c[1] = { \'x\' }; \n"
" if(c[0] == \'x\'){;}\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (style) Condition 'c[0]=='x'' is always true\n", errout.str());
check("void f(int x) {\n" check("void f(int x) {\n"
" if (x > 5 && x != 1)\n" " if (x > 5 && x != 1)\n"
" a++;\n" " a++;\n"