aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Moy <moy@adacore.com>2017-04-25 12:35:59 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2017-04-25 14:35:59 +0200
commite4b1cd76560d70923fbcbc52b2be32e4c760ba49 (patch)
treeb6a00fcba8163929715823be20e72f352d816975
parent245fee17cb416f3b5e09743a2dbee768ec8c8b16 (diff)
downloadgcc-e4b1cd76560d70923fbcbc52b2be32e4c760ba49.zip
gcc-e4b1cd76560d70923fbcbc52b2be32e4c760ba49.tar.gz
gcc-e4b1cd76560d70923fbcbc52b2be32e4c760ba49.tar.bz2
sem_util.adb: Minor refactoring.
2017-04-25 Yannick Moy <moy@adacore.com> * sem_util.adb: Minor refactoring. * freeze.adb (Freeze_Record_Type): Fix checking of SPARK RM 7.1.3(5). From-SVN: r247211
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/freeze.adb8
-rw-r--r--gcc/ada/sem_util.adb8
3 files changed, 16 insertions, 5 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index c13e016..8edaf57 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-25 Yannick Moy <moy@adacore.com>
+
+ * sem_util.adb: Minor refactoring.
+ * freeze.adb (Freeze_Record_Type): Fix checking of SPARK RM 7.1.3(5).
+
2017-04-25 Claire Dross <dross@adacore.com>
* sem_prag.adb (Collect_Inherited_Class_Wide_Conditions): Go to
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 523040e..7cfa295 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 1cae279..0c00fe2 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