Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update testother.cpp
  • Loading branch information
chrchr-github authored Sep 23, 2026
commit 995ad0570956c4fb0103344a7b3714351998f5f8
19 changes: 19 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class TestOther : public TestFixture {
TEST_CASE(checkRedundantCopy);

TEST_CASE(checkNegativeShift);
TEST_CASE(checkNegativeShiftErrorPath);

TEST_CASE(incompleteArrayFill);

Expand Down Expand Up @@ -10490,6 +10491,24 @@ class TestOther : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void checkNegativeShiftErrorPath() {
setMultiline();
Settings s = settings1;
s.templateLocation = "{file}:{line}:note:{info}\n";

check("int f(int i, bool b) {\n"
" int s = -1;\n"
" if (b)\n"
" return i;\n"
" return i << s;\n"
"}\n", dinit(CheckOptions, $.settings = &s));
ASSERT_EQUALS("[test.cpp:5:14]: warning: Shifting by a negative value is undefined behaviour [shiftNegative]\n"
"[test.cpp:2:14]: note: Assignment 's=-1', assigned value is -1\n"
"[test.cpp:3:9]: note: Assuming condition is false\n"
"[test.cpp:5:14]: note: Shifting by a negative value is undefined behaviour\n",
errout_str());
}

void incompleteArrayFill() {
check("void f() {\n"
" int a[5];\n"
Expand Down