From 84ae33e7f55bc1c183ab907370dc6b967bd9b13a Mon Sep 17 00:00:00 2001 From: Javier Miranda Date: Tue, 16 Jun 2020 13:49:04 -0400 Subject: [PATCH] [Ada] Spurious error in generic dispatching constructor 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 38864933b447..a7cfb6538d31 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -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; --------------------------------------------------------- -- 2.47.2