OSDN Git Service

* gcc-interface/decl.c (gnat_to_gnu_field): Always check components
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 Oct 2011 20:32:17 +0000 (20:32 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 Oct 2011 20:32:17 +0000 (20:32 +0000)
declared as atomic.  Move around conditionally executed code.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180539 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/atomic1.ads [new file with mode: 0644]

index 695e385..3bd55bf 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_field): Always check components
+       declared as atomic.  Move around conditionally executed code.
+
 2011-10-24  Robert Dewar  <dewar@adacore.com>
 
        * sem.adb (Initialize): Fix bug that blew up if called a second
index 71a4639..d6bfe9c 100644 (file)
@@ -6853,10 +6853,8 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
        }
     }
 
-  /* If we are packing the record and the field is BLKmode, round the
-     size up to a byte boundary.  */
-  if (packed && TYPE_MODE (gnu_field_type) == BLKmode && gnu_size)
-    gnu_size = round_up (gnu_size, BITS_PER_UNIT);
+  if (Is_Atomic (gnat_field))
+    check_ok_for_atomic (gnu_field_type, gnat_field, false);
 
   if (Present (Component_Clause (gnat_field)))
     {
@@ -6946,9 +6944,6 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
              gnu_pos = NULL_TREE;
            }
        }
-
-      if (Is_Atomic (gnat_field))
-       check_ok_for_atomic (gnu_field_type, gnat_field, false);
     }
 
   /* If the record has rep clauses and this is the tag field, make a rep
@@ -6961,7 +6956,14 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
     }
 
   else
-    gnu_pos = NULL_TREE;
+    {
+      gnu_pos = NULL_TREE;
+
+      /* If we are packing the record and the field is BLKmode, round the
+        size up to a byte boundary.  */
+      if (packed && TYPE_MODE (gnu_field_type) == BLKmode && gnu_size)
+       gnu_size = round_up (gnu_size, BITS_PER_UNIT);
+    }
 
   /* We need to make the size the maximum for the type if it is
      self-referential and an unconstrained type.  In that case, we can't
index e702ae9..89819e6 100644 (file)
@@ -1,3 +1,7 @@
+2011-10-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/atomic1.ads: New test.
+
 2011-10-26  Ed Smith-Rowland  <3dw4rd@verizon.net>
 
        Implement C++11 user-defined literals.
diff --git a/gcc/testsuite/gnat.dg/specs/atomic1.ads b/gcc/testsuite/gnat.dg/specs/atomic1.ads
new file mode 100644 (file)
index 0000000..500cad7
--- /dev/null
@@ -0,0 +1,16 @@
+-- { dg-do compile }
+
+package Atomic1 is
+
+  type Arr is array (Integer range <>) of Boolean;
+  type UA is access all Arr;
+
+  U : UA;
+  pragma Atomic (U);  -- { dg-error "atomic access" }
+
+  type R is record
+    U : UA;
+    pragma Atomic (U);  -- { dg-error "atomic access" }
+  end record;
+
+end Atomic1;