From: Piotr Trojanek Date: Thu, 16 Mar 2023 09:36:20 +0000 (+0100) Subject: ada: Simplify expansion of positional aggregates X-Git-Tag: basepoints/gcc-15~8878 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8c37d2bfde00ec3ac8083502dbbe04f0b213298;p=thirdparty%2Fgcc.git ada: Simplify expansion of positional aggregates Code cleanup; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Build_Constrained_Type): Use List_Length to count expressions in consecutive subaggregates. --- diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index bbc0f408abce..60449fbeb2d2 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -5837,7 +5837,6 @@ package body Exp_Aggr is procedure Build_Constrained_Type (Positional : Boolean) is Loc : constant Source_Ptr := Sloc (N); Agg_Type : constant Entity_Id := Make_Temporary (Loc, 'A'); - Comp : Node_Id; Decl : Node_Id; Typ : constant Entity_Id := Etype (N); Indexes : constant List_Id := New_List; @@ -5853,19 +5852,14 @@ package body Exp_Aggr is Sub_Agg := N; for D in 1 .. Number_Dimensions (Typ) loop - Sub_Agg := First (Expressions (Sub_Agg)); - - Comp := Sub_Agg; - Num := 0; - while Present (Comp) loop - Num := Num + 1; - Next (Comp); - end loop; + Num := List_Length (Expressions (Sub_Agg)); Append_To (Indexes, Make_Range (Loc, Low_Bound => Make_Integer_Literal (Loc, 1), High_Bound => Make_Integer_Literal (Loc, Num))); + + Sub_Agg := First (Expressions (Sub_Agg)); end loop; else