diff options
author | Chris Lattner <sabre@nondot.org> | 2010-07-15 00:26:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-07-15 00:26:43 +0000 |
commit | 23ef3e4f044d701d0f84980fd9816fedf17fc0cb (patch) | |
tree | 19b26b61ea0da8e3fe53e535062feafa70a1691f /lib/Sema/SemaExpr.cpp | |
parent | 30c514c225342844700ed4640ec6d90ddf0e12b2 (diff) |
restrict the && -> & warning to cover a case daniel noted.
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
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index c06943f671..5f46a977b1 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5742,6 +5742,10 @@ inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14] // 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() |