PR middle-end/20297
[official-gcc.git] / gcc / ada / sem_ch3.ads
blobd4d3799396e9429a867a5781192506b606ce857c
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E M _ C H 3 --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2005, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with Nlists; use Nlists;
28 with Types; use Types;
30 package Sem_Ch3 is
31 procedure Analyze_Component_Declaration (N : Node_Id);
32 procedure Analyze_Incomplete_Type_Decl (N : Node_Id);
33 procedure Analyze_Itype_Reference (N : Node_Id);
34 procedure Analyze_Number_Declaration (N : Node_Id);
35 procedure Analyze_Object_Declaration (N : Node_Id);
36 procedure Analyze_Others_Choice (N : Node_Id);
37 procedure Analyze_Private_Extension_Declaration (N : Node_Id);
38 procedure Analyze_Subtype_Declaration (N : Node_Id);
39 procedure Analyze_Subtype_Indication (N : Node_Id);
40 procedure Analyze_Type_Declaration (N : Node_Id);
41 procedure Analyze_Variant_Part (N : Node_Id);
43 function Access_Definition
44 (Related_Nod : Node_Id;
45 N : Node_Id) return Entity_Id;
46 -- An access definition defines a general access type for a formal
47 -- parameter. The procedure is called when processing formals, when
48 -- the current scope is the subprogram. The Implicit type is attached
49 -- to the Related_Nod put into the enclosing scope, so that the only
50 -- entities defined in the spec are the formals themselves.
52 procedure Access_Subprogram_Declaration
53 (T_Name : Entity_Id;
54 T_Def : Node_Id);
55 -- The subprogram specification yields the signature of an implicit
56 -- type, whose Ekind is Access_Subprogram_Type. This implicit type is
57 -- the designated type of the declared access type. In subprogram calls,
58 -- the signature of the implicit type works like the profile of a regular
59 -- subprogram.
61 procedure Analyze_Declarations (L : List_Id);
62 -- Called to analyze a list of declarations (in what context ???). Also
63 -- performs necessary freezing actions (more description needed ???)
65 procedure Analyze_Interface_Declaration (T : Entity_Id; Def : Node_Id);
66 -- Analyze an interface declaration or a formal interface declaration
68 procedure Analyze_Per_Use_Expression (N : Node_Id; T : Entity_Id);
69 -- Default and per object expressions do not freeze their components,
70 -- and must be analyzed and resolved accordingly. The analysis is
71 -- done by calling the Pre_Analyze_And_Resolve routine and setting
72 -- the global In_Default_Expression flag. See the documentation section
73 -- entitled "Handling of Default and Per-Object Expressions" in sem.ads
74 -- for details. N is the expression to be analyzed, T is the expected type.
76 procedure Array_Type_Declaration (T : in out Entity_Id; Def : Node_Id);
77 -- Process an array type declaration. If the array is constrained, we
78 -- create an implicit parent array type, with the same index types and
79 -- component type.
81 procedure Access_Type_Declaration (T : Entity_Id; Def : Node_Id);
82 -- Process an access type declaration
84 procedure Check_Abstract_Overriding (T : Entity_Id);
85 -- Check that all abstract subprograms inherited from T's parent type
86 -- have been overridden as required, and that nonabstract subprograms
87 -- have not been incorrectly overridden with an abstract subprogram.
89 procedure Check_Aliased_Component_Types (T : Entity_Id);
90 -- Given an array type or record type T, check that if the type is
91 -- nonlimited, then the nominal subtype of any components of T
92 -- that have discriminants must be constrained.
94 procedure Check_Completion (Body_Id : Node_Id := Empty);
95 -- At the end of a declarative part, verify that all entities that
96 -- require completion have received one. If Body_Id is absent, the
97 -- error indicating a missing completion is placed on the declaration
98 -- that needs completion. If Body_Id is present, it is the defining
99 -- identifier of a package body, and errors are posted on that node,
100 -- rather than on the declarations that require completion in the package
101 -- declaration.
103 procedure Collect_Interfaces
104 (N : Node_Id;
105 Derived_Type : Entity_Id);
106 -- Ada 2005 (AI-251): Subsidiary procedure to Build_Derived_Record_Type
107 -- and Analyze_Formal_Interface_Type.
108 -- Collect the list of interfaces that are not already implemented by the
109 -- ancestors. This is the list of interfaces for which we must provide
110 -- additional tag components.
112 procedure Derive_Subprogram
113 (New_Subp : in out Entity_Id;
114 Parent_Subp : Entity_Id;
115 Derived_Type : Entity_Id;
116 Parent_Type : Entity_Id;
117 Actual_Subp : Entity_Id := Empty);
118 -- Derive the subprogram Parent_Subp from Parent_Type, and replace the
119 -- subsidiary subtypes with the derived type to build the specification
120 -- of the inherited subprogram (returned in New_Subp). For tagged types,
121 -- the derived subprogram is aliased to that of the actual (in the
122 -- case where Actual_Subp is nonempty) rather than to the corresponding
123 -- subprogram of the parent type.
125 procedure Derive_Subprograms
126 (Parent_Type : Entity_Id;
127 Derived_Type : Entity_Id;
128 Generic_Actual : Entity_Id := Empty;
129 No_Predefined_Prims : Boolean := False);
130 -- To complete type derivation, collect/retrieve the primitive operations
131 -- of the parent type, and replace the subsidiary subtypes with the derived
132 -- type, to build the specs of the inherited ops. For generic actuals, the
133 -- mapping of the primitive operations to those of the parent type is also
134 -- done by rederiving the operations within the instance. For tagged types,
135 -- the derived subprograms are aliased to those of the actual, not those of
136 -- the ancestor. The last two params are used in case of derivation from
137 -- abstract interface types: No_Predefined_Prims is used to avoid the
138 -- derivation of predefined primitives from an abstract interface.
140 -- Note: one might expect this to be private to the package body, but
141 -- there is one rather unusual usage in package Exp_Dist.
143 function Find_Type_Of_Subtype_Indic (S : Node_Id) return Entity_Id;
144 -- Given a subtype indication S (which is really an N_Subtype_Indication
145 -- node or a plain N_Identifier), find the type of the subtype mark.
147 function Find_Type_Name (N : Node_Id) return Entity_Id;
148 -- Enter the identifier in a type definition, or find the entity already
149 -- declared, in the case of the full declaration of an incomplete or
150 -- private type.
152 function Get_Discriminant_Value
153 (Discriminant : Entity_Id;
154 Typ_For_Constraint : Entity_Id;
155 Constraint : Elist_Id) return Node_Id;
156 -- ??? MORE DOCUMENTATION
157 -- Given a discriminant somewhere in the Typ_For_Constraint tree
158 -- and a Constraint, return the value of that discriminant.
160 function Is_Null_Extension (T : Entity_Id) return Boolean;
161 -- Returns True if the tagged type T has an N_Full_Type_Declaration that
162 -- is a null extension, meaning that it has an extension part without any
163 -- components and does not have a known discriminant part.
165 function Is_Visible_Component (C : Entity_Id) return Boolean;
166 -- Determines if a record component C is visible in the present context.
167 -- Note that even though component C could appear in the entity chain
168 -- of a record type, C may not be visible in the current context. For
169 -- instance, C may be a component inherited in the full view of a private
170 -- extension which is not visible in the current context.
172 procedure Make_Index
173 (I : Node_Id;
174 Related_Nod : Node_Id;
175 Related_Id : Entity_Id := Empty;
176 Suffix_Index : Nat := 1);
177 -- Process an index that is given in an array declaration, an entry
178 -- family declaration or a loop iteration. The index is given by an
179 -- index declaration (a 'box'), or by a discrete range. The later can
180 -- be the name of a discrete type, or a subtype indication.
181 -- Related_Nod is the node where the potential generated implicit types
182 -- will be inserted. The 2 last parameters are used for creating the name.
184 procedure Make_Class_Wide_Type (T : Entity_Id);
185 -- A Class_Wide_Type is created for each tagged type definition. The
186 -- attributes of a class wide type are inherited from those of the type
187 -- T. If T is introduced by a private declaration, the corresponding
188 -- class wide type is created at the same time, and therefore there is
189 -- a private and a full declaration for the class wide type type as well.
191 procedure Process_Full_View (N : Node_Id; Full_T, Priv_T : Entity_Id);
192 -- Process some semantic actions when the full view of a private type is
193 -- encountered and analyzed. The first action is to create the full views
194 -- of the dependant private subtypes. The second action is to recopy the
195 -- primitive operations of the private view (in the tagged case).
196 -- N is the N_Full_Type_Declaration node.
198 -- Full_T is the full view of the type whose full declaration is in N.
200 -- Priv_T is the private view of the type whose full declaration is in N.
202 procedure Process_Range_Expr_In_Decl
203 (R : Node_Id;
204 T : Entity_Id;
205 Check_List : List_Id := Empty_List;
206 R_Check_Off : Boolean := False);
207 -- Process a range expression that appears in a declaration context. The
208 -- range is analyzed and resolved with the base type of the given type,
209 -- and an appropriate check for expressions in non-static contexts made
210 -- on the bounds. R is analyzed and resolved using T, so the caller should
211 -- if necessary link R into the tree before the call, and in particular in
212 -- the case of a subtype declaration, it is appropriate to set the parent
213 -- pointer of R so that the types get properly frozen. The Check_List
214 -- parameter is used when the subprogram is called from
215 -- Build_Record_Init_Proc and is used to return a set of constraint
216 -- checking statements generated by the Checks package. R_Check_Off is
217 -- set to True when the call to Range_Check is to be skipped.
219 function Process_Subtype
220 (S : Node_Id;
221 Related_Nod : Node_Id;
222 Related_Id : Entity_Id := Empty;
223 Suffix : Character := ' ') return Entity_Id;
224 -- Process a subtype indication S and return corresponding entity.
225 -- Related_Nod is the node where the potential generated implicit types
226 -- will be inserted. The Related_Id and Suffix parameters are used to
227 -- build the associated Implicit type name.
229 procedure Process_Discriminants
230 (N : Node_Id;
231 Prev : Entity_Id := Empty);
232 -- Process the discriminants contained in an N_Full_Type_Declaration or
233 -- N_Incomplete_Type_Decl node N. If the declaration is a completion,
234 -- Prev is entity on the partial view, on which references are posted.
236 function Replace_Anonymous_Access_To_Protected_Subprogram
237 (N : Node_Id;
238 Prev_E : Entity_Id) return Entity_Id;
239 -- Ada 2005 (AI-254): Create and decorate an internal full type declaration
240 -- in the enclosing scope corresponding to an anonymous access to protected
241 -- subprogram. In addition, replace the anonymous access by an occurrence
242 -- of this internal type. Prev_Etype is used to link the new internal
243 -- entity with the anonymous entity. Return the entity of this type
244 -- declaration.
246 procedure Set_Completion_Referenced (E : Entity_Id);
247 -- If E is the completion of a private or incomplete type declaration,
248 -- or the completion of a deferred constant declaration, mark the entity
249 -- as referenced. Warnings on unused entities, if needed, go on the
250 -- partial view.
252 end Sem_Ch3;