]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
exp_ch2.adb (Expand_Entity_Reference): Extend handling of atomic sync to type case.
authorRobert Dewar <dewar@adacore.com>
Fri, 4 Nov 2011 10:58:44 +0000 (10:58 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 4 Nov 2011 10:58:44 +0000 (11:58 +0100)
2011-11-04  Robert Dewar  <dewar@adacore.com>

* exp_ch2.adb (Expand_Entity_Reference): Extend handling of
atomic sync to type case.
* sem_prag.adb (Process_Suppress_Unsuppress): Atomic Sync can
apply to types.

From-SVN: r180938

gcc/ada/ChangeLog
gcc/ada/exp_ch2.adb
gcc/ada/sem_prag.adb

index 752037820fcfdbccfb0f745b58beb061775d6541..0d298e5bf3eba1bb3bdc26e058c358b580fed1d1 100644 (file)
@@ -1,3 +1,10 @@
+2011-11-04  Robert Dewar  <dewar@adacore.com>
+
+       * exp_ch2.adb (Expand_Entity_Reference): Extend handling of
+       atomic sync to type case.
+       * sem_prag.adb (Process_Suppress_Unsuppress): Atomic Sync can
+       apply to types.
+
 2011-11-04  Robert Dewar  <dewar@adacore.com>
 
        * sem_warn.adb (Warn_On_Useless_Assignment): More accurate test
index a71ce69602e2d947fc67015a53603eac7331d4c5..24f47a7775bfa48bbe0385368ff123c0fbb5d2f3 100644 (file)
@@ -401,7 +401,9 @@ package body Exp_Ch2 is
 
       --  Set Atomic_Sync_Required if necessary for atomic variable
 
-      if Is_Atomic (E) then
+      if Nkind_In (N, N_Identifier, N_Expanded_Name)
+        and then (Is_Atomic (E) or else Is_Atomic (Etype (E)))
+      then
          declare
             Set  : Boolean;
             MLoc : Node_Id;
@@ -417,10 +419,25 @@ package body Exp_Ch2 is
             elsif Debug_Flag_Dot_D then
                Set := False;
 
-            --  Otherwise setting comes from Atomic_Synchronization state
+            --  If variable is atomic, but type is not, setting depends on
+            --  disable/enable state for the variable.
 
-            else
+            elsif Is_Atomic (E) and then not Is_Atomic (Etype (E)) then
                Set := not Atomic_Synchronization_Disabled (E);
+
+            --  If variable is not atomic, but its type is atomic, setting
+            --  depends on disable/enable state for the type.
+
+            elsif not Is_Atomic (E) and then Is_Atomic (Etype (E)) then
+               Set := not Atomic_Synchronization_Disabled (Etype (E));
+
+            --  Else both variable and type are atomic (see outer if), and we
+            --  disable if either variable or its type have sync disabled.
+
+            else
+               Set := (not Atomic_Synchronization_Disabled (E))
+                        and then
+                      (not Atomic_Synchronization_Disabled (Etype (E)));
             end if;
 
             --  Set flag if required
index 70270aba26810022d11ef61e35d0f8b30f77eece..e1bf31be23a81eb45a14dc5142d1d7db08c1d161 100644 (file)
@@ -5465,7 +5465,7 @@ package body Sem_Prag is
               and then not Is_Atomic (E)
             then
                Error_Msg_N
-                 ("pragma & requires atomic variable",
+                 ("pragma & requires atomic type or variable",
                   Pragma_Identifier (Original_Node (N)));
             end if;