From 86a9605014f424c556032c2c1586cbfbc4b72131 Mon Sep 17 00:00:00 2001
From: Piotr Trojanek <trojanek@adacore.com>
Date: Wed, 6 Jan 2021 12:04:56 +0100
Subject: [PATCH] [Ada] Reuse Is_Formal_Object where convenient

gcc/ada/

	* exp_prag.adb, sem_prag.adb: Replace low-level Ekind membership
	tests with a high-level call to Is_Formal_Object.
---
 gcc/ada/exp_prag.adb | 3 +--
 gcc/ada/sem_prag.adb | 8 ++------
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
index c559184781b2..53c937db3b12 100644
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -2368,10 +2368,9 @@ package body Exp_Prag is
                if Comes_From_Source (E)
                  and then Is_Object (E)
                  and then not Is_Entry_Formal (E)
+                 and then not Is_Formal_Object (E)
                  and then Ekind (E) /= E_Component
                  and then Ekind (E) /= E_Discriminant
-                 and then Ekind (E) /= E_Generic_In_Parameter
-                 and then Ekind (E) /= E_Generic_In_Out_Parameter
                then
                   Append_To (A,
                     Make_Pragma_Argument_Association (Loc,
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index e1752060045b..b6544952e1df 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -718,9 +718,7 @@ package body Sem_Prag is
          elsif Ekind (Item_Id) = E_Constant then
             Add_Str_To_Name_Buffer ("constant");
 
-         elsif Ekind (Item_Id) in
-                 E_Generic_In_Out_Parameter | E_Generic_In_Parameter
-         then
+         elsif Is_Formal_Object (Item_Id) then
             Add_Str_To_Name_Buffer ("generic parameter");
 
          elsif Is_Formal (Item_Id) then
@@ -3098,9 +3096,7 @@ package body Sem_Prag is
                         --  it is allowed for an initialization item to depend
                         --  on an input item.
 
-                        if Ekind (Input_Id) in E_Generic_In_Out_Parameter
-                                             | E_Generic_In_Parameter
-                        then
+                        if Is_Formal_Object (Input_Id) then
                            null;
 
                         elsif Ekind (Input_Id) in E_Constant | E_Variable
-- 
GitLab