comparison gen/toir.cpp @ 628:e3c46bcce65f

Detect a missing global before trying to const init it.
author Christian Kamm <kamm incasoftware de>
date Wed, 01 Oct 2008 20:32:12 +0200
parents eb444ed4a2d3
children 607b6b5819a7
comparison
equal deleted inserted replaced
627:79cbe5034fec 628:e3c46bcce65f
126 else { 126 else {
127 Logger::println("a normal variable"); 127 Logger::println("a normal variable");
128 // take care of forward references of global variables 128 // take care of forward references of global variables
129 if (vd->isDataseg() || (vd->storage_class & STCextern)) { 129 if (vd->isDataseg() || (vd->storage_class & STCextern)) {
130 vd->toObjFile(0); // TODO: multiobj 130 vd->toObjFile(0); // TODO: multiobj
131 DtoConstInitGlobal(vd);
132 } 131 }
133 if (!vd->ir.isSet() || !vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) { 132 if (!vd->ir.isSet() || !vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) {
134 error("global variable %s not resolved", vd->toChars()); 133 error("global variable %s not resolved", vd->toChars());
135 if (Logger::enabled()) 134 if (Logger::enabled())
136 Logger::cout() << "unresolved global had type: " << *DtoType(vd->type) << '\n'; 135 Logger::cout() << "unresolved global had type: " << *DtoType(vd->type) << '\n';
137 fatal(); 136 fatal();
137 }
138 if (vd->isDataseg() || (vd->storage_class & STCextern)) {
139 DtoConstInitGlobal(vd);
138 } 140 }
139 return new DVarValue(type, vd, vd->ir.getIrValue()); 141 return new DVarValue(type, vd, vd->ir.getIrValue());
140 } 142 }
141 } 143 }
142 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) 144 else if (FuncDeclaration* fdecl = var->isFuncDeclaration())