[Ada] Add missing conversion in call to Finalize primitive
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 29 Jan 2020 15:15:09 +0000 (16:15 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 4 Jun 2020 09:11:17 +0000 (05:11 -0400)
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.

gcc/ada/exp_ch7.adb

index fbdef9b..ed4e8c5 100644 (file)
@@ -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;