Browse Source

* use fact that a method belongs to an objectsymtable to determine that
it is a method (_class is also set for nested procedures of methods),
resolves problem reported in
http://lists.freepascal.org/lists/fpc-pascal/2010-August/026259.html

git-svn-id: trunk@15898 -

Jonas Maebe 15 years ago
parent
commit
821d0c5d26
3 changed files with 43 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/symdef.pas
  3. 39 0
      tests/test/tmaclocalprocparam4h.pp

+ 1 - 0
.gitattributes

@@ -9309,6 +9309,7 @@ tests/test/tmaclocalprocparam4d.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4e.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4e.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4f.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4f.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4g.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4g.pp svneol=native#text/plain
+tests/test/tmaclocalprocparam4h.pp svneol=native#text/plain
 tests/test/tmacnonlocalexit.pp svneol=native#text/plain
 tests/test/tmacnonlocalexit.pp svneol=native#text/plain
 tests/test/tmacnonlocalgoto.pp svneol=native#text/plain
 tests/test/tmacnonlocalgoto.pp svneol=native#text/plain
 tests/test/tmacpas1.pp svneol=native#text/plain
 tests/test/tmacpas1.pp svneol=native#text/plain

+ 3 - 1
compiler/symdef.pas

@@ -3350,7 +3350,9 @@ implementation
 
 
     function tprocdef.is_methodpointer:boolean;
     function tprocdef.is_methodpointer:boolean;
       begin
       begin
-        result:=assigned(_class);
+        { don't check assigned(_class), that's also the case for nested
+          procedures inside methods }
+        result:=owner.symtabletype=ObjectSymtable;
       end;
       end;
 
 
 
 

+ 39 - 0
tests/test/tmaclocalprocparam4h.pp

@@ -0,0 +1,39 @@
+{$mode macpas}
+type    
+myObject = object
+    procedure procA (x: integer);
+    procedure procC (procedure procD (var y: myObject));
+  end;
+
+  procedure  myObject. procC (procedure procD (var y: myObject));
+    var
+      x: myobject;
+    begin
+      procD (x);
+      {more code here ...}
+    end;
+  
+var
+  ok: boolean;
+
+procedure myObject.ProcA (x: integer);
+
+    procedure ProcB (var y: myObject);
+      begin
+        ok:=true;
+      end;
+
+  begin
+    procC(ProcB);
+  end;
+
+var
+  o: myobject;
+begin
+  ok:=false;
+  new(o);
+  o.proca(1);
+  dispose(o);
+  if not ok then
+    halt(1);
+end.