Skip to content

Commit 950e894

Browse files
Fix #12455 FP bitwiseOnBoolean [inconclusive] (danmar#6040)
1 parent 0fe775c commit 950e894

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/checkbool.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ void CheckBool::checkBitwiseOnBoolean()
113113
continue;
114114
const bool isBoolOp1 = astIsBool(tok->astOperand1());
115115
const bool isBoolOp2 = astIsBool(tok->astOperand2());
116+
if (!tok->astOperand1()->valueType() || !tok->astOperand2()->valueType())
117+
continue;
116118
if (!(isBoolOp1 || isBoolOp2))
117119
continue;
118120
if (isCompound && (!isBoolOp1 || isBoolOp2))

test/testbool.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,16 @@ class TestBool : public TestFixture {
954954
" return b;\n"
955955
"}\n");
956956
ASSERT_EQUALS("", errout.str());
957+
958+
check("struct S { bool b{}; };\n" // #12455
959+
"void f(const std::unordered_map<int, S> m) {\n"
960+
" for (const auto& e : m) {\n"
961+
" S s;\n"
962+
" s.b |= e.second.b;\n"
963+
" (void)s.b;\n"
964+
" }\n"
965+
"}\n");
966+
ASSERT_EQUALS("", errout.str());
957967
}
958968

959969
void incrementBoolean() {

0 commit comments

Comments
 (0)