From e068df24b21701f002b4a667794c5d9144947714 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Wed, 19 Dec 2012 02:09:19 +0100 Subject: [PATCH] Workaround for AA literal initialization ICE. Just executing toConstElem speculatively in AssocArrayLiteralExp::toElem probably isn't the best idea anyway, I would not be surprised if there are other similar bugs. GitHub: Fixes #248. --- gen/toir.cpp | 12 ++++++++++++ tests/d2/dmd-testsuite | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gen/toir.cpp b/gen/toir.cpp index 8d68ded1..2407c374 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -1293,6 +1293,18 @@ LLConstant* AddrExp::toConstElem(IRState* p) // global variable if (VarDeclaration* vd = vexp->var->isVarDeclaration()) { + if (!vd->isDataseg()) + { + // Not sure if this can be triggered from user code, but it is + // needed for the current hacky implementation of + // AssocArrayLiteralExp::toElem, which requires on error + // gagging to check for constantness of the initializer. + error("cannot use address of non-global variable '%s' " + "as constant initializer", vd->toChars()); + if (!global.gag) fatal(); + return NULL; + } + vd->codegen(Type::sir); LLConstant* llc = llvm::dyn_cast(vd->ir.getIrValue()); assert(llc); diff --git a/tests/d2/dmd-testsuite b/tests/d2/dmd-testsuite index a4cc3344..c962f5df 160000 --- a/tests/d2/dmd-testsuite +++ b/tests/d2/dmd-testsuite @@ -1 +1 @@ -Subproject commit a4cc3344bb874ae87c04965cca179fa920bb109a +Subproject commit c962f5df8cc40fada5e9df72ba1a6daefb82fc96