[Ada] Spurious error in generic dispatching constructor
authorJavier Miranda <miranda@adacore.com>
Tue, 16 Jun 2020 17:49:04 +0000 (13:49 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 27 Jul 2020 08:05:17 +0000 (04:05 -0400)
gcc/ada/

* exp_ch6.adb (Make_Build_In_Place_Iface_Call_In_Allocator):
Revert previous patch, and add a missing type conversion to
displace the pointer to the allocated object to reference the
target dispatch table.

gcc/ada/exp_ch6.adb

index 38864933b4474eea37d6ea5c57e1e49cca0d9f52..a7cfb6538d31bb6a96cdbfa123a33eb68b801800 100644 (file)
@@ -9726,8 +9726,7 @@ package body Exp_Ch6 is
       --  declaration.
 
       Anon_Type := Create_Itype (E_Anonymous_Access_Type, Function_Call);
-      Set_Directly_Designated_Type (Anon_Type,
-        Designated_Type (Etype (Allocator)));
+      Set_Directly_Designated_Type (Anon_Type, Etype (BIP_Func_Call));
       Set_Etype (Anon_Type, Anon_Type);
       Build_Class_Wide_Master (Anon_Type);
 
@@ -9757,7 +9756,12 @@ package body Exp_Ch6 is
         (Allocator     => Expression (Tmp_Decl),
          Function_Call => Expression (Expression (Tmp_Decl)));
 
-      Rewrite (Allocator, New_Occurrence_Of (Tmp_Id, Loc));
+      --  Add a conversion to displace the pointer to the allocated object
+      --  to reference the corresponding dispatch table.
+
+      Rewrite (Allocator,
+        Convert_To (Etype (Allocator),
+          New_Occurrence_Of (Tmp_Id, Loc)));
    end Make_Build_In_Place_Iface_Call_In_Allocator;
 
    ---------------------------------------------------------