]> granicus.if.org Git - clang/commitdiff
Temporarily disable lvalue-to-rvalue conversions on const pointers while an
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 1 Nov 2011 20:38:59 +0000 (20:38 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 1 Nov 2011 20:38:59 +0000 (20:38 +0000)
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
test/SemaCXX/constant-expression-cxx11.cpp

index 7fe03b58a053fc0fafb219ca3e5ce4d0970ea9e1..4dd49c912503b8d765980087e980a92d2eabe3e3 100644 (file)
@@ -461,7 +461,8 @@ bool HandleLValueToRValueConversion(EvalInfo &Info, QualType Type,
     // them are not permitted.
     const VarDecl *VD = dyn_cast<VarDecl>(D);
     if (!VD || !(IsConstNonVolatile(VD->getType()) || isa<ParmVarDecl>(VD)) ||
-        !Type->isLiteralType() || !EvaluateVarDeclInit(Info, VD, Frame, RVal))
+        !(Type->isIntegralOrEnumerationType() || Type->isRealFloatingType()) ||
+        !EvaluateVarDeclInit(Info, VD, Frame, RVal))
       return false;
 
     if (isa<ParmVarDecl>(VD) || !VD->getAnyInitializer()->isLValue())
index bb1738330fe0c1a081f2f216e65adc634d43d1db..e65d1fa19643065d45a181ed3c24185fa83cc671 100644 (file)
@@ -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<S*>(sptr);
+#endif
 
 extern char externalvar[];
 constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL;  // expected-error {{must be initialized by a constant expression}}