diff mbox series

[COMMITTED] ada: Fix missing associated node for packed array itypes

Message ID 20240506091803.1585287-1-poulhies@adacore.com
State New
Headers show
Series [COMMITTED] ada: Fix missing associated node for packed array itypes | expand

Commit Message

Marc Poulhiès May 6, 2024, 9:18 a.m. UTC
From: Piotr Trojanek <trojanek@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_pakd.adb |  4 ++++
 gcc/ada/exp_util.adb | 15 ++-------------
 2 files changed, 6 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb
index 628a3e38a78..3f26c3527fa 100644
--- a/gcc/ada/exp_pakd.adb
+++ b/gcc/ada/exp_pakd.adb
@@ -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
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 25190a65ebf..e7573277b61 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -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;