aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 1d1721011b..b60e20fda5 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -86,7 +86,13 @@ CodeGenFunction::GenerateStaticBlockVarDecl(const VarDecl &D,
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");