Browse Source

* correctly handle calling convention for function references

Sven/Sarah Barth 3 years ago
parent
commit
533a11ec80
3 changed files with 24 additions and 4 deletions
  1. 12 2
      compiler/pdecl.pas
  2. 6 1
      compiler/pdecvar.pas
  3. 6 1
      compiler/pgenutil.pas

+ 12 - 2
compiler/pdecl.pas

@@ -222,6 +222,7 @@ implementation
          orgname : TIDString;
          orgname : TIDString;
          hdef : tdef;
          hdef : tdef;
          sym : tsym;
          sym : tsym;
+         flags : thccflags;
          dummysymoptions : tsymoptions;
          dummysymoptions : tsymoptions;
          deprecatedmsg : pshortstring;
          deprecatedmsg : pshortstring;
          storetokenpos,filepos : tfileposinfo;
          storetokenpos,filepos : tfileposinfo;
@@ -341,7 +342,11 @@ implementation
                          skip_initialiser:=true;
                          skip_initialiser:=true;
                        end;
                        end;
                       { add default calling convention }
                       { add default calling convention }
-                      handle_calling_convention(hdef,hcc_default_actions_intf);
+                      if hdef.typ=procvardef then
+                        flags:=hcc_default_actions_intf
+                      else
+                        flags:=hcc_default_actions_intf_struct;
+                      handle_calling_convention(hdef,flags);
                     end;
                     end;
                    { Parse the initialiser }
                    { Parse the initialiser }
                    if not skip_initialiser then
                    if not skip_initialiser then
@@ -698,6 +703,7 @@ implementation
          defpos,storetokenpos : tfileposinfo;
          defpos,storetokenpos : tfileposinfo;
          old_block_type : tblock_type;
          old_block_type : tblock_type;
          old_checkforwarddefs: TFPObjectList;
          old_checkforwarddefs: TFPObjectList;
+         flags : thccflags;
          setdummysym,
          setdummysym,
          first,
          first,
          isgeneric,
          isgeneric,
@@ -1074,7 +1080,11 @@ implementation
                            if current_scanner.replay_stack_depth=0 then
                            if current_scanner.replay_stack_depth=0 then
                              hdef.register_def;
                              hdef.register_def;
                          end;
                          end;
-                       handle_calling_convention(hdef,hcc_default_actions_intf);
+                       if hdef.typ=procvardef then
+                         flags:=hcc_default_actions_intf
+                       else
+                         flags:=hcc_default_actions_intf_struct;
+                       handle_calling_convention(hdef,flags);
                        if (hdef.typ=procvardef) and (po_is_function_ref in tprocvardef(hdef).procoptions) then
                        if (hdef.typ=procvardef) and (po_is_function_ref in tprocvardef(hdef).procoptions) then
                          begin
                          begin
                            if (po_is_block in tprocvardef(hdef).procoptions) and
                            if (po_is_block in tprocvardef(hdef).procoptions) and

+ 6 - 1
compiler/pdecvar.pas

@@ -1345,6 +1345,7 @@ implementation
          vs   : tabstractvarsym;
          vs   : tabstractvarsym;
          hdef : tdef;
          hdef : tdef;
          i    : longint;
          i    : longint;
+         flags : thccflags;
          first,
          first,
          isgeneric,
          isgeneric,
          semicoloneaten,
          semicoloneaten,
@@ -1557,7 +1558,11 @@ implementation
                        end;
                        end;
                    end;
                    end;
                  { Add calling convention for procvar }
                  { Add calling convention for procvar }
-                 handle_calling_convention(hdef,hcc_default_actions_intf);
+                 if hdef.typ=procvardef then
+                   flags:=hcc_default_actions_intf
+                 else
+                   flags:=hcc_default_actions_intf_struct;
+                 handle_calling_convention(hdef,flags);
                  { Handling of Delphi typed const = initialized vars }
                  { Handling of Delphi typed const = initialized vars }
                  if (token=_EQ) and
                  if (token=_EQ) and
                     not(m_tp7 in current_settings.modeswitches) and
                     not(m_tp7 in current_settings.modeswitches) and

+ 6 - 1
compiler/pgenutil.pas

@@ -1659,6 +1659,7 @@ uses
         tsrsym : ttypesym;
         tsrsym : ttypesym;
         psym,
         psym,
         srsym : tsym;
         srsym : tsym;
+        flags : thccflags;
         paramdef1,
         paramdef1,
         paramdef2,
         paramdef2,
         def : tdef;
         def : tdef;
@@ -2020,7 +2021,11 @@ uses
                         parse_proctype_directives(tprocvardef(result));
                         parse_proctype_directives(tprocvardef(result));
                       if po_is_function_ref in tprocvardef(result).procoptions then
                       if po_is_function_ref in tprocvardef(result).procoptions then
                         adjust_funcref(result,srsym,nil);
                         adjust_funcref(result,srsym,nil);
-                      handle_calling_convention(result,hcc_default_actions_intf);
+                      if result.typ=procvardef then
+                        flags:=hcc_default_actions_intf
+                      else
+                        flags:=hcc_default_actions_intf_struct;
+                      handle_calling_convention(result,flags);
                       if not hintsprocessed and (replaydepth>current_scanner.replay_stack_depth) then
                       if not hintsprocessed and (replaydepth>current_scanner.replay_stack_depth) then
                         begin
                         begin
                           try_consume_hintdirective(ttypesym(srsym).symoptions,ttypesym(srsym).deprecatedmsg);
                           try_consume_hintdirective(ttypesym(srsym).symoptions,ttypesym(srsym).deprecatedmsg);