diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-08-26 20:01:39 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-08-26 20:01:39 +0000 |
| commit | 95f896380f6dc46c89eadec017476fc75b93e43b (patch) | |
| tree | c4afdbffd2baa223849075aab77112d98f9fb6ea | |
| parent | c24fc2949ebee5ada78f031780fab66fbf3eb4a2 (diff) | |
| download | bcm5719-llvm-95f896380f6dc46c89eadec017476fc75b93e43b.tar.gz bcm5719-llvm-95f896380f6dc46c89eadec017476fc75b93e43b.zip | |
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
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 5 | ||||
| -rw-r--r-- | clang/test/CodeGen/address-space-compound-literal.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 2be22f98ab2..593406f5d0d 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/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/clang/test/CodeGen/address-space-compound-literal.c b/clang/test/CodeGen/address-space-compound-literal.c new file mode 100644 index 00000000000..79d19ed6b6b --- /dev/null +++ b/clang/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}; + |

