changeset 1242:f1877b6be63d

Merge with rev [1221]
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Fri, 17 Apr 2009 01:19:03 +0200
parents fc579f389f9a (current diff) f41ff8ccc249 (diff)
children 9c2dbbdd34f8
files gen/tollvm.cpp
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gen/tollvm.cpp	Fri Apr 17 00:54:20 2009 +0200
+++ b/gen/tollvm.cpp	Fri Apr 17 01:19:03 2009 +0200
@@ -305,6 +305,11 @@
         assert(0 && "not global/function");
     }
     
+    // The following breaks for nested naked functions, so check for that.
+    bool skipNestedCheck = false;
+    if (FuncDeclaration* fd = sym->isFuncDeclaration())
+        skipNestedCheck = (fd->naked != 0);
+    
     // Any symbol nested in a function can't be referenced directly from
     // outside that function, so we can give such symbols internal linkage.
     // This holds even if nested indirectly, such as member functions of
@@ -318,10 +323,11 @@
     // ---
     // if instances get emitted in multiple object files because they'd use
     // different instances of 'i'.
-    for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) {
-        if (parent->isFuncDeclaration())
-            return llvm::GlobalValue::InternalLinkage;
-    }
+    if (!skipNestedCheck)
+        for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) {
+            if (parent->isFuncDeclaration())
+                return llvm::GlobalValue::InternalLinkage;
+        }
     
     // default to external linkage
     return llvm::GlobalValue::ExternalLinkage;