[COMMITTED,27/35] ada: Fix internal error on bit-packed array type with Volatile_Full_Access

Message ID 20241025091107.485741-27-poulhies@adacore.com
State Committed
Commit de8d6829371821775183fbf5633cc1e654d96b78
Headers
Series [COMMITTED,01/35] ada: Pass parameters of full access unconstrained array types by copy in calls |

Commit Message

Marc Poulhiès Oct. 25, 2024, 9:10 a.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

The problem occurs when the component type is a record type with default
values for the initialization procedure of the (base) array type, because
the compiler is trying to generate a full access for a parameter of the
base array type, which does not make sense.

gcc/ada/ChangeLog:

	PR ada/116551
	* gcc-interface/trans.cc (node_is_atomic) <N_Identifier>: Return
	false if the type of the entity is an unconstrained array type.
	(node_is_volatile_full_access) <N_Identifier>: Likewise.

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

---
 gcc/ada/gcc-interface/trans.cc | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 7728e60ccb6..93f67404ddb 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -4263,7 +4263,10 @@  node_is_atomic (Node_Id gnat_node)
       if (!Is_Object (gnat_entity))
 	break;
       return Is_Atomic (gnat_entity)
+	     /* Disregard the flag on unconstrained arrays or simple constants
+		since we cannot or need not generate an atomic access.  */
 	     || (Is_Atomic (Etype (gnat_entity))
+		 && Ekind (Etype (gnat_entity)) != E_Array_Type
 		 && !simple_constant_p (gnat_entity));
 
     case N_Selected_Component:
@@ -4303,7 +4306,10 @@  node_is_volatile_full_access (Node_Id gnat_node)
       if (!Is_Object (gnat_entity))
 	break;
       return Is_Volatile_Full_Access (gnat_entity)
+	     /* Disregard the flag on unconstrained arrays or simple constants
+		since we cannot or need not generate a full access.  */
 	     || (Is_Volatile_Full_Access (Etype (gnat_entity))
+		 && Ekind (Etype (gnat_entity)) != E_Array_Type
 		 && !simple_constant_p (gnat_entity));
 
     case N_Selected_Component: