annotate gcc/ada/sem_res.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S E M _ R E S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- Resolution processing for all subexpression nodes. Note that the separate
kono
parents:
diff changeset
27 -- package Sem_Aggr contains the actual resolution routines for aggregates,
kono
parents:
diff changeset
28 -- which are separated off since aggregate processing is complex.
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 with Types; use Types;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 package Sem_Res is
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 -- As described in Sem_Ch4, the type resolution proceeds in two phases.
kono
parents:
diff changeset
35 -- The first phase is a bottom up pass that is achieved during the
kono
parents:
diff changeset
36 -- recursive traversal performed by the Analyze procedures. This phase
kono
parents:
diff changeset
37 -- determines unambiguous types, and collects sets of possible types
kono
parents:
diff changeset
38 -- where the interpretation is potentially ambiguous.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 -- On completing this bottom up pass, which corresponds to a call to
kono
parents:
diff changeset
41 -- Analyze on a complete context, the Resolve routine is called which
kono
parents:
diff changeset
42 -- performs a top down resolution with recursive calls to itself to
kono
parents:
diff changeset
43 -- resolve operands.
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 -- Since in practice a lot of semantic analysis has to be postponed until
kono
parents:
diff changeset
46 -- types are known (e.g. static folding, setting of suppress flags), the
kono
parents:
diff changeset
47 -- Resolve routines also complete the semantic analysis, and call the
kono
parents:
diff changeset
48 -- expander for possible expansion of the completely type resolved node.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 procedure Ambiguous_Character (C : Node_Id);
kono
parents:
diff changeset
51 -- Give list of candidate interpretations when a character literal cannot
kono
parents:
diff changeset
52 -- be resolved, for example in a (useless) comparison such as 'A' = 'B'.
kono
parents:
diff changeset
53 -- In Ada 95 the literals in question can be of type Character or Wide_
kono
parents:
diff changeset
54 -- Character. In Ada 2005 Wide_Wide_Character is also a candidate. The
kono
parents:
diff changeset
55 -- node may also be overloaded with user-defined character types.
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 procedure Analyze_And_Resolve (N : Node_Id);
kono
parents:
diff changeset
58 procedure Analyze_And_Resolve (N : Node_Id; Typ : Entity_Id);
kono
parents:
diff changeset
59 procedure Analyze_And_Resolve
kono
parents:
diff changeset
60 (N : Node_Id;
kono
parents:
diff changeset
61 Typ : Entity_Id;
kono
parents:
diff changeset
62 Suppress : Check_Id);
kono
parents:
diff changeset
63 procedure Analyze_And_Resolve
kono
parents:
diff changeset
64 (N : Node_Id;
kono
parents:
diff changeset
65 Suppress : Check_Id);
kono
parents:
diff changeset
66 -- These routines combine the effect of Analyze and Resolve. If a Suppress
kono
parents:
diff changeset
67 -- argument is present, then the analysis is done with the specified check
kono
parents:
diff changeset
68 -- suppressed (can be All_Checks to suppress all checks). These checks are
kono
parents:
diff changeset
69 -- suppressed for both the analysis and resolution. If the type argument
kono
parents:
diff changeset
70 -- is not present, then the Etype of the expression after the Analyze
kono
parents:
diff changeset
71 -- call is used for the Resolve.
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 procedure Check_Parameterless_Call (N : Node_Id);
kono
parents:
diff changeset
74 -- Several forms of names can denote calls to entities without parameters.
kono
parents:
diff changeset
75 -- The context determines whether the name denotes the entity or a call to
kono
parents:
diff changeset
76 -- it. When it is a call, the node must be rebuilt accordingly and
kono
parents:
diff changeset
77 -- reanalyzed to obtain possible interpretations.
kono
parents:
diff changeset
78 --
kono
parents:
diff changeset
79 -- The name may be that of an overloadable construct, or it can be an
kono
parents:
diff changeset
80 -- explicit dereference of a prefix that denotes an access to subprogram.
kono
parents:
diff changeset
81 -- In that case, we want to convert the name into a call only if the
kono
parents:
diff changeset
82 -- context requires the return type of the subprogram. Finally, a
kono
parents:
diff changeset
83 -- parameterless protected subprogram appears as a selected component.
kono
parents:
diff changeset
84 --
kono
parents:
diff changeset
85 -- The parameter T is the Typ for the corresponding resolve call.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure Preanalyze_And_Resolve (N : Node_Id; T : Entity_Id);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
88 -- Performs a preanalysis of expression node N. During preanalysis, N is
111
kono
parents:
diff changeset
89 -- analyzed and then resolved against type T, but no expansion is carried
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
90 -- out for N or its children. For more info on preanalysis read the spec
111
kono
parents:
diff changeset
91 -- of Sem.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Preanalyze_And_Resolve (N : Node_Id);
kono
parents:
diff changeset
94 -- Same, but use type of node because context does not impose a single type
kono
parents:
diff changeset
95
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
96 procedure Preanalyze_With_Freezing_And_Resolve (N : Node_Id; T : Entity_Id);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
97 -- Same, but perform freezing of static expressions of N or its children.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
98
111
kono
parents:
diff changeset
99 procedure Resolve (N : Node_Id; Typ : Entity_Id);
kono
parents:
diff changeset
100 procedure Resolve (N : Node_Id; Typ : Entity_Id; Suppress : Check_Id);
kono
parents:
diff changeset
101 -- Top-level type-checking procedure, called in a complete context. The
kono
parents:
diff changeset
102 -- construct N, which is a subexpression, has already been analyzed, and
kono
parents:
diff changeset
103 -- is required to be of type Typ given the analysis of the context (which
kono
parents:
diff changeset
104 -- uses the information gathered on the bottom-up phase in Analyze). The
kono
parents:
diff changeset
105 -- resolve routines do various other processing, e.g. static evaluation.
kono
parents:
diff changeset
106 -- If a Suppress argument is present, then the resolution is done with the
kono
parents:
diff changeset
107 -- specified check suppressed (can be All_Checks to suppress all checks).
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 procedure Resolve (N : Node_Id);
kono
parents:
diff changeset
110 -- A version of Resolve where the type to be used for resolution is taken
kono
parents:
diff changeset
111 -- from the Etype (N). This is commonly used in cases where the context
kono
parents:
diff changeset
112 -- does not add anything and the first pass of analysis found the correct
kono
parents:
diff changeset
113 -- expected type.
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 procedure Resolve_Discrete_Subtype_Indication
kono
parents:
diff changeset
116 (N : Node_Id;
kono
parents:
diff changeset
117 Typ : Entity_Id);
kono
parents:
diff changeset
118 -- Resolve subtype indications in choices (case statements and aggregates)
kono
parents:
diff changeset
119 -- and in index constraints. Note that the resulting Etype of the subtype_
kono
parents:
diff changeset
120 -- indication node is set to the Etype of the contained range (i.e. an
kono
parents:
diff changeset
121 -- Itype is not constructed for the actual subtype).
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Resolve_Entry (Entry_Name : Node_Id);
kono
parents:
diff changeset
124 -- Find name of entry being called, and resolve prefix of name with its
kono
parents:
diff changeset
125 -- own type. For now we assume that the prefix cannot be overloaded and
kono
parents:
diff changeset
126 -- the name of the entry plays no role in the resolution.
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 function Valid_Conversion
kono
parents:
diff changeset
129 (N : Node_Id;
kono
parents:
diff changeset
130 Target : Entity_Id;
kono
parents:
diff changeset
131 Operand : Node_Id;
kono
parents:
diff changeset
132 Report_Errs : Boolean := True) return Boolean;
kono
parents:
diff changeset
133 -- Verify legality rules given in 4.6 (8-23). Target is the target type
kono
parents:
diff changeset
134 -- of the conversion, which may be an implicit conversion of an actual
kono
parents:
diff changeset
135 -- parameter to an anonymous access type (in which case N denotes the
kono
parents:
diff changeset
136 -- actual parameter and N = Operand). Returns a Boolean result indicating
kono
parents:
diff changeset
137 -- whether the conversion is legal. Reports errors in the case of illegal
kono
parents:
diff changeset
138 -- conversions, unless Report_Errs is False.
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 private
kono
parents:
diff changeset
141 procedure Resolve_Implicit_Type (N : Node_Id) renames Resolve;
kono
parents:
diff changeset
142 pragma Inline (Resolve_Implicit_Type);
kono
parents:
diff changeset
143 -- We use this renaming to make the application of Inline very explicit to
kono
parents:
diff changeset
144 -- this version, since other versions of Resolve are not inlined.
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 end Sem_Res;