[Ada] Fix spurious error on instantiation with Text_IO name
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 7 Dec 2021 21:10:53 +0000 (22:10 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 6 Jan 2022 17:11:36 +0000 (17:11 +0000)
gcc/ada/

* sem_ch8.adb (Analyze_Package_Renaming): Do not check for Text_IO
special units when the name of the renaming is a generic instance,
which is the case for package instantiations in the GNAT model.

gcc/ada/sem_ch8.adb

index 8ee3496..a70077a 100644 (file)
@@ -1594,9 +1594,18 @@ package body Sem_Ch8 is
          return;
       end if;
 
-      --  Check for Text_IO special unit (we may be renaming a Text_IO child)
+      --  Check for Text_IO special units (we may be renaming a Text_IO child),
+      --  but make sure not to catch renamings generated for package instances
+      --  that have nothing to do with them but are nevertheless homonyms.
 
-      Check_Text_IO_Special_Unit (Name (N));
+      if Is_Entity_Name (Name (N))
+        and then Present (Entity (Name (N)))
+        and then Is_Generic_Instance (Entity (Name (N)))
+      then
+         null;
+      else
+         Check_Text_IO_Special_Unit (Name (N));
+      end if;
 
       if Current_Scope /= Standard_Standard then
          Set_Is_Pure (New_P, Is_Pure (Current_Scope));