Browse Source

* fixed compiler crash when using nested procedures in Objective-C methods

git-svn-id: trunk@14583 -
Jonas Maebe 15 years ago
parent
commit
77fd8bacc7
3 changed files with 37 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/pdecsub.pas
  3. 34 0
      tests/test/tobjc31.pp

+ 1 - 0
.gitattributes

@@ -9081,6 +9081,7 @@ tests/test/tobjc30.pp svneol=native#text/plain
 tests/test/tobjc30a.pp svneol=native#text/plain
 tests/test/tobjc30b.pp svneol=native#text/plain
 tests/test/tobjc30c.pp svneol=native#text/plain
+tests/test/tobjc31.pp svneol=native#text/plain
 tests/test/tobjc4.pp svneol=native#text/plain
 tests/test/tobjc4a.pp svneol=native#text/plain
 tests/test/tobjc5.pp svneol=native#text/plain

+ 2 - 1
compiler/pdecsub.pas

@@ -166,7 +166,8 @@ implementation
         sl       : tpropaccesslist;
       begin
         if (pd.typ=procdef) and
-           is_objc_class_or_protocol(tprocdef(pd)._class) then
+           is_objc_class_or_protocol(tprocdef(pd)._class) and
+           (pd.parast.symtablelevel=normal_function_level) then
           begin
             { insert Objective-C self and selector parameters }
             vs:=tparavarsym.create('$_cmd',paranr_objc_cmd,vs_value,objc_seltype,[vo_is_msgsel,vo_is_hidden_para]);

+ 34 - 0
tests/test/tobjc31.pp

@@ -0,0 +1,34 @@
+{ %target=darwin }
+{ %cpu=powerpc,powerpc64,i386,x86_64,arm }
+
+{$mode objfpc}
+{$modeswitch objectivec1}
+
+{ test program by saabino80 at alice in Italy for nested procedures in
+  Objective-C methods }
+
+Program Foo;
+uses
+        ctypes, MacOSAll, CocoaAll;
+
+Type MyObjc= objcclass(NSObject)
+Procedure nested; message 'nested';
+
+End;
+Procedure MyObjc.nested;
+
+Procedure one;
+Begin;
+ WriteLn('Ciao');
+End;
+Begin
+one;
+End;
+
+Var My:MyObjc;
+Begin
+My := MyObjc.alloc;
+My.nested;
+My.release;
+End.
+