* [Ada] Crash on allocator in alternative accessibility modes
@ 2021-10-04 8:47 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-04 8:47 UTC (permalink / raw)
To: gcc-patches; +Cc: Justin Squirek
[-- Attachment #1: Type: text/plain, Size: 343 bytes --]
This patch corrects an issue in the compiler whereby the level for
allocated objects of anonymous access types was calculated incorrectly.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_util.adb (Function_Or_Allocator_Level): Properly handle
direct function calls in the default alternative accessibility
checking mode.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1772 bytes --]
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -391,8 +391,7 @@ package body Sem_Util is
and then (Is_Static_Coextension (N)
or else Is_Dynamic_Coextension (N))
then
- return Make_Level_Literal
- (Scope_Depth (Standard_Standard));
+ return Make_Level_Literal (Scope_Depth (Standard_Standard));
end if;
-- Named access types have a designated level
@@ -416,9 +415,14 @@ package body Sem_Util is
if Debug_Flag_Underscore_B then
return Make_Level_Literal (Typ_Access_Level (Etype (N)));
- -- Otherwise the level is that of the subprogram
+ -- For function calls the level is that of the subprogram,
+ -- otherwise (for allocators etc.) we get the level of the
+ -- corresponding anonymous access type which is calculated
+ -- through the normal path of execution.
- else
+ elsif Nkind (N) = N_Function_Call
+ and then Nkind (Name (N)) /= N_Explicit_Dereference
+ then
return Make_Level_Literal
(Subprogram_Access_Level (Entity (Name (N))));
end if;
@@ -29287,7 +29291,7 @@ package body Sem_Util is
(Designated_Type (Btyp), Allow_Alt_Model);
end if;
- -- When an anonymous access type's Assoc_Ent is specifiedi,
+ -- When an anonymous access type's Assoc_Ent is specified,
-- calculate the result based on the general accessibility
-- level routine.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-04 8:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 8:47 [Ada] Crash on allocator in alternative accessibility modes Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).