Use collective N_Generic_Declaration subtype instead of its members
N_Generic_Subprogram_Declaration and N_Generic_Package_Declaration where
reasonable. Code cleanup related to handling of Global contracts in
generic units; semantics is unaffected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch10.adb, sem_prag.adb, sem_util.adb: Use
N_Generic_Declaration in membership tests.
diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb
--- a/gcc/ada/sem_ch10.adb
+++ b/gcc/ada/sem_ch10.adb
@@ -4162,8 +4162,7 @@ package body Sem_Ch10 is
end if;
if Ekind (P_Name) = E_Generic_Package
- and then Nkind (Lib_Unit) not in N_Generic_Subprogram_Declaration
- | N_Generic_Package_Declaration
+ and then Nkind (Lib_Unit) not in N_Generic_Declaration
| N_Generic_Renaming_Declaration
then
Error_Msg_N
@@ -6193,9 +6192,7 @@ package body Sem_Ch10 is
("subprogram not allowed in `LIMITED WITH` clause", N);
return;
- when N_Generic_Package_Declaration
- | N_Generic_Subprogram_Declaration
- =>
+ when N_Generic_Declaration =>
Error_Msg_N ("generic not allowed in `LIMITED WITH` clause", N);
return;
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -6678,9 +6678,7 @@ package body Sem_Prag is
then
Pragma_Misplaced;
- elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
- or else Nkind (Parent_Node) =
- N_Generic_Subprogram_Declaration)
+ elsif Nkind (Parent_Node) in N_Generic_Declaration
and then Plist = Generic_Formal_Declarations (Parent_Node)
then
Pragma_Misplaced;
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -8030,8 +8030,7 @@ package body Sem_Util is
if Present (Spec_Id)
and then Nkind (Unit_Declaration_Node (Spec_Id)) in
- N_Generic_Package_Declaration |
- N_Generic_Subprogram_Declaration
+ N_Generic_Declaration
then
return Par;
end if;
@@ -8055,9 +8054,7 @@ package body Sem_Util is
begin
Par := Parent (N);
while Present (Par) loop
- if Nkind (Par) in N_Generic_Package_Declaration
- | N_Generic_Subprogram_Declaration
- then
+ if Nkind (Par) in N_Generic_Declaration then
return Par;
elsif Nkind (Par) in N_Package_Body | N_Subprogram_Body then
@@ -8066,9 +8063,7 @@ package body Sem_Util is
if Present (Spec_Id) then
Spec_Decl := Unit_Declaration_Node (Spec_Id);
- if Nkind (Spec_Decl) in N_Generic_Package_Declaration
- | N_Generic_Subprogram_Declaration
- then
+ if Nkind (Spec_Decl) in N_Generic_Declaration then
return Spec_Decl;
end if;
end if;
@@ -17891,9 +17886,7 @@ package body Sem_Util is
-- a generic body modifies the Ekind of its spec to allow for recursive
-- calls.
- return
- Nkind (Spec_Decl) in N_Generic_Package_Declaration
- | N_Generic_Subprogram_Declaration;
+ return Nkind (Spec_Decl) in N_Generic_Declaration;
end Is_Generic_Declaration_Or_Body;
---------------------------