From: Ronan Desplanques Date: Fri, 28 Mar 2025 11:37:50 +0000 (+0100) Subject: ada: Remove creation of some unused itypes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df186850f2868f6e78509f25d01bdbf2c3f342fe;p=thirdparty%2Fgcc.git ada: Remove creation of some unused itypes Before this patch, Constrain_Index always started by creating an itype but then sometimes not using it for anything. This patch makes it so an itype is only created when needed. gcc/ada/ChangeLog: * sem_ch3.adb (Constrain_Index): Avoid unused itypes. --- diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index a5df3f89dac..23d67eaecc0 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -15215,17 +15215,21 @@ package body Sem_Ch3 is R : Node_Id := Empty; T : constant Entity_Id := Etype (Index); Is_FLB_Index : Boolean := False; + Is_Range : constant Boolean := + Nkind (S) = N_Range + or else (Nkind (S) = N_Attribute_Reference + and then Attribute_Name (S) = Name_Range); + Is_Indic : constant Boolean := Nkind (S) = N_Subtype_Indication; begin - Def_Id := - Create_Itype (E_Void, Related_Nod, Related_Id, Suffix, Suffix_Index); - Set_Etype (Def_Id, Base_Type (T)); + if Is_Range or else Is_Indic then + Def_Id := + Create_Itype + (E_Void, Related_Nod, Related_Id, Suffix, Suffix_Index); + Set_Etype (Def_Id, Base_Type (T)); + end if; - if Nkind (S) = N_Range - or else - (Nkind (S) = N_Attribute_Reference - and then Attribute_Name (S) = Name_Range) - then + if Is_Range then -- A Range attribute will be transformed into N_Range by Resolve -- If a range has an Empty upper bound, then remember that for later @@ -15260,7 +15264,7 @@ package body Sem_Ch3 is end if; end if; - elsif Nkind (S) = N_Subtype_Indication then + elsif Is_Indic then -- The parser has verified that this is a discrete indication