diff mbox series

[Ada] Add missing conversion in call to Finalize primitive

Message ID 20200604091256.GA134727@adacore.com
State New
Headers show
Series [Ada] Add missing conversion in call to Finalize primitive | expand

Commit Message

Pierre-Marie de Rodat June 4, 2020, 9:12 a.m. UTC
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  <ebotcazou@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.
diff mbox series

Patch

--- 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;