From: squirek <squi...@adacore.com> 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 Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/accessibility.adb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb index a4129819109..376eb9d0bb9 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 -- 2.43.0