aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-08-26 20:01:39 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-08-26 20:01:39 +0000
commitd15d8c6395bbdc9b344ba6c6edf152502c2abfde (patch)
tree379d174d8f7899ebcb43cb552addd5900e517590
parent2cf738f1944d1cc724ea7561b84440a3a1059e45 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80131 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExprConstant.cpp5
-rw-r--r--test/CodeGen/address-space-compound-literal.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 2be22f98ab..593406f5d0 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -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:
diff --git a/test/CodeGen/address-space-compound-literal.c b/test/CodeGen/address-space-compound-literal.c
new file mode 100644
index 0000000000..79d19ed6b6
--- /dev/null
+++ b/test/CodeGen/address-space-compound-literal.c
@@ -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};
+