Add preliminary (and probably broken) codegen support for C++ static initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55180 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 1d17210..b60e20f 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -86,7 +86,13 @@
if ((D.getInit() == 0) || NoInit) {
Init = llvm::Constant::getNullValue(LTy);
} else {
- Init = CGM.EmitConstantExpr(D.getInit(), this);
+ if (D.getInit()->isConstantExpr(getContext(), 0))
+ Init = CGM.EmitConstantExpr(D.getInit(), this);
+ else {
+ assert(getContext().getLangOptions().CPlusPlus &&
+ "only C++ supports non-constant static initializers!");
+ return GenerateStaticCXXBlockVarDecl(D);
+ }
}
assert(Init && "Unable to create initialiser for static decl");