* config/linux/x86/futex_bits.h (sys_futex0) [__x86_64__]: Change
[official-gcc.git] / gcc / ada / sem_ch6.ads
blob427559e527baa6b195a4d598357070438071a491
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E M _ C H 6 --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2015, 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 with Types; use Types;
27 package Sem_Ch6 is
29 type Conformance_Type is
30 (Type_Conformant, Mode_Conformant, Subtype_Conformant, Fully_Conformant);
31 pragma Ordered (Conformance_Type);
32 -- Conformance type used in conformance checks between specs and bodies,
33 -- and for overriding. The literals match the RM definitions of the
34 -- corresponding terms. This is an ordered type, since each conformance
35 -- type is stronger than the ones preceding it.
37 procedure Analyze_Abstract_Subprogram_Declaration (N : Node_Id);
38 procedure Analyze_Expression_Function (N : Node_Id);
39 procedure Analyze_Extended_Return_Statement (N : Node_Id);
40 procedure Analyze_Function_Call (N : Node_Id);
41 procedure Analyze_Operator_Symbol (N : Node_Id);
42 procedure Analyze_Parameter_Association (N : Node_Id);
43 procedure Analyze_Procedure_Call (N : Node_Id);
44 procedure Analyze_Simple_Return_Statement (N : Node_Id);
45 procedure Analyze_Subprogram_Declaration (N : Node_Id);
46 procedure Analyze_Subprogram_Body (N : Node_Id);
48 procedure Analyze_Subprogram_Body_Contract (Body_Id : Entity_Id);
49 -- Analyze all delayed aspects chained on the contract of subprogram body
50 -- Body_Id as if they appeared at the end of a declarative region. Aspects
51 -- in question are:
52 -- Contract_Cases (stand alone body)
53 -- Depends (stand alone body)
54 -- Global (stand alone body)
55 -- Postcondition (stand alone body)
56 -- Precondition (stand alone body)
57 -- Refined_Depends
58 -- Refined_Global
59 -- Refined_Post
60 -- Test_Case (stand alone body)
62 procedure Analyze_Subprogram_Contract (Subp_Id : Entity_Id);
63 -- Analyze all delayed aspects chained on the contract of subprogram
64 -- Subp_Id as if they appeared at the end of a declarative region. The
65 -- aspects in question are:
66 -- Contract_Cases
67 -- Depends
68 -- Global
69 -- Postcondition
70 -- Precondition
71 -- Test_Case
73 function Analyze_Subprogram_Specification (N : Node_Id) return Entity_Id;
74 -- Analyze subprogram specification in both subprogram declarations
75 -- and body declarations. Returns the defining entity for the
76 -- specification N.
78 procedure Check_Conventions (Typ : Entity_Id);
79 -- Ada 2005 (AI-430): Check that the conventions of all inherited and
80 -- overridden dispatching operations of type Typ are consistent with their
81 -- respective counterparts.
83 procedure Check_Delayed_Subprogram (Designator : Entity_Id);
84 -- Designator can be a E_Subprogram_Type, E_Procedure or E_Function. If a
85 -- type in its profile depends on a private type without a full
86 -- declaration, indicate that the subprogram or type is delayed.
88 procedure Check_Discriminant_Conformance
89 (N : Node_Id;
90 Prev : Entity_Id;
91 Prev_Loc : Node_Id);
92 -- Check that the discriminants of a full type N fully conform to the
93 -- discriminants of the corresponding partial view Prev. Prev_Loc indicates
94 -- the source location of the partial view, which may be different than
95 -- Prev in the case of private types.
97 procedure Check_Fully_Conformant
98 (New_Id : Entity_Id;
99 Old_Id : Entity_Id;
100 Err_Loc : Node_Id := Empty);
101 -- Check that two callable entities (subprograms, entries, literals)
102 -- are fully conformant, post error message if not (RM 6.3.1(17)) with
103 -- the flag being placed on the Err_Loc node if it is specified, and
104 -- on the appropriate component of the New_Id construct if not. Note:
105 -- when checking spec/body conformance, New_Id must be the body entity
106 -- and Old_Id is the spec entity (the code in the implementation relies
107 -- on this ordering, and in any case, this makes sense, since if flags
108 -- are to be placed on the construct, they clearly belong on the body.
110 procedure Check_Mode_Conformant
111 (New_Id : Entity_Id;
112 Old_Id : Entity_Id;
113 Err_Loc : Node_Id := Empty;
114 Get_Inst : Boolean := False);
115 -- Check that two callable entities (subprograms, entries, literals)
116 -- are mode conformant, post error message if not (RM 6.3.1(15)) with
117 -- the flag being placed on the Err_Loc node if it is specified, and
118 -- on the appropriate component of the New_Id construct if not. The
119 -- argument Get_Inst is set to True when this is a check against a
120 -- formal access-to-subprogram type, indicating that mapping of types
121 -- is needed.
123 procedure Check_Overriding_Indicator
124 (Subp : Entity_Id;
125 Overridden_Subp : Entity_Id;
126 Is_Primitive : Boolean);
127 -- Verify the consistency of an overriding_indicator given for subprogram
128 -- declaration, body, renaming, or instantiation. Overridden_Subp is set
129 -- if the scope where we are introducing the subprogram contains a
130 -- type-conformant subprogram that becomes hidden by the new subprogram.
131 -- Is_Primitive indicates whether the subprogram is primitive.
133 procedure Check_Subtype_Conformant
134 (New_Id : Entity_Id;
135 Old_Id : Entity_Id;
136 Err_Loc : Node_Id := Empty;
137 Skip_Controlling_Formals : Boolean := False;
138 Get_Inst : Boolean := False);
139 -- Check that two callable entities (subprograms, entries, literals)
140 -- are subtype conformant, post error message if not (RM 6.3.1(16)),
141 -- the flag being placed on the Err_Loc node if it is specified, and
142 -- on the appropriate component of the New_Id construct if not.
143 -- Skip_Controlling_Formals is True when checking the conformance of
144 -- a subprogram that implements an interface operation. In that case,
145 -- only the non-controlling formals can (and must) be examined. The
146 -- argument Get_Inst is set to True when this is a check against a
147 -- formal access-to-subprogram type, indicating that mapping of types
148 -- is needed.
150 procedure Check_Type_Conformant
151 (New_Id : Entity_Id;
152 Old_Id : Entity_Id;
153 Err_Loc : Node_Id := Empty);
154 -- Check that two callable entities (subprograms, entries, literals)
155 -- are type conformant, post error message if not (RM 6.3.1(14)) with
156 -- the flag being placed on the Err_Loc node if it is specified, and
157 -- on the appropriate component of the New_Id construct if not.
159 function Conforming_Types
160 (T1 : Entity_Id;
161 T2 : Entity_Id;
162 Ctype : Conformance_Type;
163 Get_Inst : Boolean := False) return Boolean;
164 -- Check that the types of two formal parameters are conforming. In most
165 -- cases this is just a name comparison, but within an instance it involves
166 -- generic actual types, and in the presence of anonymous access types
167 -- it must examine the designated types. The argument Get_Inst is set to
168 -- True when this is a check against a formal access-to-subprogram type,
169 -- indicating that mapping of types is needed.
171 procedure Create_Extra_Formals (E : Entity_Id);
172 -- For each parameter of a subprogram or entry that requires an additional
173 -- formal (such as for access parameters and indefinite discriminated
174 -- parameters), creates the appropriate formal and attach it to its
175 -- associated parameter. Each extra formal will also be appended to
176 -- the end of Subp's parameter list (with each subsequent extra formal
177 -- being attached to the preceding extra formal).
179 function Find_Corresponding_Spec
180 (N : Node_Id;
181 Post_Error : Boolean := True) return Entity_Id;
182 -- Use the subprogram specification in the body to retrieve the previous
183 -- subprogram declaration, if any.
185 function Fully_Conformant (New_Id, Old_Id : Entity_Id) return Boolean;
186 -- Determine whether two callable entities (subprograms, entries,
187 -- literals) are fully conformant (RM 6.3.1(17))
189 function Fully_Conformant_Expressions
190 (Given_E1 : Node_Id;
191 Given_E2 : Node_Id) return Boolean;
192 -- Determines if two (non-empty) expressions are fully conformant
193 -- as defined by (RM 6.3.1(18-21))
195 function Fully_Conformant_Discrete_Subtypes
196 (Given_S1 : Node_Id;
197 Given_S2 : Node_Id) return Boolean;
198 -- Determines if two subtype definitions are fully conformant. Used
199 -- for entry family conformance checks (RM 6.3.1 (24)).
201 procedure Install_Entity (E : Entity_Id);
202 -- Place a single entity on the visibility chain
204 procedure Install_Formals (Id : Entity_Id);
205 -- On entry to a subprogram body, make the formals visible. Note that
206 -- simply placing the subprogram on the scope stack is not sufficient:
207 -- the formals must become the current entities for their names. This
208 -- procedure is also used to get visibility to the formals when analyzing
209 -- preconditions and postconditions appearing in the spec.
211 function Is_Interface_Conformant
212 (Tagged_Type : Entity_Id;
213 Iface_Prim : Entity_Id;
214 Prim : Entity_Id) return Boolean;
215 -- Returns true if both primitives have a matching name (including support
216 -- for names of inherited private primitives --which have suffix 'P'), they
217 -- are type conformant, and Prim is defined in the scope of Tagged_Type.
218 -- Special management is done for functions returning interfaces.
220 procedure List_Inherited_Pre_Post_Aspects (E : Entity_Id);
221 -- E is the entity for a subprogram or generic subprogram spec. This call
222 -- lists all inherited Pre/Post aspects if List_Inherited_Pre_Post is True.
224 procedure May_Need_Actuals (Fun : Entity_Id);
225 -- Flag functions that can be called without parameters, i.e. those that
226 -- have no parameters, or those for which defaults exist for all parameters
227 -- Used for subprogram declarations and for access subprogram declarations,
228 -- where they apply to the anonymous designated type. On return the flag
229 -- Set_Needs_No_Actuals is set appropriately in Fun.
231 function Mode_Conformant (New_Id, Old_Id : Entity_Id) return Boolean;
232 -- Determine whether two callable entities (subprograms, entries,
233 -- literals) are mode conformant (RM 6.3.1(15))
235 procedure New_Overloaded_Entity
236 (S : Entity_Id;
237 Derived_Type : Entity_Id := Empty);
238 -- Process new overloaded entity. Overloaded entities are created by
239 -- enumeration type declarations, subprogram specifications, entry
240 -- declarations, and (implicitly) by type derivations. If Derived_Type
241 -- is non-empty then this is a subprogram derived for that type.
243 procedure Process_Formals (T : List_Id; Related_Nod : Node_Id);
244 -- Enter the formals in the scope of the subprogram or entry, and
245 -- analyze default expressions if any. The implicit types created for
246 -- access parameter are attached to the Related_Nod which comes from the
247 -- context.
249 procedure Reference_Body_Formals (Spec : Entity_Id; Bod : Entity_Id);
250 -- If there is a separate spec for a subprogram or generic subprogram, the
251 -- formals of the body are treated as references to the corresponding
252 -- formals of the spec. This reference does not count as an actual use of
253 -- the formal, in order to diagnose formals that are unused in the body.
254 -- This procedure is also used in renaming_as_body declarations, where
255 -- the formals of the specification must be treated as body formals that
256 -- correspond to the previous subprogram declaration, and not as new
257 -- entities with their defining entry in the cross-reference information.
259 procedure Set_Actual_Subtypes (N : Node_Id; Subp : Entity_Id);
260 -- If the formals of a subprogram are unconstrained, build a subtype
261 -- declaration that uses the bounds or discriminants of the actual to
262 -- construct an actual subtype for them. This is an optimization that
263 -- is done only in some cases where the actual subtype cannot change
264 -- during execution of the subprogram. By setting the actual subtype
265 -- once, we avoid recomputing it unnecessarily.
267 procedure Set_Formal_Mode (Formal_Id : Entity_Id);
268 -- Set proper Ekind to reflect formal mode (in, out, in out)
270 function Subtype_Conformant
271 (New_Id : Entity_Id;
272 Old_Id : Entity_Id;
273 Skip_Controlling_Formals : Boolean := False) return Boolean;
274 -- Determine whether two callable entities (subprograms, entries, literals)
275 -- are subtype conformant (RM 6.3.1(16)). Skip_Controlling_Formals is True
276 -- when checking the conformance of a subprogram that implements an
277 -- interface operation. In that case, only the non-controlling formals
278 -- can (and must) be examined.
280 function Type_Conformant
281 (New_Id : Entity_Id;
282 Old_Id : Entity_Id;
283 Skip_Controlling_Formals : Boolean := False) return Boolean;
284 -- Determine whether two callable entities (subprograms, entries, literals)
285 -- are type conformant (RM 6.3.1(14)). Skip_Controlling_Formals is True
286 -- when checking the conformance of a subprogram that implements an
287 -- interface operation. In that case, only the non-controlling formals
288 -- can (and must) be examined.
290 procedure Valid_Operator_Definition (Designator : Entity_Id);
291 -- Verify that an operator definition has the proper number of formals
293 end Sem_Ch6;