The language says that the profile of a subprogram renaming-as-declaration
must be mode conformant with that of the renamed subprogram, and that the
parameter subtypes are taken from the renamed subprogram.
GNAT implements the rule, except when Natural and Positive are involved,
which may lead to the wrong conclusion that it does not.
gcc/ada/
PR ada/119643
* sem_ch8.adb (Inherit_Renamed_Profile): Add guard against the
peculiarities of Natural and Positive.
gcc/testsuite/
* gnat.dg/renaming17.adb: New test.
-- If the new type is a renaming of the old one, as is the case
-- for actuals in instances, retain its name, to simplify later
- -- disambiguation.
+ -- disambiguation. Beware of Natural and Positive, see Cstand.
if Nkind (Parent (New_T)) = N_Subtype_Declaration
and then Is_Entity_Name (Subtype_Indication (Parent (New_T)))
and then Entity (Subtype_Indication (Parent (New_T))) = Old_T
+ and then Scope (New_T) /= Standard_Standard
then
null;
else
--- /dev/null
+-- { dg-do run }
+
+procedure Renaming17 is
+
+ function Incr (V : Integer; I : Integer := 1) return Integer is
+ (V + I);
+
+ function Incr_Ren (V : Integer; I : Positive := 1) return Positive
+ renames Incr;
+
+ I : Integer;
+
+begin
+ I := Incr_Ren (-3);
+ I := Incr_Ren (-3, 2);
+ I := Incr_Ren (-3, 0);
+end;