Comments
Patch
===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -2665,7 +2665,10 @@
if not Is_Actual
and then (Old_S = New_S
or else (Nkind (Nam) /= N_Expanded_Name
- and then Chars (Old_S) = Chars (New_S)))
+ and then Chars (Old_S) = Chars (New_S))
+ or else (Nkind (Nam) = N_Expanded_Name
+ and then Entity (Prefix (Nam)) = Current_Scope
+ and then Chars (Selector_Name (Nam)) = Chars (New_S)))
then
Error_Msg_N ("subprogram cannot rename itself", N);
end if;
The compiler does not report an error on the self renaming of a subprogram declaration when the renamed subprogram is referenced through its expanded name. After this patch the following test is rejected by the compiler: package Renamings1 is type T1 is tagged null record; function "=" (left, right : in T1) return Boolean renames Renamings1."="; end Renamings1; $ gcc -c renamings1.ads renamings1.ads:5:06: subprogram cannot rename itself Tested on x86_64-pc-linux-gnu, committed on trunk 2012-01-30 Javier Miranda <miranda@adacore.com> PR ada/15846 * sem_ch8.adb (Analyze_Subprogram_Renaming): Handle self-renaming when the renamed entity is referenced using its expanded name.