From: Ronan Desplanques <desplanq...@adacore.com> Before this patch, the subtype declarations for Standard.Natural and Standard.Positive were created before the entity for Standard.Integer was complete. In preparation of a future change that will make it impossible to call Etype on an incomplete node, this patch delays the creation of these subtype declarations. It doesn't affect the behavior of the compiler.
gcc/ada/ChangeLog: * cstand.adb (Create_Standard): Delay declaration generation for Natural and Positive. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/cstand.adb | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/gcc/ada/cstand.adb b/gcc/ada/cstand.adb index 41b0fec157f..14c7496fa61 100644 --- a/gcc/ada/cstand.adb +++ b/gcc/ada/cstand.adb @@ -612,25 +612,14 @@ package body CStand is Set_Is_Pure (Standard_Standard); Set_Is_Compilation_Unit (Standard_Standard); - -- Create type/subtype declaration nodes for standard types + -- Create type declaration nodes for standard types for S in S_Types loop - - -- Subtype declaration case - - if S = S_Natural or else S = S_Positive then - Decl := New_Node (N_Subtype_Declaration, Stloc); - Set_Subtype_Indication (Decl, - New_Occurrence_Of (Standard_Integer, Stloc)); - - -- Full type declaration case - - else + if S not in S_Natural | S_Positive then Decl := New_Node (N_Full_Type_Declaration, Stloc); + Set_Defining_Identifier (Decl, Standard_Entity (S)); + Append (Decl, Decl_S); end if; - - Set_Defining_Identifier (Decl, Standard_Entity (S)); - Append (Decl, Decl_S); end loop; Create_Back_End_Float_Types; @@ -1021,6 +1010,14 @@ package body CStand is Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); Set_Is_Constrained (Standard_Natural); + Append_To + (Decl_S, + Make_Subtype_Declaration + (Stloc, + Standard_Natural, + Subtype_Indication => + New_Occurrence_Of (Standard_Integer, Stloc))); + -- Setup entity for Positive Mutate_Ekind (Standard_Positive, E_Signed_Integer_Subtype); @@ -1038,6 +1035,14 @@ package body CStand is Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); Set_Is_Constrained (Standard_Positive); + Append_To + (Decl_S, + Make_Subtype_Declaration + (Stloc, + Standard_Positive, + Subtype_Indication => + New_Occurrence_Of (Standard_Integer, Stloc))); + -- Create declaration for package ASCII Decl := New_Node (N_Package_Declaration, Stloc); -- 2.43.0