From 684e1d2a1690f7f0380d873dc7141dd4406815d4 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 4 Jun 2016 00:22:31 +0000 Subject: [PATCH] PR27989: only enqueue binary operators into the data recursive int expression evaluator if they are actually int expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271754 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ExprConstant.cpp | 4 +++- test/SemaCXX/constant-expression-cxx1y.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 6b0eae143b..10192be7bd 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -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()); } diff --git a/test/SemaCXX/constant-expression-cxx1y.cpp b/test/SemaCXX/constant-expression-cxx1y.cpp index d67cbf6f3a..f8103224af 100644 --- a/test/SemaCXX/constant-expression-cxx1y.cpp +++ b/test/SemaCXX/constant-expression-cxx1y.cpp @@ -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, ""); +} -- 2.40.0