]> granicus.if.org Git - clang/commitdiff
Make address-space qualification work correctly for compound literals.
authorEli Friedman <eli.friedman@gmail.com>
Wed, 26 Aug 2009 20:01:39 +0000 (20:01 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 26 Aug 2009 20:01:39 +0000 (20:01 +0000)
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

lib/CodeGen/CGExprConstant.cpp
test/CodeGen/address-space-compound-literal.c [new file with mode: 0644]

index 2be22f98ab2e3e3abf0b2ac962085e93bfbb1511..593406f5d0d3054e3ce62233dfb3766c166d2037 100644 (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: 
diff --git a/test/CodeGen/address-space-compound-literal.c b/test/CodeGen/address-space-compound-literal.c
new file mode 100644 (file)
index 0000000..79d19ed
--- /dev/null
@@ -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};
+