Use static storage duration for file-scope compound literals, even when they
appear in non-constant initializers in C++.
llvm-svn: 145087
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 7485c71..5d43661 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1087,6 +1087,12 @@
return C;
}
+llvm::Constant *
+CodeGenModule::GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E) {
+ assert(E->isFileScope() && "not a file-scope compound literal expr");
+ return ConstExprEmitter(*this, 0).EmitLValue(E);
+}
+
static uint64_t getFieldOffset(ASTContext &C, const FieldDecl *field) {
const ASTRecordLayout &layout = C.getASTRecordLayout(field->getParent());
return layout.getFieldOffset(field->getFieldIndex());