From: Eric Botcazou Date: Tue, 17 Jul 2018 08:09:54 +0000 (+0000) Subject: [Ada] Minor fix for imported C++ constructors X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a09e0260a6ed1b8e16f6b2eaa29ec5bf51d1e61;p=gcc.git [Ada] Minor fix for imported C++ constructors C++ constructors are imported as functions and then internally rewritten into procedures taking the "this" pointer as first parameter. Now this parameter is not of an access type but of the type directly, so it must be In/Out and not just In. 2018-07-17 Eric Botcazou gcc/ada/ * exp_disp.adb (Gen_Parameters_Profile): Make the _Init parameter an In/Out parameter. (Set_CPP_Constructors): Adjust comment accordingly. From-SVN: r262790 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a07673088cd..d078d6bb05b 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-07-17 Eric Botcazou + + * exp_disp.adb (Gen_Parameters_Profile): Make the _Init parameter an + In/Out parameter. + (Set_CPP_Constructors): Adjust comment accordingly. + 2018-07-17 Bob Duff * exp_disp.adb (Build_Class_Wide_Check): Return early if the diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index b0228154bc2..298265aa813 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -8181,7 +8181,8 @@ package body Exp_Disp is function Gen_Parameters_Profile (E : Entity_Id) return List_Id; -- Duplicate the parameters profile of the imported C++ constructor - -- adding an access to the object as an additional parameter. + -- adding the "this" pointer to the object as the additional first + -- parameter under the usual form _Init : in out Typ. ---------------------------- -- Gen_Parameters_Profile -- @@ -8198,6 +8199,8 @@ package body Exp_Disp is Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uInit), + In_Present => True, + Out_Present => True, Parameter_Type => New_Occurrence_Of (Typ, Loc))); if Present (Parameter_Specifications (Parent (E))) then @@ -8244,9 +8247,7 @@ package body Exp_Disp is Found := True; Loc := Sloc (E); Parms := Gen_Parameters_Profile (E); - IP := - Make_Defining_Identifier (Loc, - Chars => Make_Init_Proc_Name (Typ)); + IP := Make_Defining_Identifier (Loc, Make_Init_Proc_Name (Typ)); -- Case 1: Constructor of untagged type @@ -8273,14 +8274,14 @@ package body Exp_Disp is -- Case 2: Constructor of a tagged type - -- In this case we generate the IP as a wrapper of the the - -- C++ constructor because IP must also save copy of the _tag + -- In this case we generate the IP routine as a wrapper of the + -- C++ constructor because IP must also save a copy of the _tag -- generated in the C++ side. The copy of the _tag is used by -- Build_CPP_Init_Procedure to elaborate derivations of C++ types. -- Generate: - -- procedure IP (_init : Typ; ...) is - -- procedure ConstructorP (_init : Typ; ...); + -- procedure IP (_init : in out Typ; ...) is + -- procedure ConstructorP (_init : in out Typ; ...); -- pragma Import (ConstructorP); -- begin -- ConstructorP (_init, ...); @@ -8352,7 +8353,7 @@ package body Exp_Disp is loop -- Skip the following assertion with primary tags -- because Related_Type is not set on primary tag - -- components + -- components. pragma Assert (Tag_Comp = First_Tag_Component (Typ)