]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Set Ekind of components earlier
authorRonan Desplanques <desplanques@adacore.com>
Mon, 10 Mar 2025 09:37:11 +0000 (10:37 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 9 Jun 2025 06:32:11 +0000 (08:32 +0200)
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.

gcc/ada/sem.adb
gcc/ada/sem_ch3.adb

index f5ce9f2300e0b76ae8856f15474e36c612dd49d1..449fd8ad2c4c9fdebed6ac7a682acbf0d0518fad 100644 (file)
@@ -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
index 59f1dd2d8d3034a8c3def79357c3decf767f4e03..7cec589731fd35163b2d68ef88890d98f7c81a04 100644 (file)
@@ -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;