-- and subtypes, string types and subtypes, and all numeric types).
-- Set if the type or subtype is constrained.
+-- Is_Constructor
+-- Defined in procedure entities. Set if a procedure denotes a
+-- constructor that allows object initialization via the 'Make attribute.
+
-- Is_Constr_Array_Subt_With_Bounds
-- Defined in all types and subtypes. Set only for an array subtype
-- which is constrained but nevertheless requires objects of this
-- subtype of an object whose nominal subtype is unconstrained. Note
-- that the constructed subtype itself will be constrained.
--- Is_Constructor
--- Defined in function and procedure entities. Set if a pragma
--- CPP_Constructor applies to the subprogram.
-
-- Is_Controlled_Active [base type only]
-- Defined in all type entities. Indicates that the type is controlled,
-- i.e. has been declared with the Finalizable or the Destructor aspect
-- Defined in all type entities, set only for tagged types to which a
-- valid pragma Import (CPP, ...) or pragma CPP_Class has been applied.
+-- Is_CPP_Constructor
+-- Defined in function and procedure entities. Set if a pragma
+-- CPP_Constructor applies to the subprogram.
+
-- Is_CUDA_Kernel
-- Defined in function and procedure entities. Set if the subprogram is a
-- CUDA kernel.
-- Is_Abstract_Subprogram (non-generic case only)
-- Is_Called (non-generic case only)
-- Is_Class_Wide_Wrapper
- -- Is_Constructor
+ -- Is_CPP_Constructor
-- Is_CUDA_Kernel (non-generic case only)
-- Is_DIC_Procedure (non-generic case only)
-- Is_Discrim_SO_Function
-- Is_Called (non-generic case only)
-- Is_Class_Wide_Wrapper
-- Is_Constructor
+ -- Is_CPP_Constructor
-- Is_CUDA_Kernel
-- Is_Destructor (non-generic case only)
-- Is_DIC_Procedure (non-generic case only)
begin
if not (Nkind (Specification (N)) = N_Procedure_Specification
- and then Is_Constructor_Procedure (Spec_Id))
+ and then Is_Constructor (Spec_Id))
then
return; -- the usual case
end if;
pragma Assert (Nkind (Allocator) = N_Allocator
and then Nkind (Function_Call) = N_Function_Call);
pragma Assert (Convention (Function_Id) = Convention_CPP
- and then Is_Constructor (Function_Id));
+ and then Is_CPP_Constructor (Function_Id));
pragma Assert (Is_Constrained (Underlying_Type (Result_Subt)));
-- Replace the initialized allocator of form "new T'(Func (...))" with
E := Next_Entity (Typ);
while Present (E) loop
- if Ekind (E) = E_Function and then Is_Constructor (E) then
+ if Ekind (E) = E_Function and then Is_CPP_Constructor (E) then
return True;
end if;
E := Next_Entity (Typ);
while Present (E) loop
if Ekind (E) = E_Function
- and then Is_Constructor (E)
+ and then Is_CPP_Constructor (E)
then
Found := True;
Loc := Sloc (E);
Defining_Unit_Name => IP,
Parameter_Specifications => Parms)));
- Set_Init_Proc (Typ, IP);
- Set_Is_Imported (IP);
- Set_Is_Constructor (IP);
- Set_Interface_Name (IP, Interface_Name (E));
- Set_Convention (IP, Convention_CPP);
- Set_Is_Public (IP);
- Set_Has_Completion (IP);
- Mutate_Ekind (IP, E_Procedure);
- Freeze_Extra_Formals (IP);
+ Set_Init_Proc (Typ, IP);
+ Set_Is_Imported (IP);
+ Set_Is_CPP_Constructor (IP);
+ Set_Interface_Name (IP, Interface_Name (E));
+ Set_Convention (IP, Convention_CPP);
+ Set_Is_Public (IP);
+ Set_Has_Completion (IP);
+ Mutate_Ekind (IP, E_Procedure);
+ Freeze_Extra_Formals (IP);
-- Case 2: Constructor of a tagged type
Defining_Unit_Name => Constructor_Id,
Parameter_Specifications => Parms));
- Set_Is_Imported (Constructor_Id);
- Set_Is_Constructor (Constructor_Id);
- Set_Interface_Name (Constructor_Id, Interface_Name (E));
- Set_Convention (Constructor_Id, Convention_CPP);
- Set_Is_Public (Constructor_Id);
- Set_Has_Completion (Constructor_Id);
+ Set_Is_Imported (Constructor_Id);
+ Set_Is_CPP_Constructor (Constructor_Id);
+ Set_Interface_Name (Constructor_Id, Interface_Name (E));
+ Set_Convention (Constructor_Id, Convention_CPP);
+ Set_Is_Public (Constructor_Id);
+ Set_Has_Completion (Constructor_Id);
-- Build the init procedure as a wrapper of this constructor
-- For C++ constructors check that their external name has been given
-- (either in pragma CPP_Constructor or in a pragma import).
- if Is_Constructor (E)
+ if Is_CPP_Constructor (E)
and then Convention (E) = Convention_CPP
and then
(No (Interface_Name (E))
Is_Controlled_Active,
Is_Controlling_Formal,
Is_CPP_Class,
+ Is_CPP_Constructor,
Is_CUDA_Kernel,
Is_Descendant_Of_Address,
Is_Destructor,
Sm (Is_Constructor, Flag),
Sm (Is_Controlled_Active, Flag, Base_Type_Only),
Sm (Is_CPP_Class, Flag),
+ Sm (Is_CPP_Constructor, Flag),
Sm (Is_Descendant_Of_Address, Flag),
Sm (Is_Discrim_SO_Function, Flag),
Sm (Is_Discriminant_Check_Function, Flag),
return "Ignore_SPARK_Mode_Pragmas";
when Is_CPP_Class =>
return "Is_CPP_Class";
+ when Is_CPP_Constructor =>
+ return "Is_CPP_Constructor";
when Is_CUDA_Kernel =>
return "Is_CUDA_Kernel";
when Is_DIC_Procedure =>
then
-- Note that, this workaround is needed to retain the info that
-- the current subprogram comes from a direct attribute
- -- definition. Otherwise, we would need to add an entity flag
- -- Is_Constructor. Currently this flag already exists and could be
- -- misleading as it refer to CPP constructors ???
+ -- definition. Otherwise, we would need to add an entity flag like
+ -- Is_Direct_Attribute_Definition ???
Copy_Spec := New_Copy (Spec);
else
Set_Needs_Construction (Prefix_E);
+ Set_Is_Constructor (Designator);
end if;
when others =>
-- Check if already defined as constructor
- if Is_Constructor (Def_Id) then
+ if Is_CPP_Constructor (Def_Id) then
Error_Msg_N
("??duplicate argument for pragma 'C'P'P_Constructor", Arg1);
return;
end if;
Set_Has_Completion (Def_Id);
- Set_Is_Constructor (Def_Id);
+ Set_Is_CPP_Constructor (Def_Id);
Set_Convention (Def_Id, Convention_CPP);
-- Imported C++ constructors are not dispatching primitives
Cursor := Get_Name_Entity_Id
(Direct_Attribute_Definition_Name (Typ, Name_Constructor));
while Present (Cursor) loop
- if Is_Constructor_Procedure (Cursor)
+ if Is_Constructor (Cursor)
and then No (Next_Formal (First_Formal (Cursor)))
then
return True;
end if;
end Is_Constant_Bound;
- ------------------------------
- -- Is_Constructor_Procedure --
- ------------------------------
-
- function Is_Constructor_Procedure (Subp : Entity_Id) return Boolean is
- First_Param : Entity_Id;
- begin
- if not (Present (First_Formal (Subp))
- and then Ekind (First_Formal (Subp)) = E_In_Out_Parameter
- and then Is_Direct_Attribute_Subp_Spec (Parent (Subp))
- and then Attribute_Name (Defining_Unit_Name
- (Original_Node (Parent (Subp))))
- = Name_Constructor)
- then
- return False;
- end if;
-
- First_Param := Implementation_Base_Type (Etype (First_Formal (Subp)));
- return Scope (Subp) = Scope (First_Param)
- and then Needs_Construction (First_Param);
- end Is_Constructor_Procedure;
-
---------------------------
-- Is_Container_Element --
---------------------------
return Present (Ret_Typ)
and then Is_CPP_Class (Ret_Typ)
- and then Is_Constructor (Entity (Name (N)))
+ and then Is_CPP_Constructor (Entity (Name (N)))
and then Is_Imported (Entity (Name (N)));
end Is_CPP_Constructor_Call;
-- enumeration literal, or an expression composed of constant-bound
-- subexpressions which are evaluated by means of standard operators.
- function Is_Constructor_Procedure (Subp : Entity_Id) return Boolean;
- -- Returns True if Subp's name directly references an attribute, has a
- -- first in out formal that needs construction within the same scope.
-
function Is_Container_Element (Exp : Node_Id) return Boolean;
-- This routine recognizes expressions that denote an element of one of
-- the predefined containers, when the source only contains an indexing
return "Ignore_SPARK_Mode_Pragmas";
when F_Is_CPP_Class =>
return "Is_CPP_Class";
+ when F_Is_CPP_Constructor =>
+ return "Is_CPP_Constructor";
when F_Is_CUDA_Kernel =>
return "Is_CUDA_Kernel";
when F_Is_DIC_Procedure =>