From: Yannick Moy Date: Tue, 25 Apr 2017 12:35:59 +0000 (+0000) Subject: sem_util.adb: Minor refactoring. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4b1cd76560d70923fbcbc52b2be32e4c760ba49;p=gcc.git sem_util.adb: Minor refactoring. 2017-04-25 Yannick Moy * sem_util.adb: Minor refactoring. * freeze.adb (Freeze_Record_Type): Fix checking of SPARK RM 7.1.3(5). From-SVN: r247211 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c13e016c551..8edaf572cc3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2017-04-25 Yannick Moy + + * sem_util.adb: Minor refactoring. + * freeze.adb (Freeze_Record_Type): Fix checking of SPARK RM 7.1.3(5). + 2017-04-25 Claire Dross * sem_prag.adb (Collect_Inherited_Class_Wide_Conditions): Go to diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 523040e0170..7cfa2955d8e 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -4625,9 +4625,11 @@ package body Freeze is if Is_Effectively_Volatile (Rec) then -- A discriminated type cannot be effectively volatile - -- (SPARK RM C.6(4)). + -- (SPARK RM 7.1.3(5)). - if Has_Discriminants (Rec) then + if Has_Discriminants (Rec) + and then not Is_Protected_Type (Rec) + then Error_Msg_N ("discriminated type & cannot be volatile", Rec); -- A tagged type cannot be effectively volatile @@ -4638,7 +4640,7 @@ package body Freeze is end if; -- A non-effectively volatile record type cannot contain - -- effectively volatile components (SPARK RM C.6(2)). + -- effectively volatile components (SPARK RM 7.1.3(6)). else Comp := First_Component (Rec); diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 1cae279da0b..0c00fe25f5c 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -12808,14 +12808,18 @@ package body Sem_Util is declare Anc : Entity_Id := Base_Type (Id); begin - if Ekind (Anc) in Private_Kind then + 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. + return Has_Volatile_Components (Id) or else - Is_Effectively_Volatile (Component_Type (Anc)); + (Present (Anc) + and then Is_Effectively_Volatile (Component_Type (Anc))); end; -- A protected type is always volatile