aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2020-03-30 05:35:22 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-15 04:04:29 -0400
commitf142237e2f70fe336b4fbe02c8f10d60ab38df67 (patch)
tree1504eb4e3c41a601afe024e712d2d96b6edb9d5d
parent50188982c8770e4f54b2be84eedceff9757b9760 (diff)
downloadgcc-f142237e2f70fe336b4fbe02c8f10d60ab38df67.zip
gcc-f142237e2f70fe336b4fbe02c8f10d60ab38df67.tar.gz
gcc-f142237e2f70fe336b4fbe02c8f10d60ab38df67.tar.bz2
[Ada] Incorrect accessibility checks on functions calls
2020-06-15 Justin Squirek <squirek@adacore.com> gcc/ada/ * sem_res.adb (Valid_Conversion): Add missing condition to trigger proper static accessiblity failiures when the target type is an anonymous access.
-rw-r--r--gcc/ada/sem_res.adb11
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 89d7851..13d925c 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -13239,13 +13239,16 @@ package body Sem_Res is
-- Check if the operand is deeper than the target type, taking
-- care to avoid the case where we are converting a result of a
-- function returning an anonymous access type since the "master
- -- of the call" would be target type of the conversion in all
- -- cases - see RM 10.3/3.
+ -- of the call" would be target type of the conversion unless
+ -- the target type is anonymous access as well - see RM 3.10.2
+ -- (10.3/3).
elsif Type_Access_Level (Opnd_Type) >
Deepest_Type_Access_Level (Target_Type)
- and then not (Nkind (Associated_Node_For_Itype (Opnd_Type)) =
- N_Function_Specification)
+ and then (Nkind (Associated_Node_For_Itype (Opnd_Type)) /=
+ N_Function_Specification
+ or else Ekind (Target_Type) in
+ Anonymous_Access_Kind)
then
-- In an instance, this is a run-time check, but one we know
-- will fail, so generate an appropriate warning. The raise