]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ada: Fix visibility issue for child unit declared as instance on homonym
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 28 Oct 2025 22:04:49 +0000 (23:04 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 28 Oct 2025 22:05:51 +0000 (23:05 +0100)
The reproducer is made up of 9 units containing multiple level of nested
instances, but in the end the problem is that the final child unit has
the same name as the parameter in its instantiation, exposing the wrong
manipulation of the homonym chain done in Analyze_Subprogram_Instantiation.

The fix is to replace this manipulation with a call to Remove_Homonym.

gcc/ada/
PR ada/48039
* sem_ch12.adb (Analyze_Subprogram_Instantiation): Call
Remove_Homonym to remove the enclosing package from visibility.

gcc/ada/sem_ch12.adb

index b5c276a04bd9c2642d7d3ff060f7ec30fe03673d..cbb0debbf1fb1fbafec37789955f596bfff680c8 100644 (file)
@@ -6735,7 +6735,7 @@ package body Sem_Ch12 is
             --  Remove package itself from visibility, so it does not
             --  conflict with subprogram.
 
-            Set_Name_Entity_Id (Chars (Pack_Id), Homonym (Pack_Id));
+            Remove_Homonym (Pack_Id);
 
             --  Set name and scope of internal subprogram so that the proper
             --  external name will be generated. The proper scope is the scope