From 344d78d6a669fb324f89937fc0739f97670f4700 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 1 Nov 2011 20:38:59 +0000 Subject: [PATCH] Temporarily disable lvalue-to-rvalue conversions on const pointers while an apparent miscompile triggered by this is investigated. This is essentially a revert of r143298. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143491 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ExprConstant.cpp | 3 ++- test/SemaCXX/constant-expression-cxx11.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 7fe03b58a0..4dd49c9125 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -461,7 +461,8 @@ bool HandleLValueToRValueConversion(EvalInfo &Info, QualType Type, // them are not permitted. const VarDecl *VD = dyn_cast(D); if (!VD || !(IsConstNonVolatile(VD->getType()) || isa(VD)) || - !Type->isLiteralType() || !EvaluateVarDeclInit(Info, VD, Frame, RVal)) + !(Type->isIntegralOrEnumerationType() || Type->isRealFloatingType()) || + !EvaluateVarDeclInit(Info, VD, Frame, RVal)) return false; if (isa(VD) || !VD->getAnyInitializer()->isLValue()) diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp index bb1738330f..e65d1fa196 100644 --- a/test/SemaCXX/constant-expression-cxx11.cpp +++ b/test/SemaCXX/constant-expression-cxx11.cpp @@ -128,6 +128,7 @@ namespace ParameterScopes { } +#if 0 namespace Pointers { constexpr int f(int n, const int *a, const int *b, const int *c) { @@ -162,9 +163,10 @@ namespace FunctionPointers { using check_value = int[1 + Apply(Select(4), 5) + Apply(Select(3), 7)]; using check_value = int[42]; - constexpr int Invalid = Apply(Select(0), 0); // expected-error {{must be initialized by a constant expression}} + constexpr int Invalid = Apply(Select(0), 0); // xpected-error {{must be initialized by a constant expression}} } +#endif namespace PointerComparison { @@ -205,8 +207,10 @@ constexpr bool s4 = &x >= &x; constexpr bool s5 = &x < &x; constexpr bool s6 = &x > &x; +#if 0 constexpr S* sptr = &s; constexpr bool dyncast = sptr == dynamic_cast(sptr); +#endif extern char externalvar[]; constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be initialized by a constant expression}} -- 2.40.0