This makes sure that Convert_View adds the unchecked conversion from
actual to formal type in the case where the type of the actual is
derived from a private formal type and for the Finalize primitive; the
same trick is already used for the call to the Adjust primitive.
That's necessary since Underlying_Type returns the Underlying_Full_View
of a type derived from a private type, when it exists, instead of the
Full_View of the parent type.
Tested on x86_64-pc-linux-gnu, committed on trunk
2020-06-04 Eric Botcazou <ebotca...@adacore.com>
gcc/ada/
* exp_ch7.adb (Make_Final_Call): Set the type of the object, if
it is unanalyzed, before calling Convert_View on it.
--- gcc/ada/exp_ch7.adb
+++ gcc/ada/exp_ch7.adb
@@ -8432,6 +8432,15 @@ package body Exp_Ch7 is
end if;
end;
+ -- If the object is unanalyzed, set its expected type for use in
+ -- Convert_View in case an additional conversion is needed.
+
+ if No (Etype (Ref))
+ and then Nkind (Ref) /= N_Unchecked_Type_Conversion
+ then
+ Set_Etype (Ref, Typ);
+ end if;
+
Ref := Convert_View (Fin_Id, Ref);
end if;