changeset 1381:44c8eef6e6ee

Fixed filename in array bounds check for mixed in imported template function. Fixes ticket #295 .
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Sun, 17 May 2009 14:56:29 +0200
parents 98d435fa2a2d
children a0a4d4dac1a4
files gen/arrays.cpp
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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<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);