From 0026dd0a639f02445d2019be7873a17313af0c16 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 12 Oct 2016 14:57:23 +0200 Subject: [PATCH] [multiple changes] 2016-10-12 Justin Squirek * sem_ch10.adb (Remove_Limited_With_Clause): Add a check to detect accidental visibility. 2016-10-12 Ed Schonberg * exp_ch4.adb (Expand_Allocator): If the expression is a qualified expression, add a predicate check after the constraint check. * sem_res.adb (Resolve_Qualified_Expression): If context is an allocator, do not apply predicate check, as it will be done when allocator is expanded. From-SVN: r241040 --- gcc/ada/ChangeLog | 13 +++++++++++++ gcc/ada/exp_ch4.adb | 9 +++++++-- gcc/ada/sem_ch10.adb | 7 +++++++ gcc/ada/sem_res.adb | 7 ++++++- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 101ea652c0c..33383e7b55e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,16 @@ +2016-10-12 Justin Squirek + + * sem_ch10.adb (Remove_Limited_With_Clause): Add a check to + detect accidental visibility. + +2016-10-12 Ed Schonberg + + * exp_ch4.adb (Expand_Allocator): If the expression is a qualified + expression, add a predicate check after the constraint check. + * sem_res.adb (Resolve_Qualified_Expression): If context is an + allocator, do not apply predicate check, as it will be done when + allocator is expanded. + 2016-10-12 Bob Duff * xref_lib.adb: Use renamings-of-slices to ensure diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index f6a5c2c9067..77b70127b50 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -4279,8 +4279,13 @@ package body Exp_Ch4 is -- in the aggregate might not match the subtype mark in the allocator. if Nkind (Expression (N)) = N_Qualified_Expression then - Apply_Constraint_Check - (Expression (Expression (N)), Etype (Expression (N))); + declare + Exp : constant Node_Id := Expression (Expression (N)); + Typ : constant Entity_Id := Etype (Expression (N)); + begin + Apply_Constraint_Check (Exp, Typ); + Apply_Predicate_Check (Exp, Typ); + end; Expand_Allocator_Expression (N); return; diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 86dbad06f52..115b2dd1e77 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -6377,6 +6377,13 @@ package body Sem_Ch10 is -- Limited_Withed_Unit. else + -- If the limited_with_clause is in some other unit in the context + -- then it is not visible in the main unit. + + if not In_Extended_Main_Source_Unit (N) then + Set_Is_Immediately_Visible (P, False); + end if; + -- Real entities that are type or subtype declarations were hidden -- from visibility at the point of installation of the limited-view. -- Now we recover the previous value of the hidden attribute. diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 47a67257051..86691d9e9a5 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -9495,7 +9495,12 @@ package body Sem_Res is then null; - elsif Nkind (N) = N_Qualified_Expression then + -- In the case of a qualified expression in an allocator, the check + -- is applied when expanding the allocator, so avoid redundant check. + + elsif Nkind (N) = N_Qualified_Expression + and then Nkind (Parent (N)) /= N_Allocator + then Apply_Predicate_Check (N, Target_Typ); end if; end if; -- 2.30.2