* decl.c (compute_array_index_type): Use type_dependent_expression_p.
[official-gcc.git] / gcc / ada / exp_ch3.ads
blob1abc4567a330b0a4fe2bd86e886f2fd52b50b733
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ C H 3 --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- Expand routines for chapter 3 constructs
28 with Types; use Types;
29 with Elists; use Elists;
30 with Uintp; use Uintp;
32 package Exp_Ch3 is
34 procedure Expand_N_Object_Declaration (N : Node_Id);
35 procedure Expand_N_Subtype_Indication (N : Node_Id);
36 procedure Expand_N_Variant_Part (N : Node_Id);
37 procedure Expand_N_Full_Type_Declaration (N : Node_Id);
39 procedure Expand_Previous_Access_Type (Def_Id : Entity_Id);
40 -- For a full type declaration that contains tasks, or that is a task,
41 -- check whether there exists an access type whose designated type is an
42 -- incomplete declarations for the current composite type. If so, build the
43 -- master for that access type, now that it is known to denote an object
44 -- with tasks.
46 procedure Expand_Record_Extension (T : Entity_Id; Def : Node_Id);
47 -- Add a field _parent in the extension part of the record
49 procedure Build_Array_Invariant_Proc (A_Type : Entity_Id; Nod : Node_Id);
50 -- If the component of type of array type has invariants, build procedure
51 -- that checks invariant on all components of the array. Ada 2012 specifies
52 -- that an invariant on some type T must be applied to in-out parameters
53 -- and return values that include a part of type T.
55 procedure Build_Discr_Checking_Funcs (N : Node_Id);
56 -- Builds function which checks whether the component name is consistent
57 -- with the current discriminants. N is the full type declaration node,
58 -- and the discriminant checking functions are inserted after this node.
60 function Build_Initialization_Call
61 (Loc : Source_Ptr;
62 Id_Ref : Node_Id;
63 Typ : Entity_Id;
64 In_Init_Proc : Boolean := False;
65 Enclos_Type : Entity_Id := Empty;
66 Discr_Map : Elist_Id := New_Elmt_List;
67 With_Default_Init : Boolean := False;
68 Constructor_Ref : Node_Id := Empty) return List_Id;
69 -- Builds a call to the initialization procedure for the base type of Typ,
70 -- passing it the object denoted by Id_Ref, plus additional parameters as
71 -- appropriate for the type (the _Master, for task types, for example).
72 -- Loc is the source location for the constructed tree. In_Init_Proc has
73 -- to be set to True when the call is itself in an init proc in order to
74 -- enable the use of discriminals. Enclos_Type is the enclosing type when
75 -- initializing a component in an outer init proc, and it is used for
76 -- various expansion cases including the case where Typ is a task type
77 -- which is an array component, the indexes of the enclosing type are
78 -- used to build the string that identifies each task at runtime.
80 -- Discr_Map is used to replace discriminants by their discriminals in
81 -- expressions used to constrain record components. In the presence of
82 -- entry families bounded by discriminants, protected type discriminants
83 -- can appear within expressions in array bounds (not as stand-alone
84 -- identifiers) and a general replacement is necessary.
86 -- Ada 2005 (AI-287): With_Default_Init is used to indicate that the
87 -- initialization call corresponds to a default initialized component
88 -- of an aggregate.
90 -- Constructor_Ref is a call to a constructor subprogram. It is currently
91 -- used only to support C++ constructors.
93 function Freeze_Type (N : Node_Id) return Boolean;
94 -- This function executes the freezing actions associated with the given
95 -- freeze type node N and returns True if the node is to be deleted. We
96 -- delete the node if it is present just for front end purpose and we don't
97 -- want Gigi to see the node. This function can't delete the node itself
98 -- since it would confuse any remaining processing of the freeze node.
100 procedure Init_Secondary_Tags
101 (Typ : Entity_Id;
102 Target : Node_Id;
103 Stmts_List : List_Id;
104 Fixed_Comps : Boolean := True;
105 Variable_Comps : Boolean := True);
106 -- Ada 2005 (AI-251): Initialize the tags of the secondary dispatch tables
107 -- of Typ. The generated code referencing tag fields of Target is appended
108 -- to Stmts_List. If Fixed_Comps is True then the tag components located at
109 -- fixed positions of Target are initialized; if Variable_Comps is True
110 -- then tags components located at variable positions of Target are
111 -- initialized.
113 function Needs_Simple_Initialization
114 (T : Entity_Id;
115 Consider_IS : Boolean := True) return Boolean;
116 -- Certain types need initialization even though there is no specific
117 -- initialization routine:
118 -- Access types (which need initializing to null)
119 -- All scalar types if Normalize_Scalars mode set
120 -- Descendents of standard string types if Normalize_Scalars mode set
121 -- Scalar types having a Default_Value attribute
122 -- Regarding Initialize_Scalars mode, this is ignored if Consider_IS is
123 -- set to False, but if Consider_IS is set to True, then the cases above
124 -- mentioning Normalize_Scalars also apply for Initialize_Scalars mode.
126 function Get_Simple_Init_Val
127 (T : Entity_Id;
128 N : Node_Id;
129 Size : Uint := No_Uint) return Node_Id;
130 -- For a type which Needs_Simple_Initialization (see above), prepares the
131 -- tree for an expression representing the required initial value. N is a
132 -- node whose source location used in constructing this tree which is
133 -- returned as the result of the call. The Size parameter indicates the
134 -- target size of the object if it is known (indicated by a value that is
135 -- not No_Uint and is greater than zero). If Size is not given (Size set to
136 -- No_Uint, or non-positive), then the Esize of T is used as an estimate of
137 -- the Size. The object size is needed to prepare a known invalid value for
138 -- use by Normalize_Scalars. A call to this routine where T is a scalar
139 -- type is only valid if we are in Normalize_Scalars or Initialize_Scalars
140 -- mode, or if N is the node for a 'Invalid_Value attribute node.
142 end Exp_Ch3;