r271754 - PR27989: only enqueue binary operators into the data recursive int expression
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 3 17:22:31 PDT 2016
Author: rsmith
Date: Fri Jun 3 19:22:31 2016
New Revision: 271754
URL: http://llvm.org/viewvc/llvm-project?rev=271754&view=rev
Log:
PR27989: only enqueue binary operators into the data recursive int expression
evaluator if they are actually int expressions.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=271754&r1=271753&r2=271754&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jun 3 19:22:31 2016
@@ -7112,7 +7112,9 @@ public:
static bool shouldEnqueue(const BinaryOperator *E) {
return E->getOpcode() == BO_Comma ||
E->isLogicalOp() ||
- (E->getLHS()->getType()->isIntegralOrEnumerationType() &&
+ (E->isRValue() &&
+ E->getType()->isIntegralOrEnumerationType() &&
+ E->getLHS()->getType()->isIntegralOrEnumerationType() &&
E->getRHS()->getType()->isIntegralOrEnumerationType());
}
Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp?rev=271754&r1=271753&r2=271754&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp Fri Jun 3 19:22:31 2016
@@ -949,3 +949,11 @@ namespace SpeculativeEvalWrites {
static_assert(!f(), "");
}
+
+namespace PR27989 {
+ constexpr int f(int n) {
+ int a = (n = 1, 0);
+ return n;
+ }
+ static_assert(f(0) == 1, "");
+}
More information about the cfe-commits
mailing list