From 584911ad4e21f3789c56bf30afc00dfda38c5b02 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Wed, 4 Feb 2009 00:50:04 +0100 Subject: [PATCH] Fixed problem with static ctors, in templated imported classes, not begin run. Fixes #203 --- gen/functions.cpp | 12 ++++++++---- gen/llvmhelpers.cpp | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gen/functions.cpp b/gen/functions.cpp index 7896865e..8646d53b 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -546,12 +546,16 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) } // static ctor - if (fdecl->isStaticCtorDeclaration() && fdecl->getModule() == gIR->dmodule) { - gIR->ctors.push_back(fdecl); + if (fdecl->isStaticCtorDeclaration()) { + if (fdecl->getModule() == gIR->dmodule || fdecl->inTemplateInstance()) { + gIR->ctors.push_back(fdecl); + } } // static dtor - else if (fdecl->isStaticDtorDeclaration() && fdecl->getModule() == gIR->dmodule) { - gIR->dtors.push_back(fdecl); + else if (fdecl->isStaticDtorDeclaration()) { + if (fdecl->getModule() == gIR->dmodule || fdecl->inTemplateInstance()) { + gIR->dtors.push_back(fdecl); + } } // we never reference parameters of function prototypes diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 82f565e1..c4b954da 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -826,6 +826,7 @@ DValue* DtoPaintType(Loc& loc, DValue* val, Type* to) // TEMPLATE HELPERS ////////////////////////////////////////////////////////////////////////////////////////*/ +// FIXME: when is this the right one to use instead of Dsymbol::inTemplateInstance() ? bool DtoIsTemplateInstance(Dsymbol* s) { if (!s) return false;