annotate gcc/cp/parser.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Data structures and function exported by the C++ Parser.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2010-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
7 under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
8 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
9 any later version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but
kono
parents:
diff changeset
12 WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
kono
parents:
diff changeset
14 General Public License for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 #ifndef GCC_CP_PARSER_H
kono
parents:
diff changeset
21 #define GCC_CP_PARSER_H
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 #include "tree.h"
kono
parents:
diff changeset
24 #include "cp/cp-tree.h"
kono
parents:
diff changeset
25 #include "c-family/c-pragma.h"
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 /* A token's value and its associated deferred access checks and
kono
parents:
diff changeset
28 qualifying scope. */
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 struct GTY(()) tree_check {
kono
parents:
diff changeset
31 /* The value associated with the token. */
kono
parents:
diff changeset
32 tree value;
kono
parents:
diff changeset
33 /* The checks that have been associated with value. */
kono
parents:
diff changeset
34 vec<deferred_access_check, va_gc> *checks;
kono
parents:
diff changeset
35 /* The token's qualifying scope (used when it is a
kono
parents:
diff changeset
36 CPP_NESTED_NAME_SPECIFIER). */
kono
parents:
diff changeset
37 tree qualifying_scope;
kono
parents:
diff changeset
38 };
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* A C++ token. */
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 struct GTY (()) cp_token {
kono
parents:
diff changeset
43 /* The kind of token. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
44 enum cpp_ttype type : 8;
111
kono
parents:
diff changeset
45 /* If this token is a keyword, this value indicates which keyword.
kono
parents:
diff changeset
46 Otherwise, this value is RID_MAX. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
47 enum rid keyword : 8;
111
kono
parents:
diff changeset
48 /* Token flags. */
kono
parents:
diff changeset
49 unsigned char flags;
kono
parents:
diff changeset
50 /* True if this token is from a context where it is implicitly extern "C" */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
51 bool implicit_extern_c : 1;
111
kono
parents:
diff changeset
52 /* True if an error has already been reported for this token, such as a
kono
parents:
diff changeset
53 CPP_NAME token that is not a keyword (i.e., for which KEYWORD is
kono
parents:
diff changeset
54 RID_MAX) iff this name was looked up and found to be ambiguous. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
55 bool error_reported : 1;
111
kono
parents:
diff changeset
56 /* True for a token that has been purged. If a token is purged,
kono
parents:
diff changeset
57 it is no longer a valid token and it should be considered
kono
parents:
diff changeset
58 deleted. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
59 bool purged_p : 1;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
60 bool tree_check_p : 1;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
61 /* 4 unused bits. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
62
111
kono
parents:
diff changeset
63 /* The location at which this token was found. */
kono
parents:
diff changeset
64 location_t location;
kono
parents:
diff changeset
65 /* The value associated with this token, if any. */
kono
parents:
diff changeset
66 union cp_token_value {
kono
parents:
diff changeset
67 /* Used for compound tokens such as CPP_NESTED_NAME_SPECIFIER. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
68 struct tree_check* GTY((tag ("true"))) tree_check_value;
111
kono
parents:
diff changeset
69 /* Use for all other tokens. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
70 tree GTY((tag ("false"))) value;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
71 } GTY((desc ("%1.tree_check_p"))) u;
111
kono
parents:
diff changeset
72 };
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 /* We use a stack of token pointer for saving token sets. */
kono
parents:
diff changeset
76 typedef struct cp_token *cp_token_position;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 /* The cp_lexer structure represents the C++ lexer. It is responsible
kono
parents:
diff changeset
79 for managing the token stream from the preprocessor and supplying
kono
parents:
diff changeset
80 it to the parser. Tokens are never added to the cp_lexer after
kono
parents:
diff changeset
81 it is created. */
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 struct GTY (()) cp_lexer {
kono
parents:
diff changeset
84 /* The memory allocated for the buffer. NULL if this lexer does not
kono
parents:
diff changeset
85 own the token buffer. */
kono
parents:
diff changeset
86 vec<cp_token, va_gc> *buffer;
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 /* A pointer just past the last available token. The tokens
kono
parents:
diff changeset
89 in this lexer are [buffer, last_token). */
kono
parents:
diff changeset
90 cp_token_position GTY ((skip)) last_token;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 /* The next available token. If NEXT_TOKEN is &eof_token, then there are
kono
parents:
diff changeset
93 no more available tokens. */
kono
parents:
diff changeset
94 cp_token_position GTY ((skip)) next_token;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 /* A stack indicating positions at which cp_lexer_save_tokens was
kono
parents:
diff changeset
97 called. The top entry is the most recent position at which we
kono
parents:
diff changeset
98 began saving tokens. If the stack is non-empty, we are saving
kono
parents:
diff changeset
99 tokens. */
kono
parents:
diff changeset
100 vec<cp_token_position> GTY ((skip)) saved_tokens;
kono
parents:
diff changeset
101
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
102 /* Saved pieces of end token we replaced with the eof token. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
103 enum cpp_ttype saved_type : 8;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
104 enum rid saved_keyword : 8;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
105
111
kono
parents:
diff changeset
106 /* The next lexer in a linked list of lexers. */
kono
parents:
diff changeset
107 struct cp_lexer *next;
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 /* True if we should output debugging information. */
kono
parents:
diff changeset
110 bool debugging_p;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 /* True if we're in the context of parsing a pragma, and should not
kono
parents:
diff changeset
113 increment past the end-of-line marker. */
kono
parents:
diff changeset
114 bool in_pragma;
kono
parents:
diff changeset
115 };
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 /* cp_token_cache is a range of tokens. There is no need to represent
kono
parents:
diff changeset
119 allocate heap memory for it, since tokens are never removed from the
kono
parents:
diff changeset
120 lexer's array. There is also no need for the GC to walk through
kono
parents:
diff changeset
121 a cp_token_cache, since everything in here is referenced through
kono
parents:
diff changeset
122 a lexer. */
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 struct GTY(()) cp_token_cache {
kono
parents:
diff changeset
125 /* The beginning of the token range. */
kono
parents:
diff changeset
126 cp_token * GTY((skip)) first;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 /* Points immediately after the last token in the range. */
kono
parents:
diff changeset
129 cp_token * GTY ((skip)) last;
kono
parents:
diff changeset
130 };
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 typedef cp_token_cache *cp_token_cache_ptr;
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 struct cp_token_ident
kono
parents:
diff changeset
135 {
kono
parents:
diff changeset
136 unsigned int ident_len;
kono
parents:
diff changeset
137 const char *ident_str;
kono
parents:
diff changeset
138 unsigned int before_len;
kono
parents:
diff changeset
139 const char *before_str;
kono
parents:
diff changeset
140 unsigned int after_len;
kono
parents:
diff changeset
141 const char *after_str;
kono
parents:
diff changeset
142 };
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 /* An entry in a queue of function arguments that require post-processing. */
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 struct GTY(()) cp_default_arg_entry {
kono
parents:
diff changeset
147 /* The current_class_type when we parsed this arg. */
kono
parents:
diff changeset
148 tree class_type;
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 /* The function decl itself. */
kono
parents:
diff changeset
151 tree decl;
kono
parents:
diff changeset
152 };
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 /* An entry in a stack for member functions defined within their classes. */
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 struct GTY(()) cp_unparsed_functions_entry {
kono
parents:
diff changeset
158 /* Functions with default arguments that require post-processing.
kono
parents:
diff changeset
159 Functions appear in this list in declaration order. */
kono
parents:
diff changeset
160 vec<cp_default_arg_entry, va_gc> *funs_with_default_args;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 /* Functions with defintions that require post-processing. Functions
kono
parents:
diff changeset
163 appear in this list in declaration order. */
kono
parents:
diff changeset
164 vec<tree, va_gc> *funs_with_definitions;
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 /* Non-static data members with initializers that require post-processing.
kono
parents:
diff changeset
167 FIELD_DECLs appear in this list in declaration order. */
kono
parents:
diff changeset
168 vec<tree, va_gc> *nsdmis;
kono
parents:
diff changeset
169
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
170 /* Functions with noexcept-specifiers that require post-processing. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
171 vec<tree, va_gc> *noexcepts;
111
kono
parents:
diff changeset
172 };
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 /* The status of a tentative parse. */
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 enum cp_parser_status_kind
kono
parents:
diff changeset
178 {
kono
parents:
diff changeset
179 /* No errors have occurred. */
kono
parents:
diff changeset
180 CP_PARSER_STATUS_KIND_NO_ERROR,
kono
parents:
diff changeset
181 /* An error has occurred. */
kono
parents:
diff changeset
182 CP_PARSER_STATUS_KIND_ERROR,
kono
parents:
diff changeset
183 /* We are committed to this tentative parse, whether or not an error
kono
parents:
diff changeset
184 has occurred. */
kono
parents:
diff changeset
185 CP_PARSER_STATUS_KIND_COMMITTED
kono
parents:
diff changeset
186 };
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 /* Context that is saved and restored when parsing tentatively. */
kono
parents:
diff changeset
190 struct GTY (()) cp_parser_context {
kono
parents:
diff changeset
191 /* If this is a tentative parsing context, the status of the
kono
parents:
diff changeset
192 tentative parse. */
kono
parents:
diff changeset
193 enum cp_parser_status_kind status;
kono
parents:
diff changeset
194 /* If non-NULL, we have just seen a `x->' or `x.' expression. Names
kono
parents:
diff changeset
195 that are looked up in this context must be looked up both in the
kono
parents:
diff changeset
196 scope given by OBJECT_TYPE (the type of `x' or `*x') and also in
kono
parents:
diff changeset
197 the context of the containing expression. */
kono
parents:
diff changeset
198 tree object_type;
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 /* The next parsing context in the stack. */
kono
parents:
diff changeset
201 struct cp_parser_context *next;
kono
parents:
diff changeset
202 };
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
205 /* Helper data structure for parsing #pragma omp declare {simd,variant}. */
111
kono
parents:
diff changeset
206 struct cp_omp_declare_simd_data {
kono
parents:
diff changeset
207 bool error_seen; /* Set if error has been reported. */
kono
parents:
diff changeset
208 bool fndecl_seen; /* Set if one fn decl/definition has been seen already. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
209 bool variant_p; /* Set for #pragma omp declare variant. */
111
kono
parents:
diff changeset
210 vec<cp_token_cache_ptr> tokens;
kono
parents:
diff changeset
211 tree clauses;
kono
parents:
diff changeset
212 };
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 /* Helper data structure for parsing #pragma acc routine. */
kono
parents:
diff changeset
215 struct cp_oacc_routine_data : cp_omp_declare_simd_data {
kono
parents:
diff changeset
216 location_t loc;
kono
parents:
diff changeset
217 };
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 /* The cp_parser structure represents the C++ parser. */
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 struct GTY(()) cp_parser {
kono
parents:
diff changeset
222 /* The lexer from which we are obtaining tokens. */
kono
parents:
diff changeset
223 cp_lexer *lexer;
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 /* The scope in which names should be looked up. If NULL_TREE, then
kono
parents:
diff changeset
226 we look up names in the scope that is currently open in the
kono
parents:
diff changeset
227 source program. If non-NULL, this is either a TYPE or
kono
parents:
diff changeset
228 NAMESPACE_DECL for the scope in which we should look. It can
kono
parents:
diff changeset
229 also be ERROR_MARK, when we've parsed a bogus scope.
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 This value is not cleared automatically after a name is looked
kono
parents:
diff changeset
232 up, so we must be careful to clear it before starting a new look
kono
parents:
diff changeset
233 up sequence. (If it is not cleared, then `X::Y' followed by `Z'
kono
parents:
diff changeset
234 will look up `Z' in the scope of `X', rather than the current
kono
parents:
diff changeset
235 scope.) Unfortunately, it is difficult to tell when name lookup
kono
parents:
diff changeset
236 is complete, because we sometimes peek at a token, look it up,
kono
parents:
diff changeset
237 and then decide not to consume it. */
kono
parents:
diff changeset
238 tree scope;
kono
parents:
diff changeset
239
kono
parents:
diff changeset
240 /* OBJECT_SCOPE and QUALIFYING_SCOPE give the scopes in which the
kono
parents:
diff changeset
241 last lookup took place. OBJECT_SCOPE is used if an expression
kono
parents:
diff changeset
242 like "x->y" or "x.y" was used; it gives the type of "*x" or "x",
kono
parents:
diff changeset
243 respectively. QUALIFYING_SCOPE is used for an expression of the
kono
parents:
diff changeset
244 form "X::Y"; it refers to X. */
kono
parents:
diff changeset
245 tree object_scope;
kono
parents:
diff changeset
246 tree qualifying_scope;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 /* A stack of parsing contexts. All but the bottom entry on the
kono
parents:
diff changeset
249 stack will be tentative contexts.
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 We parse tentatively in order to determine which construct is in
kono
parents:
diff changeset
252 use in some situations. For example, in order to determine
kono
parents:
diff changeset
253 whether a statement is an expression-statement or a
kono
parents:
diff changeset
254 declaration-statement we parse it tentatively as a
kono
parents:
diff changeset
255 declaration-statement. If that fails, we then reparse the same
kono
parents:
diff changeset
256 token stream as an expression-statement. */
kono
parents:
diff changeset
257 cp_parser_context *context;
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 /* True if we are parsing GNU C++. If this flag is not set, then
kono
parents:
diff changeset
260 GNU extensions are not recognized. */
kono
parents:
diff changeset
261 bool allow_gnu_extensions_p;
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 /* TRUE if the `>' token should be interpreted as the greater-than
kono
parents:
diff changeset
264 operator. FALSE if it is the end of a template-id or
kono
parents:
diff changeset
265 template-parameter-list. In C++0x mode, this flag also applies to
kono
parents:
diff changeset
266 `>>' tokens, which are viewed as two consecutive `>' tokens when
kono
parents:
diff changeset
267 this flag is FALSE. */
kono
parents:
diff changeset
268 bool greater_than_is_operator_p;
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 /* TRUE if default arguments are allowed within a parameter list
kono
parents:
diff changeset
271 that starts at this point. FALSE if only a gnu extension makes
kono
parents:
diff changeset
272 them permissible. */
kono
parents:
diff changeset
273 bool default_arg_ok_p;
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 /* TRUE if we are parsing an integral constant-expression. See
kono
parents:
diff changeset
276 [expr.const] for a precise definition. */
kono
parents:
diff changeset
277 bool integral_constant_expression_p;
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 /* TRUE if we are parsing an integral constant-expression -- but a
kono
parents:
diff changeset
280 non-constant expression should be permitted as well. This flag
kono
parents:
diff changeset
281 is used when parsing an array bound so that GNU variable-length
kono
parents:
diff changeset
282 arrays are tolerated. */
kono
parents:
diff changeset
283 bool allow_non_integral_constant_expression_p;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 /* TRUE if ALLOW_NON_CONSTANT_EXPRESSION_P is TRUE and something has
kono
parents:
diff changeset
286 been seen that makes the expression non-constant. */
kono
parents:
diff changeset
287 bool non_integral_constant_expression_p;
kono
parents:
diff changeset
288
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
289 /* Used to track if local variable names and/or `this' are forbidden
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
290 in the current context. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
291 #define LOCAL_VARS_FORBIDDEN (1 << 0)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
292 #define THIS_FORBIDDEN (1 << 1)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
293 #define LOCAL_VARS_AND_THIS_FORBIDDEN (LOCAL_VARS_FORBIDDEN | THIS_FORBIDDEN)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
294 unsigned char local_variables_forbidden_p;
111
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 /* TRUE if the declaration we are parsing is part of a
kono
parents:
diff changeset
297 linkage-specification of the form `extern string-literal
kono
parents:
diff changeset
298 declaration'. */
kono
parents:
diff changeset
299 bool in_unbraced_linkage_specification_p;
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 /* TRUE if we are presently parsing a declarator, after the
kono
parents:
diff changeset
302 direct-declarator. */
kono
parents:
diff changeset
303 bool in_declarator_p;
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 /* TRUE if we are presently parsing a template-argument-list. */
kono
parents:
diff changeset
306 bool in_template_argument_list_p;
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 /* Set to IN_ITERATION_STMT if parsing an iteration-statement,
kono
parents:
diff changeset
309 to IN_OMP_BLOCK if parsing OpenMP structured block and
kono
parents:
diff changeset
310 IN_OMP_FOR if parsing OpenMP loop. If parsing a switch statement,
kono
parents:
diff changeset
311 this is bitwise ORed with IN_SWITCH_STMT, unless parsing an
kono
parents:
diff changeset
312 iteration-statement, OpenMP block or loop within that switch. */
kono
parents:
diff changeset
313 #define IN_SWITCH_STMT 1
kono
parents:
diff changeset
314 #define IN_ITERATION_STMT 2
kono
parents:
diff changeset
315 #define IN_OMP_BLOCK 4
kono
parents:
diff changeset
316 #define IN_OMP_FOR 8
kono
parents:
diff changeset
317 #define IN_IF_STMT 16
kono
parents:
diff changeset
318 unsigned char in_statement;
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 /* TRUE if we are presently parsing the body of a switch statement.
kono
parents:
diff changeset
321 Note that this doesn't quite overlap with in_statement above.
kono
parents:
diff changeset
322 The difference relates to giving the right sets of error messages:
kono
parents:
diff changeset
323 "case not in switch" vs "break statement used with OpenMP...". */
kono
parents:
diff changeset
324 bool in_switch_statement_p;
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 /* TRUE if we are parsing a type-id in an expression context. In
kono
parents:
diff changeset
327 such a situation, both "type (expr)" and "type (type)" are valid
kono
parents:
diff changeset
328 alternatives. */
kono
parents:
diff changeset
329 bool in_type_id_in_expr_p;
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 /* TRUE if strings in expressions should be translated to the execution
kono
parents:
diff changeset
332 character set. */
kono
parents:
diff changeset
333 bool translate_strings_p;
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 /* TRUE if we are presently parsing the body of a function, but not
kono
parents:
diff changeset
336 a local class. */
kono
parents:
diff changeset
337 bool in_function_body;
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 /* Nonzero if we're processing a __transaction_atomic or
kono
parents:
diff changeset
340 __transaction_relaxed statement. */
kono
parents:
diff changeset
341 unsigned char in_transaction;
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 /* TRUE if we can auto-correct a colon to a scope operator. */
kono
parents:
diff changeset
344 bool colon_corrects_to_scope_p;
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 /* TRUE if : doesn't start a class definition. Should be only used
kono
parents:
diff changeset
347 together with type_definition_forbidden_message non-NULL, in
kono
parents:
diff changeset
348 contexts where new types may not be defined, and the type list
kono
parents:
diff changeset
349 is terminated by colon. */
kono
parents:
diff changeset
350 bool colon_doesnt_start_class_def_p;
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 /* If non-NULL, then we are parsing a construct where new type
kono
parents:
diff changeset
353 definitions are not permitted. The string stored here will be
kono
parents:
diff changeset
354 issued as an error message if a type is defined. */
kono
parents:
diff changeset
355 const char *type_definition_forbidden_message;
kono
parents:
diff changeset
356
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
357 /* Argument for type_definition_forbidden_message if needed. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
358 const char *type_definition_forbidden_message_arg;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
359
111
kono
parents:
diff changeset
360 /* A stack used for member functions of local classes. The lists
kono
parents:
diff changeset
361 contained in an individual entry can only be processed once the
kono
parents:
diff changeset
362 outermost class being defined is complete. */
kono
parents:
diff changeset
363 vec<cp_unparsed_functions_entry, va_gc> *unparsed_queues;
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 /* The number of classes whose definitions are currently in
kono
parents:
diff changeset
366 progress. */
kono
parents:
diff changeset
367 unsigned num_classes_being_defined;
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 /* The number of template parameter lists that apply directly to the
kono
parents:
diff changeset
370 current declaration. */
kono
parents:
diff changeset
371 unsigned num_template_parameter_lists;
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 /* When parsing #pragma omp declare simd, this is a pointer to a
kono
parents:
diff changeset
374 helper data structure. */
kono
parents:
diff changeset
375 cp_omp_declare_simd_data * GTY((skip)) omp_declare_simd;
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 /* When parsing #pragma acc routine, this is a pointer to a helper data
kono
parents:
diff changeset
378 structure. */
kono
parents:
diff changeset
379 cp_oacc_routine_data * GTY((skip)) oacc_routine;
kono
parents:
diff changeset
380
kono
parents:
diff changeset
381 /* Nonzero if parsing a parameter list where 'auto' should trigger an implicit
kono
parents:
diff changeset
382 template parameter. */
kono
parents:
diff changeset
383 bool auto_is_implicit_function_template_parm_p;
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 /* TRUE if the function being declared was made a template due to its
kono
parents:
diff changeset
386 parameter list containing generic type specifiers (`auto' or concept
kono
parents:
diff changeset
387 identifiers) rather than an explicit template parameter list. */
kono
parents:
diff changeset
388 bool fully_implicit_function_template_p;
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 /* Tracks the function's template parameter list when declaring a function
kono
parents:
diff changeset
391 using generic type parameters. This is either a new chain in the case of a
kono
parents:
diff changeset
392 fully implicit function template or an extension of the function's existing
kono
parents:
diff changeset
393 template parameter list. This is tracked to optimize calls subsequent
kono
parents:
diff changeset
394 calls to synthesize_implicit_template_parm during
kono
parents:
diff changeset
395 cp_parser_parameter_declaration. */
kono
parents:
diff changeset
396 tree implicit_template_parms;
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 /* The scope into which an implicit template parameter list has been
kono
parents:
diff changeset
399 introduced or an existing template parameter list is being extended with
kono
parents:
diff changeset
400 implicit template parameters. In most cases this is the sk_function_parms
kono
parents:
diff changeset
401 scope containing the use of a generic type. In the case of an out-of-line
kono
parents:
diff changeset
402 member definition using a generic type, it is the sk_class scope. */
kono
parents:
diff changeset
403 cp_binding_level* implicit_template_scope;
kono
parents:
diff changeset
404
kono
parents:
diff changeset
405 /* True if parsing a result type in a compound requirement. This permits
kono
parents:
diff changeset
406 constrained-type-specifiers inside what would normally be a trailing
kono
parents:
diff changeset
407 return type. */
kono
parents:
diff changeset
408 bool in_result_type_constraint_p;
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 /* True if a constrained-type-specifier is not allowed in this
kono
parents:
diff changeset
411 context e.g., because they could never be deduced. */
kono
parents:
diff changeset
412 int prevent_constrained_type_specifiers;
kono
parents:
diff changeset
413
kono
parents:
diff changeset
414 /* Location of the string-literal token within the current linkage
kono
parents:
diff changeset
415 specification, if any, or UNKNOWN_LOCATION otherwise. */
kono
parents:
diff changeset
416 location_t innermost_linkage_specification_location;
kono
parents:
diff changeset
417
kono
parents:
diff changeset
418 };
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 /* In parser.c */
kono
parents:
diff changeset
421 extern void debug (cp_token &ref);
kono
parents:
diff changeset
422 extern void debug (cp_token *ptr);
kono
parents:
diff changeset
423 extern void cp_lexer_debug_tokens (vec<cp_token, va_gc> *);
kono
parents:
diff changeset
424 extern void debug (vec<cp_token, va_gc> &ref);
kono
parents:
diff changeset
425 extern void debug (vec<cp_token, va_gc> *ptr);
kono
parents:
diff changeset
426 extern void cp_debug_parser (FILE *, cp_parser *);
kono
parents:
diff changeset
427 extern void debug (cp_parser &ref);
kono
parents:
diff changeset
428 extern void debug (cp_parser *ptr);
kono
parents:
diff changeset
429 extern bool cp_keyword_starts_decl_specifier_p (enum rid keyword);
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 #endif /* GCC_CP_PARSER_H */