changeset 17:6c6cd097bcdf trunk

[svn r21] * Fixed local instances of imported templates
author lindquist
date Wed, 03 Oct 2007 06:14:41 +0200
parents 860524276608
children c05ef76f1c20
files gen/toobj.c lib/llvmdcore.bc lib/lphobos.bc test/imports2.d
diffstat 4 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gen/toobj.c	Wed Oct 03 05:41:15 2007 +0200
+++ b/gen/toobj.c	Wed Oct 03 06:14:41 2007 +0200
@@ -630,7 +630,7 @@
     const llvm::FunctionType* functype = llvm::cast<llvm::FunctionType>(llvmValue->getType()->getContainedType(0));
 
     // only members of the current module maybe be defined
-    if (getModule() == gIR->dmodule)
+    if (getModule() == gIR->dmodule || parent->isTemplateInstance())
     {
         llvmDModule = gIR->dmodule;
 
@@ -730,5 +730,10 @@
 
             gIR->funcdecls.pop_back();
         }
+
+        // template instances should have weak linkage
+        if (parent->isTemplateInstance()) {
+            func->setLinkage(llvm::GlobalValue::WeakLinkage);
+        }
     }
 }
Binary file lib/llvmdcore.bc has changed
Binary file lib/lphobos.bc has changed
--- a/test/imports2.d	Wed Oct 03 05:41:15 2007 +0200
+++ b/test/imports2.d	Wed Oct 03 06:14:41 2007 +0200
@@ -1,6 +1,8 @@
-module test;
+module imports2;
 import std.stdio;
 
 void main() {
     writefln("Hello world!"[]);
+    print(42);
+    printf("\n");
 }