diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2023-03-17 14:10:03 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-26 09:29:17 +0200 |
commit | 10bb8c4ea8a1b6c7056d3a36a69702588412b0c5 (patch) | |
tree | 287d88b0884741821fa16ca1eea2523ee5e0d422 /gcc/ada/sem_ch3.adb | |
parent | 16c320507774ca38e0eb3d1c4116c9dcb3f2e598 (diff) | |
download | gcc-10bb8c4ea8a1b6c7056d3a36a69702588412b0c5.zip gcc-10bb8c4ea8a1b6c7056d3a36a69702588412b0c5.tar.gz gcc-10bb8c4ea8a1b6c7056d3a36a69702588412b0c5.tar.bz2 |
ada: Cleanups in handling of aggregates
Assorted cleanups related to recent fixes of aggregate handling for
GNATprove; semantics is unaffected.
gcc/ada/
* sem_aggr.adb
(Resolve_Record_Aggregate): Remove useless assignment.
* sem_aux.adb
(Has_Variant_Part): Remove useless guard; this routine is only called
on type entities (and now will crash in other cases).
* sem_ch3.adb
(Create_Constrained_Components): Only assign Assoc_List when necessary;
tune whitespace.
(Is_Variant_Record): Refactor repeated calls to Parent.
* sem_util.adb
(Gather_Components): Assert that discriminant association has just one
choice in component_association; refactor repeated calls to Next.
* sem_util.ads
(Gather_Components): Tune whitespace in comment.
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r-- | gcc/ada/sem_ch3.adb | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index fb4f5ba..ff52e05 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -15161,8 +15161,8 @@ package body Sem_Ch3 is Loc : constant Source_Ptr := Sloc (Subt); Comp_List : constant Elist_Id := New_Elmt_List; Parent_Type : constant Entity_Id := Etype (Typ); - Assoc_List : constant List_Id := New_List; + Assoc_List : List_Id; Discr_Val : Elmt_Id; Errors : Boolean; New_C : Entity_Id; @@ -15191,8 +15191,10 @@ package body Sem_Ch3 is procedure Collect_Fixed_Components (Typ : Entity_Id) is begin - -- Build association list for discriminants, and find components of the - -- variant part selected by the values of the discriminants. + -- Build association list for discriminants, and find components of + -- the variant part selected by the values of the discriminants. + + Assoc_List := New_List; Old_C := First_Discriminant (Typ); Discr_Val := First_Elmt (Constraints); @@ -15293,13 +15295,13 @@ package body Sem_Ch3 is ----------------------- function Is_Variant_Record (T : Entity_Id) return Boolean is + Decl : constant Node_Id := Parent (T); begin - return Nkind (Parent (T)) = N_Full_Type_Declaration - and then Nkind (Type_Definition (Parent (T))) = N_Record_Definition - and then Present (Component_List (Type_Definition (Parent (T)))) + return Nkind (Decl) = N_Full_Type_Declaration + and then Nkind (Type_Definition (Decl)) = N_Record_Definition + and then Present (Component_List (Type_Definition (Decl))) and then - Present - (Variant_Part (Component_List (Type_Definition (Parent (T))))); + Present (Variant_Part (Component_List (Type_Definition (Decl)))); end Is_Variant_Record; -- Start of processing for Create_Constrained_Components @@ -15427,10 +15429,10 @@ package body Sem_Ch3 is Gather_Components (Typ, Component_List (Type_Definition (Parent (Typ))), - Governed_By => Assoc_List, - Into => Comp_List, - Report_Errors => Errors, - Allow_Compile_Time => True); + Governed_By => Assoc_List, + Into => Comp_List, + Report_Errors => Errors, + Allow_Compile_Time => True); pragma Assert (not Errors or else Serious_Errors_Detected > 0); Create_All_Components; @@ -15450,10 +15452,10 @@ package body Sem_Ch3 is Gather_Components (Typ, Component_List (Type_Definition (Parent (Parent_Type))), - Governed_By => Assoc_List, - Into => Comp_List, - Report_Errors => Errors, - Allow_Compile_Time => True); + Governed_By => Assoc_List, + Into => Comp_List, + Report_Errors => Errors, + Allow_Compile_Time => True); -- Note: previously there was a check at this point that no errors -- were detected. As a consequence of AI05-220 there may be an error |