Browse Source

* fixed loading parent frame pointer for nested procvars on targets that
that use explicit parentfp structs (fixes webtbs/tw17379 for llvm)

git-svn-id: trunk@42100 -

Jonas Maebe 6 years ago
parent
commit
eb0f02348d
2 changed files with 21 additions and 7 deletions
  1. 4 2
      compiler/ncgld.pas
  2. 17 5
      tests/webtbs/tw17379.pp

+ 4 - 2
compiler/ncgld.pas

@@ -557,7 +557,8 @@ implementation
                        hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
                        hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
                      { vd will contain the type of the self pointer (self in
                      { vd will contain the type of the self pointer (self in
                        case of a class/classref, address of self in case of
                        case of a class/classref, address of self in case of
-                       an object }
+                       an object, frame pointer or pointer to parentfpstruct
+                       in case of nested procsym load  }
                      vd:=nil;
                      vd:=nil;
                      case left.location.loc of
                      case left.location.loc of
                         LOC_CREGISTER,
                         LOC_CREGISTER,
@@ -573,7 +574,8 @@ implementation
                         LOC_REFERENCE:
                         LOC_REFERENCE:
                           begin
                           begin
                              if is_implicit_pointer_object_type(left.resultdef) or
                              if is_implicit_pointer_object_type(left.resultdef) or
-                                 (left.resultdef.typ=classrefdef) then
+                                (left.resultdef.typ=classrefdef) or
+                                is_nested_pd(procdef) then
                                begin
                                begin
                                  vd:=left.resultdef;
                                  vd:=left.resultdef;
                                  location.registerhi:=hlcg.getaddressregister(current_asmdata.CurrAsmList,left.resultdef);
                                  location.registerhi:=hlcg.getaddressregister(current_asmdata.CurrAsmList,left.resultdef);

+ 17 - 5
tests/webtbs/tw17379.pp

@@ -1,22 +1,34 @@
-{ %norun }
-
 {$mode macpas}
 {$mode macpas}
 {$warnings off}
 {$warnings off}
 program recursivefunctionparam;
 program recursivefunctionparam;
 
 
 function first( function test( theint: integer): boolean): integer;
 function first( function test( theint: integer): boolean): integer;
-begin {not implemented} end;
+begin
+  test(2);
+end;
 
 
 function find: integer;
 function find: integer;
+  var
+    l: longint;
 
 
   function test( theint: integer): boolean;
   function test( theint: integer): boolean;
   begin
   begin
-    first( test)
+    if (theint = 1) then
+      first( test)
+    else
+      begin
+        writeln('nested procvar call, l = ', l);
+        if l<>1234567890 then
+          halt(1);
+      end;
+    find:=0;
   end;
   end;
 
 
 begin
 begin
-  {not implemented}
+  l:=1234567890;
+  test(1)
 end;
 end;
 
 
 begin
 begin
+  find;
 end.
 end.