[Ada] Cleanup condition for an effectively volatile array type
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 29 May 2020 18:57:53 +0000 (20:57 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 15 Jul 2020 13:42:41 +0000 (09:42 -0400)
gcc/ada/

* sem_prag.adb (Atomic_Components): Simplify with Ekind_In.
(Complex_Representation): Fix type of E_Id, which just like when
for pragma Atomic_Components will hold an N_Identifier node, not
an entity.
* sem_util.adb (Is_Effectively_Volatile): Refactor to avoid
unnecessary computation.

gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb

index 24053d5..2895a9c 100644 (file)
@@ -13626,9 +13626,7 @@ package body Sem_Prag is
             if (Nkind (D) = N_Full_Type_Declaration and then Is_Array_Type (E))
               or else
                 (Nkind (D) = N_Object_Declaration
-                   and then (Ekind (E) = E_Constant
-                              or else
-                             Ekind (E) = E_Variable)
+                   and then Ekind_In (E, E_Constant, E_Variable)
                    and then Nkind (Object_Definition (D)) =
                                        N_Constrained_Array_Definition)
               or else
@@ -14258,7 +14256,7 @@ package body Sem_Prag is
          --  pragma Complex_Representation ([Entity =>] LOCAL_NAME);
 
          when Pragma_Complex_Representation => Complex_Representation : declare
-            E_Id : Entity_Id;
+            E_Id : Node_Id;
             E    : Entity_Id;
             Ent  : Entity_Id;
 
index 7823373..ddd4d27 100644 (file)
@@ -15615,22 +15615,24 @@ package body Sem_Util is
          --  effectively volatile.
 
          elsif Is_Array_Type (Id) then
-            declare
-               Anc : Entity_Id := Base_Type (Id);
-            begin
-               if Is_Private_Type (Anc) then
-                  Anc := Full_View (Anc);
-               end if;
+            if Has_Volatile_Components (Id) then
+               return True;
+            else
+               declare
+                  Anc : Entity_Id := Base_Type (Id);
+               begin
+                  if Is_Private_Type (Anc) then
+                     Anc := Full_View (Anc);
+                  end if;
 
-               --  Test for presence of ancestor, as the full view of a private
-               --  type may be missing in case of error.
+                  --  Test for presence of ancestor, as the full view of a
+                  --  private type may be missing in case of error.
 
-               return
-                 Has_Volatile_Components (Id)
-                   or else
-                 (Present (Anc)
-                   and then Is_Effectively_Volatile (Component_Type (Anc)));
-            end;
+                  return
+                    Present (Anc)
+                      and then Is_Effectively_Volatile (Component_Type (Anc));
+               end;
+            end if;
 
          --  A protected type is always volatile