8sa1-gcc/gcc/ada/exp_ch3.ads
Javier Miranda 3476f94908 exp_ch3.ads, [...] (Expand_N_Object_Declaration): Do not register in the final list objects containing class-wide interfaces...
2006-10-31  Javier Miranda  <miranda@adacore.com>
	    Robert Dewar  <dewar@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>
	    Gary Dismukes  <dismukes@adacore.com>

        * exp_ch3.ads, exp_ch3.adb (Expand_N_Object_Declaration): Do not
	register in the final list objects containing class-wide interfaces;
	otherwise we incorrectly register the tag of the interface in the final
	list.
        (Make_Controlling_Function_Wrappers): Add missing barrier to do not
        generate the wrapper if the parent primitive is abstract. This is
        required to report the correct error message.
        (Expand_N_Subtype_Indication): Do validity checks on range
	(Clean_Task_Names): If an initialization procedure includes a call to
	initialize a task (sub)component, indicate that the procedure will use
	the secondary stack.
	(Build_Init_Procedure, Init_Secondary_Tags): Enable full ABI
	compatibility for interfacing with CPP by default.
	(Expand_N_Object_Declaration): Only build an Adjust call when the
	object's type is a nonlimited controlled type.
	* exp_ch3.adb: Add with and use of Exp_Ch6.
	(Expand_N_Object_Declaration): Check for object initialization that is a
	call to build-in-place function and apply Make_Build_In_Place_Call_In_
	Object_Declaration to the call.
	(Freeze_Type): When the designated type of an RACW was not frozen at the
	point where the RACW was declared, validate the primitive operations
	with respect to E.2.2(14) when it finally is frozen.
	(Build_Initialization_Call,Expand_Record_Controller): Rename
	Is_Return_By_Reference_Type to be Is_Inherently_Limited_Type, because
	return-by-reference has no meaning in Ada 2005.
	(Init_Secondary_Tags): Add missing call to Set_Offset_To_Top
	to register tag of the immediate ancestor interfaces in the
	run-time structure.
	(Init_Secondary_Tags): Moved to the specification to allow the
	initialization of extension aggregates with abstract interfaces.
	(Build_Master_Renaming): Make public, for use by function declarations
	whose return type is an anonymous access type.
	(Freeze_Record_Type): Replace call to Insert_List_Before by call to
	Insert_List_Before_And_Analyze after the generation of the specs
	associated with null procedures.
	(Expand_Tagged_Root): Update documentation in its specification.
	(Init_Secondary_Tags): Update documentation.
	(Build_Init_Procedure): If we are compiling under CPP full ABI compa-
	tibility mode and the immediate ancestor is a CPP_Pragma tagged type
	then generate code to inherit the contents of the dispatch table
	directly from the ancestor.
	(Expand_Record_Controller): Insert controller component after tags of
	implemented interfaces.
	(Freeze_Record_Type): Call new procedure Make_Null_Procedure_Specs to
	create null procedure overridings when null procedures are inherited
	from interfaces.
	(Make_Null_Procedure_Specs): New procedure to generate null procedure
	declarations for overriding null primitives inherited from interfaces.
	(Is_Null_Interface_Procedure): New function in
	Make_Null_Procedure_Specs.
	(Make_Predefined_Primitive_Specs/Predefined_Primitive_Bodies): If the
	immediate ancestor of a tagged type is an abstract interface type we
	must generate the specification of the predefined primitives associated
	with controlled types (because the dispatch table of the ancestor is
	null and hence these entries cannot be inherited). This is required to
	elaborate well the dispatch table.

From-SVN: r118256
2006-10-31 18:54:22 +01:00

146 lines
8.0 KiB
Ada

------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ C H 3 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Expand routines for chapter 3 constructs
with Types; use Types;
with Elists; use Elists;
with Uintp; use Uintp;
package Exp_Ch3 is
procedure Expand_N_Object_Declaration (N : Node_Id);
procedure Expand_N_Subtype_Indication (N : Node_Id);
procedure Expand_N_Variant_Part (N : Node_Id);
procedure Expand_N_Full_Type_Declaration (N : Node_Id);
procedure Expand_Previous_Access_Type (Def_Id : Entity_Id);
-- For a full type declaration that contains tasks, or that is a task,
-- check whether there exists an access type whose designated type is an
-- incomplete declarations for the current composite type. If so, build the
-- master for that access type, now that it is known to denote an object
-- with tasks.
procedure Expand_Record_Extension (T : Entity_Id; Def : Node_Id);
-- Add a field _parent in the extension part of the record
procedure Build_Class_Wide_Master (T : Entity_Id);
-- For access to class-wide limited types we must build a task master
-- because some subsequent extension may add a task component. To avoid
-- bringing in the tasking run-time whenever an access-to-class-wide
-- limited type is used, we use the soft-link mechanism and add a level of
-- indirection to calls to routines that manipulate Master_Ids. This must
-- also be used for anonymous access types whose designated type is a task
-- or synchronized interface.
procedure Build_Discr_Checking_Funcs (N : Node_Id);
-- Builds function which checks whether the component name is consistent
-- with the current discriminants. N is the full type declaration node,
-- and the discriminant checking functions are inserted after this node.
function Build_Initialization_Call
(Loc : Source_Ptr;
Id_Ref : Node_Id;
Typ : Entity_Id;
In_Init_Proc : Boolean := False;
Enclos_Type : Entity_Id := Empty;
Discr_Map : Elist_Id := New_Elmt_List;
With_Default_Init : Boolean := False) return List_Id;
-- Builds a call to the initialization procedure of the Id entity. Id_Ref
-- is either a new reference to Id (for record fields), or an indexed
-- component (for array elements). Loc is the source location for the
-- constructed tree, and Typ is the type of the entity (the initialization
-- procedure of the base type is the procedure that actually gets called).
-- In_Init_Proc has to be set to True when the call is itself in an init
-- proc in order to enable the use of discriminals. Enclos_type is the type
-- of the init proc and it is used for various expansion cases including
-- the case where Typ is a task type which is a array component, the
-- indices of the enclosing type are used to build the string that
-- identifies each task at runtime.
--
-- Discr_Map is used to replace discriminants by their discriminals in
-- expressions used to constrain record components. In the presence of
-- entry families bounded by discriminants, protected type discriminants
-- can appear within expressions in array bounds (not as stand-alone
-- identifiers) and a general replacement is necessary.
--
-- Ada 2005 (AI-287): With_Default_Init is used to indicate that the
-- initialization call corresponds to a default initialized component
-- of an aggregate.
procedure Build_Master_Renaming (N : Node_Id; T : Entity_Id);
-- If the designated type of an access type is a task type or contains
-- tasks, we make sure that a _Master variable is declared in the current
-- scope, and then declare a renaming for it:
--
-- atypeM : Master_Id renames _Master;
--
-- where atyp is the name of the access type. This declaration is
-- used when an allocator for the access type is expanded. The node N
-- is the full declaration of the designated type that contains tasks.
-- The renaming declaration is inserted before N, and after the Master
-- declaration.
function Freeze_Type (N : Node_Id) return Boolean;
-- This function executes the freezing actions associated with the given
-- freeze type node N and returns True if the node is to be deleted. We
-- delete the node if it is present just for front end purpose and we don't
-- want Gigi to see the node. This function can't delete the node itself
-- since it would confuse any remaining processing of the freeze node.
procedure Init_Secondary_Tags
(Typ : Entity_Id;
Target : Node_Id;
Stmts_List : List_Id);
-- Ada 2005 (AI-251): Initialize the tags of all the secondary tables
-- associated with the abstract interfaces of Typ. The generated code
-- referencing tag fields of Target is appended to Stmts_List.
function Needs_Simple_Initialization (T : Entity_Id) return Boolean;
-- Certain types need initialization even though there is no specific
-- initialization routine. In this category are access types (which need
-- initializing to null), packed array types whose implementation is a
-- modular type, and all scalar types if Normalize_Scalars is set, as well
-- as private types whose underlying type is present and meets any of these
-- criteria. Finally, descendants of String and Wide_String also need
-- initialization in Initialize/Normalize_Scalars mode.
function Get_Simple_Init_Val
(T : Entity_Id;
Loc : Source_Ptr;
Size : Uint := No_Uint) return Node_Id;
-- For a type which Needs_Simple_Initialization (see above), prepares the
-- tree for an expression representing the required initial value. Loc is
-- the source location used in constructing this tree which is returned as
-- the result of the call. The Size parameter indicates the target size of
-- the object if it is known (indicated by a value that is not No_Uint and
-- is greater than zero). If Size is not given (Size set to No_Uint, or
-- non-positive), then the Esize of T is used as an estimate of the Size.
-- The object size is needed to prepare a known invalid value for use by
-- Normalize_Scalars.
end Exp_Ch3;