diff mbox

[Ada] Fix error message printed for invalid access to atomic component

Message ID 20120612090306.GA1624@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 12, 2012, 9:03 a.m. UTC
This changes the error message printed for an invalid access to an atomic
component, which was:
  access to volatile object cannot yield access-to-non-volatile type
into the more correct:
  access to atomic object cannot yield access-to-non-atomic type
The problem was that Is_Atomic_Object returned false for such a component.

The following testcase should generate the new error message:

procedure Atomic_Test is

   type X32 is mod 2 ** 32;

   type Rec is record
      B : aliased X32;
      pragma Atomic (B);
   end record;

   procedure Test (X : access X32) is null;

   Object : Rec;
begin
   Test (Object.B'Access);
end Atomic_Test;

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

2012-06-12  Eric Botcazou  <ebotcazou@adacore.com>

	* sem_util.adb (Is_Atomic_Object): Return true for an atomic
	component as well as a prefix which is an atomic component.
diff mbox

Patch

Index: sem_util.adb
===================================================================
--- sem_util.adb	(revision 188428)
+++ sem_util.adb	(working copy)
@@ -6749,6 +6749,11 @@ 
          then
             return True;
 
+         elsif Nkind (N) = N_Selected_Component
+           and then Is_Atomic (Entity (Selector_Name (N)))
+         then
+            return True;
+
          elsif Nkind (N) = N_Indexed_Component
            or else Nkind (N) = N_Selected_Component
          then
@@ -6772,6 +6777,11 @@ 
       then
          return True;
 
+      elsif Nkind (N) = N_Selected_Component
+        and then Is_Atomic (Entity (Selector_Name (N)))
+      then
+         return True;
+
       elsif Nkind (N) = N_Indexed_Component
         or else Nkind (N) = N_Selected_Component
       then