https://gcc.gnu.org/g:025f6caa60394dce9dfefb49341e539bb656264b
commit r16-1333-g025f6caa60394dce9dfefb49341e539bb656264b Author: Ronan Desplanques <desplanq...@adacore.com> Date: Mon Mar 10 10:37:11 2025 +0100 ada: Set Ekind of components earlier Before this patch, the calls to set the proper Ekind of component entities were delayed in order to catch "premature usage" type of errors. This patch moves those calls to the natural place, at the beginning of Analyze_Component_Declaration, and makes premature usage error dectection use the newer Is_Self_Hidden mechanism. The motivation for this patch is to accomodate future removals of operations on E_Void entities. gcc/ada/ChangeLog: * sem.adb (Analyze): Adapt to new Ekinds. * sem_ch3.adb (Analyze_Component_Declaration): Set Ekind early. (Is_Visible_Component, Record_Type_Definition): Adjust. Diff: --- gcc/ada/sem.adb | 3 +-- gcc/ada/sem_ch3.adb | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index f5ce9f2300e0..449fd8ad2c4c 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -765,8 +765,7 @@ package body Sem is E : constant Entity_Id := Defining_Entity_Or_Empty (N); begin if Present (E) then - if Ekind (E) = E_Void - and then Nkind (N) = N_Component_Declaration + if Nkind (N) = N_Component_Declaration and then Present (Scope (E)) and then Ekind (Scope (E)) = E_Record_Type then diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 59f1dd2d8d30..7cec589731fd 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2046,6 +2046,7 @@ package body Sem_Ch3 is -- Start of processing for Analyze_Component_Declaration begin + Mutate_Ekind (Id, E_Component); Generate_Definition (Id); Enter_Name (Id); @@ -19833,7 +19834,9 @@ package body Sem_Ch3 is -- Start of processing for Is_Visible_Component begin - if Ekind (C) in E_Component | E_Discriminant then + if Ekind (C) in E_Component | E_Discriminant + and then Is_Not_Self_Hidden (C) + then Original_Comp := Original_Record_Component (C); end if; @@ -23123,10 +23126,8 @@ package body Sem_Ch3 is Component := First_Entity (Current_Scope); while Present (Component) loop - if Ekind (Component) = E_Void - and then not Is_Itype (Component) + if Ekind (Component) = E_Component and then not Is_Itype (Component) then - Mutate_Ekind (Component, E_Component); Reinit_Component_Location (Component); Set_Is_Not_Self_Hidden (Component); end if;