]> granicus.if.org Git - clang/commitdiff
Fix a failure (which led to a crash) in constant emission code with vector compound...
authorEli Friedman <eli.friedman@gmail.com>
Thu, 22 Dec 2011 00:04:00 +0000 (00:04 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 22 Dec 2011 00:04:00 +0000 (00:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147111 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprConstant.cpp
test/CodeGen/compound-literal.c

index 48eda17b7a81df4389c47aa4d737ae74957d6b97..136b71391088315ded28196641c4e7caf6e18c43 100644 (file)
@@ -870,7 +870,8 @@ public:
       // Note that due to the nature of compound literals, this is guaranteed
       // to be the only use of the variable, so we just generate it here.
       CompoundLiteralExpr *CLE = cast<CompoundLiteralExpr>(E);
-      llvm::Constant* C = Visit(CLE->getInitializer());
+      llvm::Constant* C = CGM.EmitConstantExpr(CLE->getInitializer(),
+                                               CLE->getType(), CGF);
       // FIXME: "Leaked" on failure.
       if (C)
         C = new llvm::GlobalVariable(CGM.getModule(), C->getType(),
index 0164c2b738621d87dcb58fa5b4307d4e36ce6887..8208513c7cfce45e5b5b19b65dc30e16a524603e 100644 (file)
@@ -2,8 +2,9 @@
 
 int* a = &(int){1};
 struct s {int a, b, c;} * b = &(struct s) {1, 2, 3};
-// Not working; complex constants are broken
-// _Complex double * x = &(_Complex double){1.0f};
+_Complex double * x = &(_Complex double){1.0f};
+typedef int v4i32 __attribute((vector_size(16)));
+v4i32 *x = &(v4i32){1,2,3,4};
 
 void xxx() {
 int* a = &(int){1};