diff mbox series

[COMMITTED,06/16] ada: Crash checking accessibility level on private type

Message ID 20240614073633.2089692-6-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/16] ada: Remove unused name of aspect from Snames | expand

Commit Message

Marc Poulhiès June 14, 2024, 7:36 a.m. UTC
From: Justin Squirek <squirek@adacore.com>

This patch fixes an issue in the compiler whereby calculating a static
accessibility level on a private type with an access discriminant resulted
in a compile time crash when No_Dynamic_Accessibility_Checks is enabled.

gcc/ada/

	* accessibility.adb:
	(Accessibility_Level): Replace call Get_Full_View with call to
	Full_View since Get_Full_View only works with incomplete types.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/accessibility.adb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb
index 47b3a7af10a..da4d1d9ce2e 100644
--- a/gcc/ada/accessibility.adb
+++ b/gcc/ada/accessibility.adb
@@ -2227,7 +2227,11 @@  package body Accessibility is
                   --  that of the type.
 
                   elsif Ekind (Def_Ent) = E_Discriminant then
-                     return Scope_Depth (Get_Full_View (Scope (Def_Ent)));
+                     return Scope_Depth
+                       (if Present (Full_View (Scope (Def_Ent))) then
+                           Full_View (Scope (Def_Ent))
+                        else
+                           Scope (Def_Ent));
                   end if;
                end if;