Fixed filename in array bounds check for mixed in imported template function. Fixes ticket #295 .

This commit is contained in:
Tomas Lindquist Olsen
2009-05-17 14:56:29 +02:00
parent 9be5694168
commit 0414a5acbb

View File

@@ -1024,10 +1024,18 @@ void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, bool isslice)
std::vector<LLValue*> args;
// file param
// get the filename from the function symbol instead of the current module
// it's wrong for instantiations of imported templates. Fixes LDC bug #271
// we might be generating for an imported template function
Module* funcmodule = gIR->func()->decl->getModule();
args.push_back(DtoLoad(getIrModule(NULL)->fileName));
const char* cur_file = funcmodule->srcfile->name->toChars();
if (loc.filename && strcmp(loc.filename, cur_file) != 0)
{
args.push_back(DtoConstString(loc.filename));
}
else
{
IrModule* irmod = getIrModule(funcmodule);
args.push_back(DtoLoad(irmod->fileName));
}
// line param
LLConstant* c = DtoConstUint(loc.linnum);