2005-12-29 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / ada / sem_res.ads
blobf1a098f2c7af8e673833b53037da4ae148d60b05
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E M _ R E S --
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 -- Resolution processing for all subexpression nodes. Note that the separate
28 -- package Sem_Aggr contains the actual resolution routines for aggregates,
29 -- which are separated off since aggregate processing is complex.
31 with Types; use Types;
33 package Sem_Res is
35 -- As described in Sem_Ch4, the type resolution proceeds in two phases.
36 -- The first phase is a bottom up pass that is achieved during the
37 -- recursive traversal performed by the Analyze procedures. This phase
38 -- determines unambiguous types, and collects sets of possible types
39 -- where the interpretation is potentially ambiguous.
41 -- On completing this bottom up pass, which corresponds to a call to
42 -- Analyze on a complete context, the Resolve routine is called which
43 -- performs a top down resolution with recursive calls to itself to
44 -- resolve operands.
46 -- Since in practice a lot of semantic analysis has to be postponed until
47 -- types are known (e.g. static folding, setting of suppress flags), the
48 -- Resolve routines also complete the semantic analysis, and call the
49 -- expander for possibly expansion of the completely type resolved node.
51 procedure Resolve (N : Node_Id; Typ : Entity_Id);
52 procedure Resolve (N : Node_Id; Typ : Entity_Id; Suppress : Check_Id);
53 -- Top level type-checking procedure, called in a complete context. The
54 -- construct N, which is a subexpression, has already been analyzed, and
55 -- is required to be of type Typ given the analysis of the context (which
56 -- uses the information gathered on the bottom up phase in Analyze). The
57 -- resolve routines do various other processing, e.g. static evaluation.
58 -- If a Suppress argument is present, then the resolution is done with the
59 -- specified check suppressed (can be All_Checks to suppress all checks).
61 procedure Resolve (N : Node_Id);
62 -- A version of Resolve where the type to be used for resolution is
63 -- taken from the Etype (N). This is commonly used in cases where the
64 -- context does not add anything and the first pass of analysis found
65 -- the correct expected type.
67 procedure Resolve_Discrete_Subtype_Indication
68 (N : Node_Id;
69 Typ : Entity_Id);
70 -- Resolve subtype indications in choices (case statements and
71 -- aggregates) and in index constraints. Note that the resulting Etype
72 -- of the subtype indication node is set to the Etype of the contained
73 -- range (i.e. an Itype is not constructed for the actual subtype).
75 procedure Resolve_Entry (Entry_Name : Node_Id);
76 -- Find name of entry being called, and resolve prefix of name with its
77 -- own type. For now we assume that the prefix cannot be overloaded and
78 -- the name of the entry plays no role in the resolution.
80 procedure Analyze_And_Resolve (N : Node_Id);
81 procedure Analyze_And_Resolve (N : Node_Id; Typ : Entity_Id);
82 procedure Analyze_And_Resolve
83 (N : Node_Id;
84 Typ : Entity_Id;
85 Suppress : Check_Id);
86 procedure Analyze_And_Resolve
87 (N : Node_Id;
88 Suppress : Check_Id);
89 -- These routines combine the effect of Analyze and Resolve. If a Suppress
90 -- argument is present, then the analysis is done with the specified check
91 -- suppressed (can be All_Checks to suppress all checks). These checks are
92 -- suppressed for both the analysis and resolution. If the type argument
93 -- is not present, then the Etype of the expression after the Analyze
94 -- call is used for the Resolve.
96 procedure Check_Parameterless_Call (N : Node_Id);
97 -- Several forms of names can denote calls to entities without para-
98 -- meters. The context determines whether the name denotes the entity
99 -- or a call to it. When it is a call, the node must be rebuilt
100 -- accordingly and renalyzed to obtain possible interpretations.
102 -- The name may be that of an overloadable construct, or it can be an
103 -- explicit dereference of a prefix that denotes an access to subprogram.
104 -- In that case, we want to convert the name into a call only if the
105 -- context requires the return type of the subprogram. Finally, a
106 -- parameterless protected subprogram appears as a selected component.
108 -- The parameter T is the Typ for the corresponding resolve call.
110 procedure Pre_Analyze_And_Resolve (N : Node_Id; T : Entity_Id);
111 -- Performs a pre-analysis of expression node N. During pre-analysis
112 -- N is analyzed and then resolved against type T, but no expansion
113 -- is carried out for N or its children. For more info on pre-analysis
114 -- read the spec of Sem.
116 procedure Pre_Analyze_And_Resolve (N : Node_Id);
117 -- Same, but use type of node because context does not impose a single
118 -- type.
120 private
121 procedure Resolve_Implicit_Type (N : Node_Id) renames Resolve;
122 pragma Inline (Resolve_Implicit_Type);
123 -- We use this renaming to make the application of Inline very explicit
124 -- to this version, since other versions of Resolve are not inlined.
126 end Sem_Res;