aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2021-08-17 23:12:00 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-10-04 08:45:04 +0000
commit2376b04d474656af0234bee68af144a7780253b6 (patch)
treeead2b748bc79b9e47425f4ccc915d85ae18eb8ed /gcc
parentd681ce903bffa9b5ac19fa7ffb721e55043a0fcc (diff)
downloadgcc-2376b04d474656af0234bee68af144a7780253b6.zip
gcc-2376b04d474656af0234bee68af144a7780253b6.tar.gz
gcc-2376b04d474656af0234bee68af144a7780253b6.tar.bz2
[Ada] Spurious accessibility error on renamed expression
gcc/ada/ * sem_util.adb (Accessibility_Level): Add a case to handle renamed subprograms in addition to renamed objects.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_util.adb18
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 70ab0d6..ba0341e 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -713,15 +713,25 @@ package body Sem_Util is
return Make_Level_Literal (Typ_Access_Level (E) + 1);
- -- Move up the renamed entity if it came from source since
- -- expansion may have created a dummy renaming under certain
- -- circumstances.
+ -- Move up the renamed entity or object if it came from source
+ -- since expansion may have created a dummy renaming under
+ -- certain circumstances.
+
+ -- Note: We check if the original node of the renaming comes
+ -- from source because the node may have been rewritten.
elsif Present (Renamed_Object (E))
- and then Comes_From_Source (Renamed_Object (E))
+ and then Comes_From_Source (Original_Node (Renamed_Object (E)))
then
return Accessibility_Level (Renamed_Object (E));
+ -- Move up renamed entities
+
+ elsif Present (Renamed_Entity (E))
+ and then Comes_From_Source (Original_Node (Renamed_Entity (E)))
+ then
+ return Accessibility_Level (Renamed_Entity (E));
+
-- Named access types get their level from their associated type
elsif Is_Named_Access_Type (Etype (E)) then