# HG changeset patch # User Tomas Lindquist Olsen # Date 1242564989 -7200 # Node ID 44c8eef6e6ee6b26411c9df150daef30dbac49b2 # Parent 98d435fa2a2d9f8348f15d58a6e0d2efbcc8eec0 Fixed filename in array bounds check for mixed in imported template function. Fixes ticket #295 . diff -r 98d435fa2a2d -r 44c8eef6e6ee gen/arrays.cpp --- a/gen/arrays.cpp Sun May 17 14:40:09 2009 +0200 +++ b/gen/arrays.cpp Sun May 17 14:56:29 2009 +0200 @@ -1024,10 +1024,18 @@ 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);