changeset 370:051ab876fe11 trunk

[svn r391] Fix classes nested inside functions for real.
author ChristianK
date Tue, 15 Jul 2008 10:23:50 +0200
parents 7d91d82000ae
children f2b608012699
files gen/classes.cpp gen/llvmhelpers.cpp tests/mini/nested6a.d
diffstat 3 files changed, 42 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gen/classes.cpp	Tue Jul 15 08:44:08 2008 +0200
+++ b/gen/classes.cpp	Tue Jul 15 10:23:50 2008 +0200
@@ -828,7 +828,8 @@
         Logger::println("Resolving nested context");
         LOG_SCOPE;
 
-        LLValue* gep = DtoGEPi(mem,0,2,"tmp");
+        size_t idx = 2 + tc->sym->vthis->ir.irField->index;
+        LLValue* gep = DtoGEPi(mem,0,idx,"tmp");
 
         // this value might be zero if it was not necessary to generate it ...
         LLValue* nest = gIR->func()->nestedVar;
--- a/gen/llvmhelpers.cpp	Tue Jul 15 08:44:08 2008 +0200
+++ b/gen/llvmhelpers.cpp	Tue Jul 15 10:23:50 2008 +0200
@@ -382,7 +382,7 @@
         }
         else if (ClassDeclaration* cd = fd->toParent2()->isClassDeclaration())
         {
-            v = DtoGEPi(v,0,2,"tmp");
+            v = DtoGEPi(v,0,2+cd->vthis->ir.irField->index,"tmp");
             v = DtoLoad(v);
         }
         else
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/mini/nested6a.d	Tue Jul 15 10:23:50 2008 +0200
@@ -0,0 +1,39 @@
+module nested6a;
+extern(C) int printf(char*, ...);
+
+void main()
+{
+    int i = 42;
+
+    printf("main() %d\n", i++);
+
+    class C
+    {
+        int j;
+        void func()
+        {
+	    int k;
+            printf("C.func() %d\n", i++);
+
+            class C2
+            {
+	        int l;
+                void func2()
+                {
+                    printf("C2.func2() %d\n", i++);
+                }
+		int m;
+            }
+
+            {
+                scope c2 = new C2;
+                c2.func2();
+            }
+	    int n;
+        }
+	int o;
+    }
+
+    scope c = new C;
+    c.func();
+}