summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-15 00:26:43 +0000
committerChris Lattner <sabre@nondot.org>2010-07-15 00:26:43 +0000
commitdeee7a3c0bf5897dbe00277097c5b86eddf894a2 (patch)
treecd5a20464d42a1f6056a7c7d4a4c22751cb7beff /clang/lib/Sema/SemaExpr.cpp
parent8b1bb8cfbdbeb8d05f83aa4bf1c652622bd1e243 (diff)
downloadbcm5719-llvm-deee7a3c0bf5897dbe00277097c5b86eddf894a2.tar.gz
bcm5719-llvm-deee7a3c0bf5897dbe00277097c5b86eddf894a2.zip
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. llvm-svn: 108388
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c06943f6718..5f46a977b12 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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()
OpenPOWER on IntegriCloud