Fix a failure (which led to a crash) in constant emission code with vector compound literals.

llvm-svn: 147111
This commit is contained in:
Eli Friedman 2011-12-22 00:04:00 +00:00
parent 2aa433398a
commit 5c9cd7a8a3
2 changed files with 5 additions and 3 deletions

View 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(),

View 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};