]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Clear confusion about subcomponents of atomic object
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 13 Dec 2019 09:05:18 +0000 (09:05 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Fri, 13 Dec 2019 09:05:18 +0000 (09:05 +0000)
2019-12-13  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_util.ads (Is_Atomic_Object): Mention relevant RM clauses.
* sem_util.adb (Is_Atomic_Object): For an indexed component,
only look at the Has_Atomic_Components aspect of the prefix and
do not recurse on it; for a selected component, do not look at
the prefix.
(Is_Atomic_Or_VFA_Object): Minor tweak.

From-SVN: r279363

gcc/ada/ChangeLog
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads

index 9f49f8674ae2d1610ea6f54f8965e903ac58ff95..a1f971ab748f45f6c4fee5b71aa80ab880e02ae5 100644 (file)
@@ -1,3 +1,12 @@
+2019-12-13  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * sem_util.ads (Is_Atomic_Object): Mention relevant RM clauses.
+       * sem_util.adb (Is_Atomic_Object): For an indexed component,
+       only look at the Has_Atomic_Components aspect of the prefix and
+       do not recurse on it; for a selected component, do not look at
+       the prefix.
+       (Is_Atomic_Or_VFA_Object): Minor tweak.
+
 2019-12-13  Arnaud Charlet  <charlet@adacore.com>
 
        * libgnat/a-calfor.ads, libgnat/a-calfor.adb (Split_Duration):
index e29360f576fbfa27673432c57d780f37960249a6..30a227307fe5b8a042caa71223367ce78006b7d5 100644 (file)
@@ -13724,54 +13724,33 @@ package body Sem_Util is
    ----------------------
 
    function Is_Atomic_Object (N : Node_Id) return Boolean is
-      function Is_Atomic_Entity (Id : Entity_Id) return Boolean;
-      pragma Inline (Is_Atomic_Entity);
-      --  Determine whether arbitrary entity Id is either atomic or has atomic
+      function Prefix_Has_Atomic_Components (Pref : Node_Id) return Boolean;
+      --  Determine whether prefix Pref of an indexed component has atomic
       --  components.
 
-      function Is_Atomic_Prefix (Pref : Node_Id) return Boolean;
-      --  Determine whether prefix Pref of an indexed or selected component is
-      --  an atomic object.
-
-      ----------------------
-      -- Is_Atomic_Entity --
-      ----------------------
-
-      function Is_Atomic_Entity (Id : Entity_Id) return Boolean is
-      begin
-         return Is_Atomic (Id) or else Has_Atomic_Components (Id);
-      end Is_Atomic_Entity;
-
-      ----------------------
-      -- Is_Atomic_Prefix --
-      ----------------------
+      ---------------------------------
+      -- Prefix_Has_Atomic_Components --
+      ---------------------------------
 
-      function Is_Atomic_Prefix (Pref : Node_Id) return Boolean is
+      function Prefix_Has_Atomic_Components (Pref : Node_Id) return Boolean is
          Typ : constant Entity_Id := Etype (Pref);
 
       begin
          if Is_Access_Type (Typ) then
             return Has_Atomic_Components (Designated_Type (Typ));
 
-         elsif Is_Atomic_Entity (Typ) then
+         elsif Has_Atomic_Components (Typ) then
             return True;
 
          elsif Is_Entity_Name (Pref)
-           and then Is_Atomic_Entity (Entity (Pref))
+           and then Has_Atomic_Components (Entity (Pref))
          then
             return True;
 
-         elsif Nkind (Pref) = N_Indexed_Component then
-            return Is_Atomic_Prefix (Prefix (Pref));
-
-         elsif Nkind (Pref) = N_Selected_Component then
-            return
-              Is_Atomic_Prefix (Prefix (Pref))
-                or else Is_Atomic (Entity (Selector_Name (Pref)));
+         else
+            return False;
          end if;
-
-         return False;
-      end Is_Atomic_Prefix;
+      end Prefix_Has_Atomic_Components;
 
    --  Start of processing for Is_Atomic_Object
 
@@ -13780,12 +13759,13 @@ package body Sem_Util is
          return Is_Atomic_Object_Entity (Entity (N));
 
       elsif Nkind (N) = N_Indexed_Component then
-         return Is_Atomic (Etype (N)) or else Is_Atomic_Prefix (Prefix (N));
+         return
+           Is_Atomic (Etype (N))
+             or else Prefix_Has_Atomic_Components (Prefix (N));
 
       elsif Nkind (N) = N_Selected_Component then
          return
            Is_Atomic (Etype (N))
-             or else Is_Atomic_Prefix (Prefix (N))
              or else Is_Atomic (Entity (Selector_Name (N)));
       end if;
 
@@ -13810,8 +13790,8 @@ package body Sem_Util is
    function Is_Atomic_Or_VFA_Object (N : Node_Id) return Boolean is
    begin
       return Is_Atomic_Object (N)
-        or else (Is_Object_Reference (N)
-                   and then Is_Entity_Name (N)
+        or else (Is_Entity_Name (N)
+                   and then Is_Object (Entity (N))
                    and then (Is_Volatile_Full_Access (Entity (N))
                                 or else
                              Is_Volatile_Full_Access (Etype (Entity (N)))));
index ea963deb44962f462f029f929901d38859303d06..c354d7e9072291c5a5dd46b937bd23db30a7ed35 100644 (file)
@@ -1531,7 +1531,7 @@ package Sem_Util is
 
    function Is_Atomic_Object (N : Node_Id) return Boolean;
    --  Determine whether arbitrary node N denotes a reference to an atomic
-   --  object as per Ada RM C.6(12).
+   --  object as per Ada RM C.6(7) and the crucial remark in C.6(8).
 
    --  WARNING: There is a matching C declaration of this subprogram in fe.h