Ver código fonte

* when creating a bare procdef copy, don't copy the funcret parameter.
This is useful if you want to change the calling convention of the copy.
o call insert_funcret_para() after creating a bare copy
* don't copy aliasnames of copied procdefs either (can at best result
in duplicate symbol errors)

git-svn-id: trunk@28227 -

Jonas Maebe 11 anos atrás
pai
commit
627c83e828
2 arquivos alterados com 24 adições e 16 exclusões
  1. 3 0
      compiler/jvm/pjvm.pas
  2. 21 16
      compiler/symdef.pas

+ 3 - 0
compiler/jvm/pjvm.pas

@@ -505,6 +505,7 @@ implementation
         methoddef:=tprocdef(tprocvardef(def).getcopyas(procdef,pc_bareproc));
         methoddef:=tprocdef(tprocvardef(def).getcopyas(procdef,pc_bareproc));
         finish_copied_procdef(methoddef,'invoke',pvclass.symtable,pvclass);
         finish_copied_procdef(methoddef,'invoke',pvclass.symtable,pvclass);
         insert_self_and_vmt_para(methoddef);
         insert_self_and_vmt_para(methoddef);
+        insert_funcret_para(methoddef);
         methoddef.synthetickind:=tsk_jvm_procvar_invoke;
         methoddef.synthetickind:=tsk_jvm_procvar_invoke;
         methoddef.calcparas;
         methoddef.calcparas;
 
 
@@ -539,6 +540,7 @@ implementation
             methoddef:=tprocdef(tprocvardef(def).getcopyas(procdef,pc_bareproc));
             methoddef:=tprocdef(tprocvardef(def).getcopyas(procdef,pc_bareproc));
             finish_copied_procdef(methoddef,name+'Callback',pvintf.symtable,pvintf);
             finish_copied_procdef(methoddef,name+'Callback',pvintf.symtable,pvintf);
             insert_self_and_vmt_para(methoddef);
             insert_self_and_vmt_para(methoddef);
+            insert_funcret_para(methoddef);
             { can't be final/static/private/protected, and must be virtual
             { can't be final/static/private/protected, and must be virtual
               since it's an interface method }
               since it's an interface method }
             methoddef.procoptions:=methoddef.procoptions-[po_staticmethod,po_finalmethod];
             methoddef.procoptions:=methoddef.procoptions-[po_staticmethod,po_finalmethod];
@@ -680,6 +682,7 @@ implementation
         { since it was a bare copy, insert the self parameter (we can't just
         { since it was a bare copy, insert the self parameter (we can't just
           copy the vmt parameter from the constructor, that's different) }
           copy the vmt parameter from the constructor, that's different) }
         insert_self_and_vmt_para(wrapperpd);
         insert_self_and_vmt_para(wrapperpd);
+        insert_funcret_para(wrapperpd);
         wrapperpd.calcparas;
         wrapperpd.calcparas;
         { implementation: call through to the constructor
         { implementation: call through to the constructor
           Exception: if the current class is abstract, do not call the
           Exception: if the current class is abstract, do not call the

+ 21 - 16
compiler/symdef.pas

@@ -4453,7 +4453,7 @@ implementation
                   { in case of bare proc, don't copy self, vmt or framepointer
                   { in case of bare proc, don't copy self, vmt or framepointer
                     parameters }
                     parameters }
                   if (copytyp=pc_bareproc) and
                   if (copytyp=pc_bareproc) and
-                     (([vo_is_self,vo_is_vmt,vo_is_parentfp,vo_is_result]*pvs.varoptions)<>[]) then
+                     (([vo_is_self,vo_is_vmt,vo_is_parentfp,vo_is_result,vo_is_funcret]*pvs.varoptions)<>[]) then
                     continue;
                     continue;
                   npvs:=cparavarsym.create(pvs.realname,pvs.paranr,pvs.varspez,
                   npvs:=cparavarsym.create(pvs.realname,pvs.paranr,pvs.varspez,
                     pvs.vardef,pvs.varoptions);
                     pvs.vardef,pvs.varoptions);
@@ -5188,24 +5188,29 @@ implementation
           tprocdef(result).deprecatedmsg:=stringdup(deprecatedmsg^);
           tprocdef(result).deprecatedmsg:=stringdup(deprecatedmsg^);
         { will have to be associated with appropriate procsym }
         { will have to be associated with appropriate procsym }
         tprocdef(result).procsym:=nil;
         tprocdef(result).procsym:=nil;
+        { don't create aliases for bare copies, nor copy the funcretsym as
+          the function result parameter will be inserted again if necessary
+          (e.g. if the calling convention is changed) }
         if copytyp<>pc_bareproc then
         if copytyp<>pc_bareproc then
-          tprocdef(result).aliasnames.concatListcopy(aliasnames);
-        if assigned(funcretsym) then
           begin
           begin
-            if funcretsym.owner=parast then
+            tprocdef(result).aliasnames.concatListcopy(aliasnames);
+            if assigned(funcretsym) then
               begin
               begin
-                j:=parast.symlist.indexof(funcretsym);
-                if j<0 then
-                  internalerror(2011040606);
-                tprocdef(result).funcretsym:=tsym(tprocdef(result).parast.symlist[j]);
-              end
-            else if funcretsym.owner=localst then
-              begin
-                { nothing to do, will be inserted for the new procdef while
-                  parsing its body (by pdecsub.insert_funcret_local) }
-              end
-            else
-              internalerror(2011040605);
+                if funcretsym.owner=parast then
+                  begin
+                    j:=parast.symlist.indexof(funcretsym);
+                    if j<0 then
+                      internalerror(2011040606);
+                    tprocdef(result).funcretsym:=tsym(tprocdef(result).parast.symlist[j]);
+                  end
+                else if funcretsym.owner=localst then
+                  begin
+                    { nothing to do, will be inserted for the new procdef while
+                      parsing its body (by pdecsub.insert_funcret_local) }
+                  end
+                else
+                  internalerror(2011040605);
+              end;
           end;
           end;
         { will have to be associated with a new struct }
         { will have to be associated with a new struct }
         tprocdef(result).struct:=nil;
         tprocdef(result).struct:=nil;