Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Oct 6, 2023
1 parent 78673b5 commit 0b449ec
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6867,6 +6867,31 @@ class TestOther : public TestFixture {
"[test.cpp:4]: (style) The comparison 'E0 > 0' is always false.\n"
"[test.cpp:5]: (style) The comparison 'E0 == 0' is always true.\n",
errout.str());

check("struct S {\n" // #12040, #12044
" static const int I = 0;\n"
" enum { E0 };\n"
" enum F { F0 };\n"
" void f() {\n"
" if (0 > I) {}\n"
" if (0 > S::I) {}\n"
" if (0 > E0) {}\n"
" if (0 > S::E0) {}\n"
" }\n"
"};\n"
"void g() {\n"
" if (0 > S::I) {}\n"
" if (0 > S::E0) {}\n"
" if (0 > S::F::F0) {}\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:6]: (style) The comparison '0 > I' is always false.\n"
"[test.cpp:2] -> [test.cpp:7]: (style) The comparison '0 > S::I' is always false.\n"
"[test.cpp:8]: (style) The comparison '0 > E0' is always false.\n"
"[test.cpp:9]: (style) The comparison '0 > S::E0' is always false.\n"
"[test.cpp:2] -> [test.cpp:13]: (style) The comparison '0 > S::I' is always false.\n"
"[test.cpp:14]: (style) The comparison '0 > S::E0' is always false.\n"
"[test.cpp:15]: (style) The comparison '0 > S::F::F0' is always false.\n",
errout.str());
}

void duplicateExpressionLoop() {
Expand Down

0 comments on commit 0b449ec

Please sign in to comment.