File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ class TestOther : public TestFixture {
230230 TEST_CASE(checkRedundantCopy);
231231
232232 TEST_CASE(checkNegativeShift);
233+ TEST_CASE(checkNegativeShiftErrorPath);
233234
234235 TEST_CASE(incompleteArrayFill);
235236
@@ -10490,6 +10491,24 @@ class TestOther : public TestFixture {
1049010491 ASSERT_EQUALS("", errout_str());
1049110492 }
1049210493
10494+ void checkNegativeShiftErrorPath() {
10495+ setMultiline();
10496+ Settings s = settings1;
10497+ s.templateLocation = "{file}:{line}:note:{info}\n";
10498+
10499+ check("int f(int i, bool b) {\n"
10500+ " int s = -1;\n"
10501+ " if (b)\n"
10502+ " return i;\n"
10503+ " return i << s;\n"
10504+ "}\n", dinit(CheckOptions, $.settings = &s));
10505+ ASSERT_EQUALS("[test.cpp:5:14]: warning: Shifting by a negative value is undefined behaviour [shiftNegative]\n"
10506+ "[test.cpp:2:14]: note: Assignment 's=-1', assigned value is -1\n"
10507+ "[test.cpp:3:9]: note: Assuming condition is false\n"
10508+ "[test.cpp:5:14]: note: Shifting by a negative value is undefined behaviour\n",
10509+ errout_str());
10510+ }
10511+
1049310512 void incompleteArrayFill() {
1049410513 check("void f() {\n"
1049510514 " int a[5];\n"
You can’t perform that action at this time.
0 commit comments