Mercurial > projects > ldc
diff gen/toobj.cpp @ 824:b972fec8a5f5
Fixed problem with moduleinfo thinking it imports itself, causing assertion failure, fixes #138
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Thu, 04 Dec 2008 14:36:11 +0100 |
parents | 35de5ba7d36d |
children | ba390e5e9150 |
line wrap: on
line diff
--- a/gen/toobj.cpp Wed Dec 03 01:40:28 2008 +0100 +++ b/gen/toobj.cpp Thu Dec 04 14:36:11 2008 +0100 @@ -743,7 +743,7 @@ for (size_t i = 0; i < aimports.dim; i++) { Module *m = (Module *)aimports.data[i]; - if (!m->needModuleInfo()) + if (!m->needModuleInfo() || m == this) continue; // declare the imported module info @@ -867,13 +867,12 @@ MIname.append(mangle()); MIname.append("8__ModuleZ"); - // declare + // declare global // flags will be modified at runtime so can't make it constant - llvm::GlobalVariable* gvar = gIR->module->getGlobalVariable(MIname); - if (!gvar) gvar = new llvm::GlobalVariable(constMI->getType(), false, llvm::GlobalValue::ExternalLinkage, NULL, MIname, gIR->module); - else assert(gvar->getType()->getContainedType(0) == constMI->getType()); - gvar->setInitializer(constMI); + // it makes no sense that the our own module info already exists! + assert(!gIR->module->getGlobalVariable(MIname)); + llvm::GlobalVariable* gvar = new llvm::GlobalVariable(constMI->getType(), false, llvm::GlobalValue::ExternalLinkage, constMI, MIname, gIR->module); // build the modulereference and ctor for registering it LLFunction* mictor = build_module_reference_and_ctor(gvar);