Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2999,7 +2999,7 @@ void CheckOther::checkNegativeBitwiseShift()
// don't warn if lhs is a class. this is an overloaded operator then
if (tok->isCpp()) {
const ValueType * lhsType = tok->astOperand1()->valueType();
if (!lhsType || !lhsType->isIntegral())
if (!lhsType || !lhsType->isIntegral() || lhsType->pointer)
continue;
}

Expand Down
7 changes: 7 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9113,6 +9113,13 @@ class TestOther : public TestFixture {
"[test.cpp:2]: (error) Shifting by a negative value is undefined behaviour\n"
"[test.cpp:3]: (portability) Shifting a negative value is technically undefined behaviour\n"
"[test.cpp:4]: (portability) Shifting a negative value is technically undefined behaviour\n", errout_str());

check("void f(int i) {\n" // #12916
" if (i < 0) {\n"
" g(\"abc\" << i);\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void incompleteArrayFill() {
Expand Down