diff mbox

[Ada] Correct some anmolies in the handling of Atomic

Message ID 20150522085240.GA2760@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet May 22, 2015, 8:52 a.m. UTC
This update corrects two problems in the handling of Atomic.
First we do not need Atomic_Synchronization for an object
renaming declaration. Second, when we do have a renaming of
an atomic object, the renaming object should be marked as atomic.

Compiling this test:

     1. package Renamed_Atomic is
     2.
     3.   I : Integer;
     4.   pragma Atomic (I);
     5.
     6.   function Get_I return Integer;
     7.   procedure Set_I (Val : Integer);
     8.
     9.   J : Integer renames I;
    10.
    11.   function Get_J return Integer;
    12.   procedure Set_J (Val : Integer);
    13.
    14. end Renamed_Atomic;

We do not want Is_Atomic set on the identifier reference
in line 9, but we do want Is_Atomic set on the entity for J.

So if we use -gnatdt to generate a tree file, it should have
two Is_Atomic references, one for the entity I and one for the
entity J.

Tested on x86_64-pc-linux-gnu, committed on trunk

2015-05-21  Robert Dewar  <dewar@adacore.com>

	* exp_util.adb (Activate_Atomic_Synchronization): Do not set
	Atomic_Sync_Required for an object renaming declaration.
	* sem_ch8.adb (Analyze_Object_Renaming): Copy Is_Atomic and
	Is_Independent to renaming object.

Comments

Duncan Sands May 22, 2015, 11:16 a.m. UTC | #1
Hi Arnaud,

> Index: exp_util.adb
> ===================================================================
> --- exp_util.adb	(revision 223476)
> +++ exp_util.adb	(working copy)
> @@ -204,6 +204,13 @@
>           when others => null;
>        end case;
>
> +      --  Nothing to do for the identifier in an object renaming declaration,
> +      --  the renaming itself does not need atomic syncrhonization.

syncrhonization -> synchronization

Ciao, Duncan.
diff mbox

Patch

Index: exp_util.adb
===================================================================
--- exp_util.adb	(revision 223476)
+++ exp_util.adb	(working copy)
@@ -204,6 +204,13 @@ 
          when others => null;
       end case;
 
+      --  Nothing to do for the identifier in an object renaming declaration,
+      --  the renaming itself does not need atomic syncrhonization.
+
+      if Nkind (Parent (N)) = N_Object_Renaming_Declaration then
+         return;
+      end if;
+
       --  Go ahead and set the flag
 
       Set_Atomic_Sync_Required (N);
Index: sem_ch8.adb
===================================================================
--- sem_ch8.adb	(revision 223476)
+++ sem_ch8.adb	(working copy)
@@ -1344,6 +1344,13 @@ 
 
       Set_Is_Volatile (Id, Is_Volatile_Object (Nam));
 
+      --  Also copy settings of Is_Atomic and Is_Independent
+
+      if Is_Entity_Name (Nam) then
+         Set_Is_Atomic      (Id, Is_Atomic      (Entity (Nam)));
+         Set_Is_Independent (Id, Is_Independent (Entity (Nam)));
+      end if;
+
       --  Treat as volatile if we just set the Volatile flag
 
       if Is_Volatile (Id)