From: squirek Date: Thu, 24 Oct 2024 17:02:53 +0000 (+0000) Subject: ada: Crash on 'Access for Stream_Element_Array object X-Git-Tag: basepoints/gcc-16~4159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1850d0dbd32cf0b2cfa3225f0f8fbe1754b37393;p=thirdparty%2Fgcc.git ada: Crash on 'Access for Stream_Element_Array object This patch fixes a crash in the compiler when the actual for an anonymous access type formal is an 'Access of a Sream_Element_Array object during the calculation of said actual's accessibility level. gcc/ada/ChangeLog: * accessibility.adb (Accessibility_Level): Handle the Input attribute case --- diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb index a4129819109d..376eb9d0bb94 100644 --- a/gcc/ada/accessibility.adb +++ b/gcc/ada/accessibility.adb @@ -464,6 +464,23 @@ package body Accessibility is if Attribute_Name (E) = Name_Access then return Accessibility_Level (Prefix (E)); + -- If we have reached a 'Input attribute then this is the + -- the result of the expansion of an object declaration with + -- an initial value featuring it. Is this the only case ??? + + -- For example: + + -- Opaque : aliased Stream_Element_Array := + -- Stream_Element_Array'Input (S); + + elsif Attribute_Name (E) = Name_Input then + + -- Return the level of the enclosing declaration + + return Make_Level_Literal + (Innermost_Master_Scope_Depth + (Enclosing_Declaration (Expr))); + -- Unchecked or unrestricted attributes have unlimited depth elsif Attribute_Name (E) in Name_Address