diff options
author | John McCall <rjmccall@apple.com> | 2010-06-12 01:56:02 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-06-12 01:56:02 +0000 |
commit | 6907fbe758d23e1aec4c0a67e7b633d1d855feb4 (patch) | |
tree | cc0183caac12637d2dd8f322672acb9ffda0add0 /lib/AST/Expr.cpp | |
parent | 1715bf5ed87c792c63278e739bc492921d512a88 (diff) |
When deciding whether an expression has the boolean nature, don't look through
explicit casts. Fixes PR7359.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105871 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index c38cec32c3..68fcb35c79 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -52,7 +52,9 @@ bool Expr::isKnownToHaveBooleanValue() const { } } - if (const CastExpr *CE = dyn_cast<CastExpr>(this)) + // Only look through implicit casts. If the user writes + // '(int) (a && b)' treat it as an arbitrary int. + if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(this)) return CE->getSubExpr()->isKnownToHaveBooleanValue(); if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(this)) { |