浏览代码

* 8086: Fixed Ofs() for far routines.
resultdef of typeconvnode.typecheck_proc_to_procvar() is reused every time you get an address of a proc. So it is forbidden to change the far/near attribute of resultdef - it leads to mess during code generation.
Instead it is needed to use separate reusable resultdefs with new flags pc_far_address and pc_offset.

git-svn-id: trunk@46470 -

yury 5 年之前
父节点
当前提交
222f981dd1
共有 2 个文件被更改,包括 16 次插入2 次删除
  1. 10 2
      compiler/i8086/n8086cnv.pas
  2. 6 0
      compiler/symdef.pas

+ 10 - 2
compiler/i8086/n8086cnv.pas

@@ -70,14 +70,22 @@ implementation
           begin
           begin
             if resultdef.typ<>procvardef then
             if resultdef.typ<>procvardef then
               internalerror(2018040401);
               internalerror(2018040401);
-            exclude(tprocvardef(resultdef).procoptions,po_far);
+            if po_far in tprocvardef(resultdef).procoptions then
+              begin
+                resultdef:=cprocvardef.getreusableprocaddr(tabstractprocdef(left.resultdef),pc_offset);
+                exclude(tprocvardef(resultdef).procoptions,po_far);
+              end;
           end
           end
         else if (tcnf_proc_2_procvar_2_voidpointer in convnodeflags) and
         else if (tcnf_proc_2_procvar_2_voidpointer in convnodeflags) and
                 (current_settings.x86memorymodel in x86_far_code_models) then
                 (current_settings.x86memorymodel in x86_far_code_models) then
           begin
           begin
             if resultdef.typ<>procvardef then
             if resultdef.typ<>procvardef then
               internalerror(2018040402);
               internalerror(2018040402);
-            include(tprocvardef(resultdef).procoptions,po_far);
+            if not (po_far in tprocvardef(resultdef).procoptions) then
+              begin
+                resultdef:=cprocvardef.getreusableprocaddr(tabstractprocdef(left.resultdef),pc_far_address);
+                include(tprocvardef(resultdef).procoptions,po_far);
+              end;
           end;
           end;
       end;
       end;
 
 

+ 6 - 0
compiler/symdef.pas

@@ -643,6 +643,12 @@ interface
          pno_mangledname, pno_noparams);
          pno_mangledname, pno_noparams);
        tprocnameoptions = set of tprocnameoption;
        tprocnameoptions = set of tprocnameoption;
        tproccopytyp = (pc_normal,
        tproccopytyp = (pc_normal,
+{$ifdef i8086}
+                       { the address in a far format }
+                       pc_far_address,
+                       { the offset part of the far address }
+                       pc_offset,
+{$endif i8086}
                        { creates a procvardef describing only the code pointer
                        { creates a procvardef describing only the code pointer
                          of a method/netsted function/... }
                          of a method/netsted function/... }
                        pc_address_only,
                        pc_address_only,