r188716 - PR16727: don't try to evaluate a potentially value-dependent expression when
Richard Smith
richard-llvm at metafoo.co.uk
Mon Aug 19 15:06:05 PDT 2013
Author: rsmith
Date: Mon Aug 19 17:06:05 2013
New Revision: 188716
URL: http://llvm.org/viewvc/llvm-project?rev=188716&view=rev
Log:
PR16727: don't try to evaluate a potentially value-dependent expression when
checking for missing parens in &&/|| expressions.
Added:
cfe/trunk/test/SemaCXX/parentheses.cpp
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=188716&r1=188715&r2=188716&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Aug 19 17:06:05 2013
@@ -9115,14 +9115,16 @@ EmitDiagnosticForLogicalAndInLogicalOr(S
/// 'true'.
static bool EvaluatesAsTrue(Sema &S, Expr *E) {
bool Res;
- return E->EvaluateAsBooleanCondition(Res, S.getASTContext()) && Res;
+ return !E->isValueDependent() &&
+ E->EvaluateAsBooleanCondition(Res, S.getASTContext()) && Res;
}
/// \brief Returns true if the given expression can be evaluated as a constant
/// 'false'.
static bool EvaluatesAsFalse(Sema &S, Expr *E) {
bool Res;
- return E->EvaluateAsBooleanCondition(Res, S.getASTContext()) && !Res;
+ return !E->isValueDependent() &&
+ E->EvaluateAsBooleanCondition(Res, S.getASTContext()) && !Res;
}
/// \brief Look for '&&' in the left hand of a '||' expr.
Added: cfe/trunk/test/SemaCXX/parentheses.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/parentheses.cpp?rev=188716&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/parentheses.cpp (added)
+++ cfe/trunk/test/SemaCXX/parentheses.cpp Mon Aug 19 17:06:05 2013
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify %s
+
+// PR16930, PR16727:
+template<class Foo>
+bool test(Foo f, int *array)
+{
+ return false && false || array[f.get()]; // expected-warning {{'&&' within '||'}} expected-note {{parentheses}}
+}
More information about the cfe-commits
mailing list