From: Justin Squirek Date: Wed, 18 Aug 2021 03:12:00 +0000 (-0400) Subject: [Ada] Spurious accessibility error on renamed expression X-Git-Tag: basepoints/gcc-13~4201 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2376b04d474656af0234bee68af144a7780253b6;p=thirdparty%2Fgcc.git [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. --- diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 70ab0d6d91da..ba0341e70c71 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