aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-01-10 23:36:02 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2018-01-10 23:36:02 +0000
commitaf95bb266a88d570db1b8bf5d57be430683bf1e9 (patch)
treee261143854165df2a889239587392c9a2348b4c9
parentbdd82c9b9975a8bca850b99cd5cee75e6ed3c127 (diff)
downloadgcc-af95bb266a88d570db1b8bf5d57be430683bf1e9.zip
gcc-af95bb266a88d570db1b8bf5d57be430683bf1e9.tar.gz
gcc-af95bb266a88d570db1b8bf5d57be430683bf1e9.tar.bz2
decl.c (gnat_to_gnu_component_type): Apply the check for atomic access once the component size is taken into account...
* 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. From-SVN: r256465
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/gcc-interface/decl.c6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/atomic10.adb25
4 files changed, 38 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 508b926..e1334f8 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+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-04 Eric Botcazou <ebotcazou@adacore.com>
* gnatvsn.ads: Bump copyright year.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index ab5fb0e..e8c48c7 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -5022,9 +5022,6 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition,
&& 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. */
gnu_comp_size
= validate_size (Component_Size (gnat_array), gnu_type, gnat_array,
@@ -5071,6 +5068,9 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition,
gnat_array);
}
+ 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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4ac9461..016f677 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-01-10 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/atomic10.adb: New test.
+
2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82367
diff --git a/gcc/testsuite/gnat.dg/atomic10.adb b/gcc/testsuite/gnat.dg/atomic10.adb
new file mode 100644
index 0000000..5f99ca6
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/atomic10.adb
@@ -0,0 +1,25 @@
+-- { dg-do compile }
+-- { dg-options "-gnatws" }
+
+with System.Multiprocessors;
+
+procedure Atomic10 is
+
+ type Atomic_Unsigned is mod 2 ** 32;
+ pragma Atomic (Atomic_Unsigned);
+
+ Max : Positive := Positive (System.Multiprocessors.Number_Of_CPUs);
+
+ Comp_Size : constant := 64 * 8;
+
+ subtype Index_Type is Positive range 1 .. Max;
+
+ type Array_Type is array (Index_Type) of aliased Atomic_Unsigned; -- { dg-error "cannot be guaranteed" }
+ for Array_Type'Component_Size use Comp_Size;
+
+ Slots : Array_Type;
+begin
+ for Index in Index_Type loop
+ Slots (Index) := 0;
+ end loop;
+end;