]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Simplify handling of selected components as name references
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 7 Mar 2025 11:08:44 +0000 (12:08 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 9 Jun 2025 06:32:10 +0000 (08:32 +0200)
The selector_name of a selected_component always points to an identifier than
is an object name, i.e. specifically, name of a component or discriminant.
There is no need to examine this.

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* sem_util.adb (Is_Name_Reference): Remove check for selector_name of a
selected_component; reuse existing code for indexed components and
slices.
(Statically_Names_Object): Remove dead code.

gcc/ada/sem_util.adb

index 2b7296b67e8c05f7d0384b50a18a74b006aab1d7..3c80d236af81cff1f025b7b2973a73819b0b8899 100644 (file)
@@ -18375,6 +18375,7 @@ package body Sem_Util is
 
       case Nkind (N) is
          when N_Indexed_Component
+            | N_Selected_Component
             | N_Slice
          =>
             return
@@ -18386,13 +18387,6 @@ package body Sem_Util is
          when N_Attribute_Reference =>
             return Attribute_Name (N) in Name_Input | Name_Old | Name_Result;
 
-         when N_Selected_Component =>
-            return
-              Is_Name_Reference (Selector_Name (N))
-                and then
-                  (Is_Name_Reference (Prefix (N))
-                    or else Is_Access_Type (Etype (Prefix (N))));
-
          when N_Explicit_Dereference =>
             return True;
 
@@ -28517,12 +28511,6 @@ package body Sem_Util is
                return False;
             end if;
 
-            if Ekind (Entity (Selector_Name (N))) not in
-                 E_Component | E_Discriminant
-            then
-               return False;
-            end if;
-
             declare
                Comp : constant Entity_Id :=
                  Original_Record_Component (Entity (Selector_Name (N)));