]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Ensure Expression_Copy has a parent before analysis
authorViljar Indus <indus@adacore.com>
Mon, 30 Jun 2025 19:41:45 +0000 (22:41 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 22 Jul 2025 08:19:30 +0000 (10:19 +0200)
Some analysis requires going up the parent chain to get the
relevant context. Ensure that is done for the Expression_Copy
node which is not a syntactic node.

gcc/ada/ChangeLog:

* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations):
Ensure the Expression_Copy always has a parent before
calling any analyze.

gcc/ada/sem_ch13.adb

index 99acbf89e4eb4daed33edd2dca5afe5d6993f939..704bf3e0412719dc467e317f49a51490711115d8 100644 (file)
@@ -11241,6 +11241,13 @@ package body Sem_Ch13 is
    --  Start of processing for Check_Aspect_At_End_Of_Declarations
 
    begin
+      --  Indicate that the expression comes from an aspect specification,
+      --  which is used in subsequent analysis even if expansion is off.
+
+      if Present (End_Decl_Expr) then
+         Set_Parent (End_Decl_Expr, ASN);
+      end if;
+
       --  In an instance we do not perform the consistency check between freeze
       --  point and end of declarations, because it was done already in the
       --  analysis of the generic. Furthermore, the delayed analysis of an
@@ -11332,13 +11339,6 @@ package body Sem_Ch13 is
             end if;
          end if;
 
-         --  Indicate that the expression comes from an aspect specification,
-         --  which is used in subsequent analysis even if expansion is off.
-
-         if Present (End_Decl_Expr) then
-            Set_Parent (End_Decl_Expr, ASN);
-         end if;
-
          --  In a generic context the original aspect expressions have not
          --  been preanalyzed, so do it now. There are no conformance checks
          --  to perform in this case. As before, we have to make components