From 0414a5acbb1f38f803b59add002ccc59d908c928 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Sun, 17 May 2009 14:56:29 +0200 Subject: [PATCH] Fixed filename in array bounds check for mixed in imported template function. Fixes ticket #295 . --- gen/arrays.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 6a463a52..3da0d4e1 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -1024,10 +1024,18 @@ void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, bool isslice) std::vector 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);