]> granicus.if.org Git - clang/commitdiff
Don't try to emit CK_LValueBitCast casts as constants. PR9558.
authorEli Friedman <eli.friedman@gmail.com>
Mon, 24 Oct 2011 22:25:55 +0000 (22:25 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 24 Oct 2011 22:25:55 +0000 (22:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142863 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprConstant.cpp
test/CodeGenCXX/const-init.cpp

index 3997866ea68ee5001dceaa0c0c3c4ec910b3cd84..31e0f2c3b0e247c2651a4d7744a23bea8dc3d589 100644 (file)
@@ -573,7 +573,6 @@ public:
     case CK_CPointerToObjCPointerCast:
     case CK_BlockPointerToObjCPointerCast:
     case CK_AnyPointerToBlockPointerCast:
-    case CK_LValueBitCast:
     case CK_BitCast:
       if (C->getType() == destType) return C;
       return llvm::ConstantExpr::getBitCast(C, destType);
@@ -589,6 +588,7 @@ public:
     case CK_ARCConsumeObject:
     case CK_ARCReclaimReturnedObject:
     case CK_ARCExtendBlockObject:
+    case CK_LValueBitCast:
       return 0;
 
     // These might need to be supported for constexpr.
index 797d1377f698da380f8c66fb97e4cb904f9177c2..f06e546ec9a681f6f9411e8356e8a89aa750ee68 100644 (file)
@@ -36,3 +36,7 @@ namespace test2 {
   double t0 = A::d;
   double t1[] = { A::d, A::f };
 }
+
+// We don't expect to fold this in the frontend, but make sure it doesn't crash.
+// CHECK: @PR9558 = global float 0.000000e+0
+float PR9558 = reinterpret_cast<const float&>("asd");