summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-09-07 23:26:17 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-09-07 23:26:17 +0000
commit366a94822bf210cbb5d32a76b63e8423268565db (patch)
tree74d9fffd4baacf1929d943159a112bb0030b7f52 /clang/lib/CodeGen/CGDecl.cpp
parenta4d9c78aa1689e86961c96b7a7feaa67d83373ba (diff)
downloadbcm5719-llvm-366a94822bf210cbb5d32a76b63e8423268565db.tar.gz
bcm5719-llvm-366a94822bf210cbb5d32a76b63e8423268565db.zip
Local static block variable referecned in its
block-literal initializer expression causes IRgen to crash. This patch fixes by saving it in StaticLocalDecl map already used for such purposes. (radar 8390455). llvm-svn: 113307
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 57e5236c67e..97c03410871 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -244,6 +244,10 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D,
// Make sure to evaluate VLA bounds now so that we have them for later.
if (D.getType()->isVariablyModifiedType())
EmitVLASize(D.getType());
+
+ // Local static block variables must be treated as globals as they may be
+ // referenced in their RHS initializer block-literal expresion.
+ CGM.setStaticLocalDeclAddress(&D, GV);
// If this value has an initializer, emit it.
if (D.getInit())
@@ -266,9 +270,6 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D,
if (D.hasAttr<UsedAttr>())
CGM.AddUsedGlobal(GV);
- if (getContext().getLangOptions().CPlusPlus)
- CGM.setStaticLocalDeclAddress(&D, GV);
-
// We may have to cast the constant because of the initializer
// mismatch above.
//
OpenPOWER on IntegriCloud