This patch adds cross-reference information to the formals of an Access_To_
Subprogram type. Previously these formals were classified as objects; now
they are references as (in, out, in-out) parameters.

Here is an example of the new output of the cross-reference utility;

      gcc -c params_pkg.adb
      gnatxref params_pkg.ali
-----
Param_1                                          parameter integer object
  Decl:  params_pkg.ads         3:23
Param_1                                          parameter integer object
  Decl:  params_pkg.ads         6:19
  Body:  params_pkg.adb         2:19
Param_2                                          parameter float object
  Decl:  params_pkg.ads         4:23
Param_2                                          parameter float object
  Decl:  params_pkg.ads         7:19
  Body:  params_pkg.adb         3:19
Params_Pkg                                       package
  Decl:  params_pkg.ads         1:9
  Body:  params_pkg.adb         1:14
Proc                                             procedure
  Decl:  params_pkg.ads         6:13
  Body:  params_pkg.adb         2:13
Proc_Access_Type                                 access type
  Decl:  params_pkg.ads         2:8

---
package Params_Pkg is
  type Proc_Access_Type is
    access procedure (Param_1 : in Integer;
                      Param_2 : out Float);

  procedure Proc (Param_1 : in Integer;
                  Param_2 : out Float);
end Params_Pkg;
---
package body Params_Pkg is
  procedure Proc (Param_1 : in Integer;
                  Param_2 : out Float) is
  begin
     null;
  end;

end Params_Pkg;

Tested on x86_64-pc-linux-gnu, committed on trunk

2013-07-05  Ed Schonberg  <schonb...@adacore.com>

        * sem_ch3.adb (Access_Subprogram_Declaration): Use
        Generate_Reference_To_Formals.
        * lib-xref.adb (Generate_Reference_To_Formals): In the case of
        access to subprograms, the formals are found in the designated
        subprogram type.

Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb (revision 200688)
+++ sem_ch3.adb (working copy)
@@ -1283,6 +1283,8 @@
       Init_Size_Align              (T_Name);
       Set_Directly_Designated_Type (T_Name, Desig_Type);
 
+      Generate_Reference_To_Formals (T_Name);
+
       --  Ada 2005 (AI-231): Propagate the null-excluding attribute
 
       Set_Can_Never_Be_Null (T_Name, Null_Exclusion_Present (T_Def));
Index: lib-xref.adb
===================================================================
--- lib-xref.adb        (revision 200688)
+++ lib-xref.adb        (working copy)
@@ -1079,6 +1079,9 @@
             Next_Entity (Formal);
          end loop;
 
+      elsif Ekind (E) in Access_Subprogram_Kind then
+         Formal := First_Formal (Designated_Type (E));
+
       else
          Formal := First_Formal (E);
       end if;
Index: lib-xref.ads
===================================================================
--- lib-xref.ads        (revision 200688)
+++ lib-xref.ads        (working copy)
@@ -718,7 +718,7 @@
 
    procedure Generate_Reference_To_Formals (E : Entity_Id);
    --  Add a reference to the definition of each formal on the line for
-   --  a subprogram.
+   --  a subprogram or an access_to_subprogram type.
 
    procedure Generate_Reference_To_Generic_Formals (E : Entity_Id);
    --  Add a reference to the definition of each generic formal on the line

Reply via email to