[cfe-commits] r147111 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGen/compound-literal.c

Eli Friedman eli.friedman at gmail.com
Wed Dec 21 16:04:00 PST 2011


Author: efriedma
Date: Wed Dec 21 18:04:00 2011
New Revision: 147111

URL: http://llvm.org/viewvc/llvm-project?rev=147111&view=rev
Log:
Fix a failure (which led to a crash) in constant emission code with vector compound literals.


Modified:
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
    cfe/trunk/test/CodeGen/compound-literal.c

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=147111&r1=147110&r2=147111&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Dec 21 18:04:00 2011
@@ -870,7 +870,8 @@
       // 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(),

Modified: cfe/trunk/test/CodeGen/compound-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/compound-literal.c?rev=147111&r1=147110&r2=147111&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/compound-literal.c (original)
+++ cfe/trunk/test/CodeGen/compound-literal.c Wed Dec 21 18:04:00 2011
@@ -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};





More information about the cfe-commits mailing list