From 821d0c5d260a5d163bea7f8c4be7314a917a0f36 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 24 Aug 2010 20:30:18 +0000 Subject: [PATCH] * 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 - --- .gitattributes | 1 + compiler/symdef.pas | 4 ++- tests/test/tmaclocalprocparam4h.pp | 39 ++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/test/tmaclocalprocparam4h.pp diff --git a/.gitattributes b/.gitattributes index 309ba94e57..59010a45e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9309,6 +9309,7 @@ tests/test/tmaclocalprocparam4d.pp svneol=native#text/plain tests/test/tmaclocalprocparam4e.pp svneol=native#text/plain tests/test/tmaclocalprocparam4f.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/tmacnonlocalgoto.pp svneol=native#text/plain tests/test/tmacpas1.pp svneol=native#text/plain diff --git a/compiler/symdef.pas b/compiler/symdef.pas index cf8d4b8fac..384bcafb79 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -3350,7 +3350,9 @@ implementation function tprocdef.is_methodpointer:boolean; begin - result:=assigned(_class); + { don't check assigned(_class), that's also the case for nested + procedures inside methods } + result:=owner.symtabletype=ObjectSymtable; end; diff --git a/tests/test/tmaclocalprocparam4h.pp b/tests/test/tmaclocalprocparam4h.pp new file mode 100644 index 0000000000..da65774985 --- /dev/null +++ b/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.