Compiler rejects a use of a name in a subprogram body that appears in a
with_clause, when the name is that of an inherited function for a local
derived type, and is hidden by an explicit declaration of a
non-overloadable homonym, and other homonyms exist in the environment of
the subprogram body.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * sem_util.adb (Enter_Name): When an inherited operation for a
        local derived type is hidden by an explicit declaration of a
        non-overloadable entity in the same scope, make the inherited
        operation non-visible to prevent its accidental use elsewhere.
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
@@ -8288,6 +8288,13 @@ package body Sem_Util is
                   else
                      Set_Name_Entity_Id (Chars (E), Homonym (E));
                   end if;
+
+                  --  The inherited operation cannot be retrieved
+                  --  by name, even though it may remain accesssible
+                  --  in some cases involving subprogram bodies without
+                  --  specs appearing in with_clauses..
+
+                  Set_Is_Immediately_Visible (E, False);
                end if;
             end;
 


Reply via email to