]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix missing associated node for packed array itypes
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 18 Dec 2023 13:31:52 +0000 (14:31 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 6 May 2024 09:11:26 +0000 (11:11 +0200)
After decoration, itypes should have its associated node set.

gcc/ada/

* exp_pakd.adb (Create_Packed_Array_Impl_Type): Set associated
node for the packed array itype.
* exp_util.adb (Possible_Side_Effect_In_SPARK): Remove
workaround for a missing associated node.

gcc/ada/exp_pakd.adb
gcc/ada/exp_util.adb

index 628a3e38a78a1743272d0a71af12ef1b06ce2346..3f26c3527fa4848ede3c41cdbacd347fb80e60b5 100644 (file)
@@ -541,8 +541,12 @@ package body Exp_Pakd is
 
          if Is_Itype (Typ) then
             Set_Parent (Decl, Associated_Node_For_Itype (Typ));
+            Set_Associated_Node_For_Itype
+              (PAT, Associated_Node_For_Itype (Typ));
          else
             Set_Parent (Decl, Declaration_Node (Typ));
+            Set_Associated_Node_For_Itype
+              (PAT, Declaration_Node (Typ));
          end if;
 
          if Scope (Typ) /= Current_Scope then
index 25190a65ebfe7231fd06054ffe1a93e8009c063f..e7573277b61edc85b2fcc13660c70bf53530d333 100644 (file)
@@ -11917,7 +11917,7 @@ package body Exp_Util is
 
                         --  When this routine is called while the itype
                         --  is being created, the entity might not yet be
-                        --  decorated with the associated node, but should
+                        --  decorated with the associated node, but will
                         --  have the related expression.
 
                         if Present (Associated_Node_For_Itype (Subt)) then
@@ -11925,21 +11925,10 @@ package body Exp_Util is
                              Possible_Side_Effect_In_SPARK
                                (Associated_Node_For_Itype (Subt));
 
-                        elsif Present (Related_Expression (Subt)) then
+                        else
                            return
                              Possible_Side_Effect_In_SPARK
                                (Related_Expression (Subt));
-
-                        --  When the itype doesn't have any indication of its
-                        --  origin (which currently only happens for packed
-                        --  array types created by freezing that shouldn't
-                        --  be picked by GNATprove anyway), then we can
-                        --  conservatively assume that the expression can
-                        --  be kept as it appears in the source code.
-
-                        else
-                           pragma Assert (Is_Packed_Array_Impl_Type (Subt));
-                           return False;
                         end if;
                      else
                         return True;