1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Nlists
; use Nlists
;
27 with Types
; use Types
;
30 procedure Analyze_Component_Declaration
(N
: Node_Id
);
31 procedure Analyze_Incomplete_Type_Decl
(N
: Node_Id
);
32 procedure Analyze_Itype_Reference
(N
: Node_Id
);
33 procedure Analyze_Number_Declaration
(N
: Node_Id
);
34 procedure Analyze_Object_Declaration
(N
: Node_Id
);
35 procedure Analyze_Others_Choice
(N
: Node_Id
);
36 procedure Analyze_Private_Extension_Declaration
(N
: Node_Id
);
37 procedure Analyze_Subtype_Indication
(N
: Node_Id
);
38 procedure Analyze_Type_Declaration
(N
: Node_Id
);
39 procedure Analyze_Variant_Part
(N
: Node_Id
);
41 procedure Analyze_Subtype_Declaration
43 Skip
: Boolean := False);
44 -- Called to analyze a subtype declaration. The parameter Skip is used for
45 -- Ada 2005 (AI-412). We set to True in order to avoid reentering the
46 -- defining identifier of N when analyzing a rewritten incomplete subtype
49 function Access_Definition
50 (Related_Nod
: Node_Id
;
51 N
: Node_Id
) return Entity_Id
;
52 -- An access definition defines a general access type for a formal
53 -- parameter. The procedure is called when processing formals, when
54 -- the current scope is the subprogram. The Implicit type is attached
55 -- to the Related_Nod put into the enclosing scope, so that the only
56 -- entities defined in the spec are the formals themselves.
58 procedure Access_Subprogram_Declaration
61 -- The subprogram specification yields the signature of an implicit
62 -- type, whose Ekind is Access_Subprogram_Type. This implicit type is
63 -- the designated type of the declared access type. In subprogram calls,
64 -- the signature of the implicit type works like the profile of a regular
67 procedure Analyze_Declarations
(L
: List_Id
);
68 -- Called to analyze a list of declarations (in what context ???). Also
69 -- performs necessary freezing actions (more description needed ???)
71 procedure Analyze_Interface_Declaration
(T
: Entity_Id
; Def
: Node_Id
);
72 -- Analyze an interface declaration or a formal interface declaration
74 procedure Array_Type_Declaration
(T
: in out Entity_Id
; Def
: Node_Id
);
75 -- Process an array type declaration. If the array is constrained, we
76 -- create an implicit parent array type, with the same index types and
79 procedure Access_Type_Declaration
(T
: Entity_Id
; Def
: Node_Id
);
80 -- Process an access type declaration
82 procedure Check_Abstract_Overriding
(T
: Entity_Id
);
83 -- Check that all abstract subprograms inherited from T's parent type
84 -- have been overridden as required, and that nonabstract subprograms
85 -- have not been incorrectly overridden with an abstract subprogram.
87 procedure Check_Aliased_Component_Types
(T
: Entity_Id
);
88 -- Given an array type or record type T, check that if the type is
89 -- nonlimited, then the nominal subtype of any components of T
90 -- that have discriminants must be constrained.
92 procedure Check_Completion
(Body_Id
: Node_Id
:= Empty
);
93 -- At the end of a declarative part, verify that all entities that
94 -- require completion have received one. If Body_Id is absent, the
95 -- error indicating a missing completion is placed on the declaration
96 -- that needs completion. If Body_Id is present, it is the defining
97 -- identifier of a package body, and errors are posted on that node,
98 -- rather than on the declarations that require completion in the package
101 procedure Derive_Subprogram
102 (New_Subp
: in out Entity_Id
;
103 Parent_Subp
: Entity_Id
;
104 Derived_Type
: Entity_Id
;
105 Parent_Type
: Entity_Id
;
106 Actual_Subp
: Entity_Id
:= Empty
);
107 -- Derive the subprogram Parent_Subp from Parent_Type, and replace the
108 -- subsidiary subtypes with the derived type to build the specification
109 -- of the inherited subprogram (returned in New_Subp). For tagged types,
110 -- the derived subprogram is aliased to that of the actual (in the
111 -- case where Actual_Subp is nonempty) rather than to the corresponding
112 -- subprogram of the parent type.
114 procedure Derive_Subprograms
115 (Parent_Type
: Entity_Id
;
116 Derived_Type
: Entity_Id
;
117 Generic_Actual
: Entity_Id
:= Empty
);
118 -- To complete type derivation, collect/retrieve the primitive operations
119 -- of the parent type, and replace the subsidiary subtypes with the derived
120 -- type, to build the specs of the inherited ops. For generic actuals, the
121 -- mapping of the primitive operations to those of the parent type is also
122 -- done by rederiving the operations within the instance. For tagged types,
123 -- the derived subprograms are aliased to those of the actual, not those of
126 -- Note: one might expect this to be private to the package body, but
127 -- there is one rather unusual usage in package Exp_Dist.
129 function Find_Hidden_Interface
131 Dest
: Elist_Id
) return Entity_Id
;
132 -- Ada 2005: Determine whether the interfaces in list Src are all present
133 -- in the list Dest. Return the first differing interface, or Empty
136 function Find_Type_Of_Subtype_Indic
(S
: Node_Id
) return Entity_Id
;
137 -- Given a subtype indication S (which is really an N_Subtype_Indication
138 -- node or a plain N_Identifier), find the type of the subtype mark.
140 function Find_Type_Name
(N
: Node_Id
) return Entity_Id
;
141 -- Enter the identifier in a type definition, or find the entity already
142 -- declared, in the case of the full declaration of an incomplete or
145 function Get_Discriminant_Value
146 (Discriminant
: Entity_Id
;
147 Typ_For_Constraint
: Entity_Id
;
148 Constraint
: Elist_Id
) return Node_Id
;
149 -- ??? MORE DOCUMENTATION
150 -- Given a discriminant somewhere in the Typ_For_Constraint tree
151 -- and a Constraint, return the value of that discriminant.
153 function Is_Null_Extension
(T
: Entity_Id
) return Boolean;
154 -- Returns True if the tagged type T has an N_Full_Type_Declaration that
155 -- is a null extension, meaning that it has an extension part without any
156 -- components and does not have a known discriminant part.
158 function Is_Visible_Component
(C
: Entity_Id
) return Boolean;
159 -- Determines if a record component C is visible in the present context.
160 -- Note that even though component C could appear in the entity chain
161 -- of a record type, C may not be visible in the current context. For
162 -- instance, C may be a component inherited in the full view of a private
163 -- extension which is not visible in the current context.
167 Related_Nod
: Node_Id
;
168 Related_Id
: Entity_Id
:= Empty
;
169 Suffix_Index
: Nat
:= 1);
170 -- Process an index that is given in an array declaration, an entry
171 -- family declaration or a loop iteration. The index is given by an
172 -- index declaration (a 'box'), or by a discrete range. The later can
173 -- be the name of a discrete type, or a subtype indication.
175 -- Related_Nod is the node where the potential generated implicit types
176 -- will be inserted. The 2 last parameters are used for creating the name.
178 procedure Make_Class_Wide_Type
(T
: Entity_Id
);
179 -- A Class_Wide_Type is created for each tagged type definition. The
180 -- attributes of a class-wide type are inherited from those of the type T.
181 -- If T is introduced by a private declaration, the corresponding class
182 -- wide type is created at the same time, and therefore there is a private
183 -- and a full declaration for the class-wide type as well.
185 function OK_For_Limited_Init_In_05
187 Exp
: Node_Id
) return Boolean;
188 -- Presuming Exp is an expression of an inherently limited type Typ,
189 -- returns True if the expression is allowed in an initialization context
190 -- by the rules of Ada 2005. We use the rule in RM-7.5(2.1/2), "...it is an
191 -- aggregate, a function_call, or a parenthesized expression or qualified
192 -- expression whose operand is permitted...". Note that in Ada 95 mode,
193 -- we sometimes wish to give warnings based on whether the program _would_
194 -- be legal in Ada 2005. Note that Exp must already have been resolved,
195 -- so we can know whether it's a function call (as opposed to an indexed
196 -- component, for example). In the case where Typ is a limited interface's
197 -- class-wide type, then the expression is allowed to be of any kind if its
198 -- type is a nonlimited descendant of the interface.
200 function OK_For_Limited_Init
202 Exp
: Node_Id
) return Boolean;
203 -- Always False in Ada 95 mode. Equivalent to OK_For_Limited_Init_In_05 in
206 procedure Preanalyze_Spec_Expression
(N
: Node_Id
; T
: Entity_Id
);
207 -- Default and per object expressions do not freeze their components, and
208 -- must be analyzed and resolved accordingly. The analysis is done by
209 -- calling the Preanalyze_And_Resolve routine and setting the global
210 -- In_Default_Expression flag. See the documentation section entitled
211 -- "Handling of Default and Per-Object Expressions" in sem.ads for full
212 -- details. N is the expression to be analyzed, T is the expected type.
214 procedure Process_Full_View
(N
: Node_Id
; Full_T
, Priv_T
: Entity_Id
);
215 -- Process some semantic actions when the full view of a private type is
216 -- encountered and analyzed. The first action is to create the full views
217 -- of the dependant private subtypes. The second action is to recopy the
218 -- primitive operations of the private view (in the tagged case).
219 -- N is the N_Full_Type_Declaration node.
221 -- Full_T is the full view of the type whose full declaration is in N.
223 -- Priv_T is the private view of the type whose full declaration is in N.
225 procedure Process_Range_Expr_In_Decl
228 Check_List
: List_Id
:= Empty_List
;
229 R_Check_Off
: Boolean := False);
230 -- Process a range expression that appears in a declaration context. The
231 -- range is analyzed and resolved with the base type of the given type,
232 -- and an appropriate check for expressions in non-static contexts made
233 -- on the bounds. R is analyzed and resolved using T, so the caller should
234 -- if necessary link R into the tree before the call, and in particular in
235 -- the case of a subtype declaration, it is appropriate to set the parent
236 -- pointer of R so that the types get properly frozen. The Check_List
237 -- parameter is used when the subprogram is called from
238 -- Build_Record_Init_Proc and is used to return a set of constraint
239 -- checking statements generated by the Checks package. R_Check_Off is set
240 -- to True when the call to Range_Check is to be skipped.
242 function Process_Subtype
244 Related_Nod
: Node_Id
;
245 Related_Id
: Entity_Id
:= Empty
;
246 Suffix
: Character := ' ') return Entity_Id
;
247 -- Process a subtype indication S and return corresponding entity.
248 -- Related_Nod is the node where the potential generated implicit types
249 -- will be inserted. The Related_Id and Suffix parameters are used to
250 -- build the associated Implicit type name.
252 procedure Process_Discriminants
254 Prev
: Entity_Id
:= Empty
);
255 -- Process the discriminants contained in an N_Full_Type_Declaration or
256 -- N_Incomplete_Type_Decl node N. If the declaration is a completion,
257 -- Prev is entity on the partial view, on which references are posted.
259 function Replace_Anonymous_Access_To_Protected_Subprogram
260 (N
: Node_Id
) return Entity_Id
;
261 -- Ada 2005 (AI-254): Create and decorate an internal full type declaration
262 -- for an anonymous access to protected subprogram. For a record component
263 -- declaration, the type is created in the enclosing scope, for an array
264 -- type declaration or an object declaration it is simply placed ahead of
267 procedure Set_Completion_Referenced
(E
: Entity_Id
);
268 -- If E is the completion of a private or incomplete type declaration,
269 -- or the completion of a deferred constant declaration, mark the entity
270 -- as referenced. Warnings on unused entities, if needed, go on the