Ticket #8780 was fixed in b839ad60dd
.
Add a test to avoid regressions.
This commit is contained in:
parent
8f36b7d23b
commit
a05079fef7
|
@ -73,6 +73,7 @@ private:
|
|||
TEST_CASE(incorrectLogicOperator10); // enum
|
||||
TEST_CASE(incorrectLogicOperator11);
|
||||
TEST_CASE(incorrectLogicOperator12);
|
||||
TEST_CASE(incorrectLogicOperator13);
|
||||
TEST_CASE(secondAlwaysTrueFalseWhenFirstTrueError);
|
||||
TEST_CASE(incorrectLogicOp_condSwapping);
|
||||
TEST_CASE(testBug5895);
|
||||
|
@ -1300,6 +1301,21 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3] -> [test.cpp:5]: (warning) Logical conjunction always evaluates to false: a > x && a < y.\n", errout.str());
|
||||
}
|
||||
|
||||
void incorrectLogicOperator13() {
|
||||
// 8780
|
||||
check("void f(const int &v) {\n"
|
||||
" const int x=v;\n"
|
||||
" if ((v == 1) && (x == 2)) {;}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Logical conjunction always evaluates to false: v == 1 && x == 2.\n", errout.str());
|
||||
|
||||
check("void f2(const int *v) {\n"
|
||||
" const int *x=v;\n"
|
||||
" if ((*v == 1) && (*x == 2)) {;}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Logical conjunction always evaluates to false: *(v) == 1 && *(x) == 2.\n", errout.str());
|
||||
}
|
||||
|
||||
void secondAlwaysTrueFalseWhenFirstTrueError() {
|
||||
check("void f(int x) {\n"
|
||||
" if (x > 5 && x != 1)\n"
|
||||
|
|
Loading…
Reference in New Issue