* gimplify.c (find_single_pointer_decl_1): New static function.
[official-gcc.git] / gcc / ada / sem_ch3.ads
blob608666d18e60c7bb1f6d89b1e7d1344061c662e6
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_Per_Use_Expression (N : Node_Id; T : Entity_Id);
66 -- Default and per object expressions do not freeze their components,
67 -- and must be analyzed and resolved accordingly. The analysis is
68 -- done by calling the Pre_Analyze_And_Resolve routine and setting
69 -- the global In_Default_Expression flag. See the documentation section
70 -- entitled "Handling of Default and Per-Object Expressions" in sem.ads
71 -- for details. N is the expression to be analyzed, T is the expected type.
73 procedure Array_Type_Declaration (T : in out Entity_Id; Def : Node_Id);
74 -- Process an array type declaration. If the array is constrained, we
75 -- create an implicit parent array type, with the same index types and
76 -- component type.
78 procedure Access_Type_Declaration (T : Entity_Id; Def : Node_Id);
79 -- Process an access type declaration
81 procedure Check_Abstract_Overriding (T : Entity_Id);
82 -- Check that all abstract subprograms inherited from T's parent type
83 -- have been overridden as required, and that nonabstract subprograms
84 -- have not been incorrectly overridden with an abstract subprogram.
86 procedure Check_Aliased_Component_Types (T : Entity_Id);
87 -- Given an array type or record type T, check that if the type is
88 -- nonlimited, then the nominal subtype of any components of T
89 -- that have discriminants must be constrained.
91 procedure Check_Completion (Body_Id : Node_Id := Empty);
92 -- At the end of a declarative part, verify that all entities that
93 -- require completion have received one. If Body_Id is absent, the
94 -- error indicating a missing completion is placed on the declaration
95 -- that needs completion. If Body_Id is present, it is the defining
96 -- identifier of a package body, and errors are posted on that node,
97 -- rather than on the declarations that require completion in the package
98 -- declaration.
100 procedure Derive_Subprogram
101 (New_Subp : in out Entity_Id;
102 Parent_Subp : Entity_Id;
103 Derived_Type : Entity_Id;
104 Parent_Type : Entity_Id;
105 Actual_Subp : Entity_Id := Empty);
106 -- Derive the subprogram Parent_Subp from Parent_Type, and replace the
107 -- subsidiary subtypes with the derived type to build the specification
108 -- of the inherited subprogram (returned in New_Subp). For tagged types,
109 -- the derived subprogram is aliased to that of the actual (in the
110 -- case where Actual_Subp is nonempty) rather than to the corresponding
111 -- subprogram of the parent type.
113 procedure Derive_Subprograms
114 (Parent_Type : Entity_Id;
115 Derived_Type : Entity_Id;
116 Generic_Actual : Entity_Id := Empty;
117 No_Predefined_Prims : Boolean := False;
118 Predefined_Prims_Only : Boolean := False);
119 -- To complete type derivation, collect/retrieve the primitive operations
120 -- of the parent type, and replace the subsidiary subtypes with the derived
121 -- type, to build the specs of the inherited ops. For generic actuals, the
122 -- mapping of the primitive operations to those of the parent type is also
123 -- done by rederiving the operations within the instance. For tagged types,
124 -- the derived subprograms are aliased to those of the actual, not those of
125 -- the ancestor. The last two params are used in case of derivation from
126 -- abstract interface types: No_Predefined_Prims is used to avoid the
127 -- derivation of predefined primitives from the interface, and Predefined
128 -- Prims_Only is used to complete the derivation predefined primitives
129 -- in case of private tagged types implementing interfaces.
131 -- Note: one might expect this to be private to the package body, but
132 -- there is one rather unusual usage in package Exp_Dist.
134 function Find_Type_Of_Subtype_Indic (S : Node_Id) return Entity_Id;
135 -- Given a subtype indication S (which is really an N_Subtype_Indication
136 -- node or a plain N_Identifier), find the type of the subtype mark.
138 function Find_Type_Name (N : Node_Id) return Entity_Id;
139 -- Enter the identifier in a type definition, or find the entity already
140 -- declared, in the case of the full declaration of an incomplete or
141 -- private type.
143 function Get_Discriminant_Value
144 (Discriminant : Entity_Id;
145 Typ_For_Constraint : Entity_Id;
146 Constraint : Elist_Id) return Node_Id;
147 -- ??? MORE DOCUMENTATION
148 -- Given a discriminant somewhere in the Typ_For_Constraint tree
149 -- and a Constraint, return the value of that discriminant.
151 function Is_Visible_Component (C : Entity_Id) return Boolean;
152 -- Determines if a record component C is visible in the present context.
153 -- Note that even though component C could appear in the entity chain
154 -- of a record type, C may not be visible in the current context. For
155 -- instance, C may be a component inherited in the full view of a private
156 -- extension which is not visible in the current context.
158 procedure Make_Index
159 (I : Node_Id;
160 Related_Nod : Node_Id;
161 Related_Id : Entity_Id := Empty;
162 Suffix_Index : Nat := 1);
163 -- Process an index that is given in an array declaration, an entry
164 -- family declaration or a loop iteration. The index is given by an
165 -- index declaration (a 'box'), or by a discrete range. The later can
166 -- be the name of a discrete type, or a subtype indication.
167 -- Related_Nod is the node where the potential generated implicit types
168 -- will be inserted. The 2 last parameters are used for creating the name.
170 procedure Make_Class_Wide_Type (T : Entity_Id);
171 -- A Class_Wide_Type is created for each tagged type definition. The
172 -- attributes of a class wide type are inherited from those of the type
173 -- T. If T is introduced by a private declaration, the corresponding
174 -- class wide type is created at the same time, and therefore there is
175 -- a private and a full declaration for the class wide type type as well.
177 procedure Process_Full_View (N : Node_Id; Full_T, Priv_T : Entity_Id);
178 -- Process some semantic actions when the full view of a private type is
179 -- encountered and analyzed. The first action is to create the full views
180 -- of the dependant private subtypes. The second action is to recopy the
181 -- primitive operations of the private view (in the tagged case).
182 -- N is the N_Full_Type_Declaration node.
184 -- Full_T is the full view of the type whose full declaration is in N.
186 -- Priv_T is the private view of the type whose full declaration is in N.
188 procedure Process_Range_Expr_In_Decl
189 (R : Node_Id;
190 T : Entity_Id;
191 Check_List : List_Id := Empty_List;
192 R_Check_Off : Boolean := False);
193 -- Process a range expression that appears in a declaration context. The
194 -- range is analyzed and resolved with the base type of the given type,
195 -- and an appropriate check for expressions in non-static contexts made
196 -- on the bounds. R is analyzed and resolved using T, so the caller should
197 -- if necessary link R into the tree before the call, and in particular in
198 -- the case of a subtype declaration, it is appropriate to set the parent
199 -- pointer of R so that the types get properly frozen. The Check_List
200 -- parameter is used when the subprogram is called from
201 -- Build_Record_Init_Proc and is used to return a set of constraint
202 -- checking statements generated by the Checks package. R_Check_Off is
203 -- set to True when the call to Range_Check is to be skipped.
205 function Process_Subtype
206 (S : Node_Id;
207 Related_Nod : Node_Id;
208 Related_Id : Entity_Id := Empty;
209 Suffix : Character := ' ') return Entity_Id;
210 -- Process a subtype indication S and return corresponding entity.
211 -- Related_Nod is the node where the potential generated implicit types
212 -- will be inserted. The Related_Id and Suffix parameters are used to
213 -- build the associated Implicit type name.
215 procedure Process_Discriminants
216 (N : Node_Id;
217 Prev : Entity_Id := Empty);
218 -- Process the discriminants contained in an N_Full_Type_Declaration or
219 -- N_Incomplete_Type_Decl node N. If the declaration is a completion,
220 -- Prev is entity on the partial view, on which references are posted.
222 function Replace_Anonymous_Access_To_Protected_Subprogram
223 (N : Node_Id;
224 Prev_E : Entity_Id) return Entity_Id;
225 -- Ada 2005 (AI-254): Create and decorate an internal full type declaration
226 -- in the enclosing scope corresponding to an anonymous access to protected
227 -- subprogram. In addition, replace the anonymous access by an occurrence
228 -- of this internal type. Prev_Etype is used to link the new internal
229 -- entity with the anonymous entity. Return the entity of this type
230 -- declaration.
232 procedure Set_Completion_Referenced (E : Entity_Id);
233 -- If E is the completion of a private or incomplete type declaration,
234 -- or the completion of a deferred constant declaration, mark the entity
235 -- as referenced. Warnings on unused entities, if needed, go on the
236 -- partial view.
238 end Sem_Ch3;