Make address-space qualification work correctly for compound literals.

Issue reported on cfe-dev.

Also fixed the code to use isConstant to determine whether to generate a 
constant global, to be consistent with CodeGenModule.  This probably 
needs to be refactored to deal with C++, though.

llvm-svn: 80131
This commit is contained in:
Eli Friedman 2009-08-26 20:01:39 +00:00
parent c24fc2949e
commit 95f896380f
2 changed files with 8 additions and 2 deletions

View File

@ -591,9 +591,10 @@ public:
// FIXME: "Leaked" on failure.
if (C)
C = new llvm::GlobalVariable(CGM.getModule(), C->getType(),
E->getType().isConstQualified(),
E->getType().isConstant(CGM.getContext()),
llvm::GlobalValue::InternalLinkage,
C, ".compoundliteral");
C, ".compoundliteral", 0, false,
E->getType().getAddressSpace());
return C;
}
case Expr::DeclRefExprClass:

View File

@ -0,0 +1,5 @@
// RUN: clang-cc -emit-llvm < %s | grep "internal addrspace(1) global i32 1"
typedef int a __attribute__((address_space(1)));
a* x = &(a){1};