Skip to content

Commit 2543dc9

Browse files
Fix FP bitwiseOnBoolean (#4280)
1 parent 2c7d986 commit 2543dc9

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/checkbool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void CheckBool::checkBitwiseOnBoolean()
111111
const bool isBoolOp2 = astIsBool(tok->astOperand2());
112112
if (!(isBoolOp1 || isBoolOp2))
113113
continue;
114-
if (isCompound && !isBoolOp1)
114+
if (isCompound && (!isBoolOp1 || isBoolOp2))
115115
continue;
116116
if (tok->str() == "|" && !isConvertedToBool(tok) && !(isBoolOp1 && isBoolOp2))
117117
continue;

test/testbool.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,12 @@ class TestBool : public TestFixture {
949949
" if (b || c) {}\n"
950950
"}\n");
951951
ASSERT_EQUALS("", errout.str());
952+
953+
check("bool f(bool b, int i) {\n"
954+
" b &= (i == 5);\n"
955+
" return b;\n"
956+
"}\n");
957+
ASSERT_EQUALS("", errout.str());
952958
}
953959

954960
void incrementBoolean() {

0 commit comments

Comments
 (0)