[Ada] Reuse First_Formal for generic subprograms

Message ID 20210504095222.GA90506@adacore.com
State New
Headers show
  • [Ada] Reuse First_Formal for generic subprograms
Related show

Commit Message

Pierre-Marie de Rodat May 4, 2021, 9:52 a.m.
Routine First_Formal works both for non-generic and generic subprograms,
so patch removes a dubious special-casing for the latter.

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


	* lib-xref.adb (Generate_Reference_To_Formals): Remove dedicated
	branch for generic subprograms (they are now handled together
	with non-generic subprograms in the ELSE branch); replace a
	low-level Ekind membership test with a high-level call to


diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb
--- a/gcc/ada/lib-xref.adb
+++ b/gcc/ada/lib-xref.adb
@@ -1277,18 +1277,8 @@  package body Lib.Xref is
       Formal : Entity_Id;
-      if Is_Generic_Subprogram (E) then
-         Formal := First_Entity (E);
-         while Present (Formal)
-           and then not Is_Formal (Formal)
-         loop
-            Next_Entity (Formal);
-         end loop;
-      elsif Ekind (E) in Access_Subprogram_Kind then
+      if Is_Access_Subprogram_Type (E) then
          Formal := First_Formal (Designated_Type (E));
          Formal := First_Formal (E);
       end if;