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.
Tested on x86_64-pc-linux-gnu, committed on trunk
2018-07-17 Eric Botcazou <ebotca...@adacore.com>
gcc/ada/
* exp_disp.adb (Gen_Parameters_Profile): Make the _Init parameter an
In/Out parameter.
(Set_CPP_Constructors): Adjust comment accordingly.
--- gcc/ada/exp_disp.adb
+++ 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)