From: Piotr Trojanek Date: Fri, 29 May 2020 18:57:53 +0000 (+0200) Subject: [Ada] Cleanup condition for an effectively volatile array type X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=98e663f5979ad0686d7ed79a3c8ff7445f5fab18;p=gcc.git [Ada] Cleanup condition for an effectively volatile array type 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. --- diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 24053d54cc8..2895a9cbba5 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -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; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 782337346bb..ddd4d275ea1 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -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