[Ada] Fix ICE on Component_Size clause with atomic type

Message ID 1735400.qtVBFoXyZB@polaris
State New
Headers show
  • [Ada] Fix ICE on Component_Size clause with atomic type
Related show

Commit Message

Eric Botcazou Jan. 10, 2018, 11:36 p.m.
The compiler aborts on the assignment to an array component if the component 
type is an atomic type and the array is subject to a Component_Size clause 
that is too large for atomic access on the target.  A proper error message 
must be issued instead.

Tested on x86-64/Linux, applied on the mainline.

2018-01-10  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/decl.c (gnat_to_gnu_component_type): Apply the check
	for atomic access once the component size is taken into account and
	also do it if the component type is Atomic or Volatile_Full_Access.

2018-01-10  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/atomic10.adb: New test.

Eric Botcazou


Index: gcc-interface/decl.c
--- gcc-interface/decl.c	(revision 256275)
+++ gcc-interface/decl.c	(working copy)
@@ -5022,9 +5022,6 @@  gnat_to_gnu_component_type (Entity_Id gn
       && tree_fits_uhwi_p (TYPE_SIZE (gnu_type)))
     gnu_type = make_packable_type (gnu_type, false, max_align);
-  if (Has_Atomic_Components (gnat_array))
-    check_ok_for_atomic_type (gnu_type, gnat_array, true);
   /* Get and validate any specified Component_Size.  */
     = validate_size (Component_Size (gnat_array), gnu_type, gnat_array,
@@ -5071,6 +5068,9 @@  gnat_to_gnu_component_type (Entity_Id gn
+  if (Has_Atomic_Components (gnat_array) || Is_Atomic_Or_VFA (gnat_type))
+    check_ok_for_atomic_type (gnu_type, gnat_array, true);
   /* If the component type is a padded type made for a non-bit-packed array
      of scalars with reverse storage order, we need to propagate the reverse
      storage order to the padding type since it is the innermost enclosing