changeset 1279:04c36605feb9

Fixed array operation codegen when used from imported templates. All array operations are now emitted with template linkage. Fixed #270 .
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Wed, 29 Apr 2009 18:59:39 +0200
parents 8fb39f7f1a7c
children 00a307a393f2
files dmd/arrayop.c gen/llvmhelpers.cpp gen/tollvm.cpp
diffstat 3 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/arrayop.c	Wed Apr 29 18:39:59 2009 +0200
+++ b/dmd/arrayop.c	Wed Apr 29 18:59:39 2009 +0200
@@ -275,7 +275,7 @@
         //printf("ftype: %s\n", ftype->toChars());
         fd = new FuncDeclaration(0, 0, Lexer::idPool(name), STCundefined, ftype);
         fd->fbody = fbody;
-        fd->protection = PROTprotected;
+        fd->protection = PROTpublic;
         fd->linkage = LINKd;
 
         // special attention for array ops
--- a/gen/llvmhelpers.cpp	Wed Apr 29 18:39:59 2009 +0200
+++ b/gen/llvmhelpers.cpp	Wed Apr 29 18:59:39 2009 +0200
@@ -1352,6 +1352,12 @@
 
 bool mustDefineSymbol(Dsymbol* s)
 {
+    if (FuncDeclaration* fd = s->isFuncDeclaration())
+    {
+        if (fd->isArrayOp)
+            return true;
+    }
+
     TemplateInstance* tinst = DtoIsTemplateInstance(s);
     if (tinst)
     {
--- a/gen/tollvm.cpp	Wed Apr 29 18:39:59 2009 +0200
+++ b/gen/tollvm.cpp	Wed Apr 29 18:59:39 2009 +0200
@@ -275,9 +275,9 @@
         assert(fdecl->type->ty == Tfunction);
         TypeFunction* ft = (TypeFunction*)fdecl->type;
 
-        // array operations are always internal
+        // array operations are always template linkage
         if (fdecl->isArrayOp)
-            return llvm::GlobalValue::InternalLinkage;
+            return TEMPLATE_LINKAGE_TYPE;
         // intrinsics are always external
         if (fdecl->llvmInternal == LLVMintrinsic)
             return llvm::GlobalValue::ExternalLinkage;