Don't warn about "logically bool" expressions on the RHS,
even if they fold to a constant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108388
91177308-0d34-0410-b5e6-
96231b3b80d8
// is a constant.
if (lex->getType()->isIntegerType() && !lex->getType()->isBooleanType() &&
rex->getType()->isIntegerType() && rex->isEvaluatable(Context) &&
+ // Don't warn if the RHS is a (constant folded) boolean expression like
+ // "sizeof(int) == 4".
+ !rex->isKnownToHaveBooleanValue() &&
+ // Don't warn in macros.
!Loc.isMacroID())
Diag(Loc, diag::warn_logical_instead_of_bitwise)
<< rex->getSourceRange()
int test20(int x) {
return x && 4; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+
+ return x && sizeof(int) == 4; // no warning.
}