Fix FP bitwiseOnBoolean (#4280)

This commit is contained in:
chrchr-github 2022-07-14 20:59:39 +02:00 committed by GitHub
parent 2c7d98626a
commit 2543dc97d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -111,7 +111,7 @@ void CheckBool::checkBitwiseOnBoolean()
const bool isBoolOp2 = astIsBool(tok->astOperand2());
if (!(isBoolOp1 || isBoolOp2))
continue;
if (isCompound && !isBoolOp1)
if (isCompound && (!isBoolOp1 || isBoolOp2))
continue;
if (tok->str() == "|" && !isConvertedToBool(tok) && !(isBoolOp1 && isBoolOp2))
continue;

View File

@ -949,6 +949,12 @@ private:
" if (b || c) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("bool f(bool b, int i) {\n"
" b &= (i == 5);\n"
" return b;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void incrementBoolean() {