]>
Commit | Line | Data |
---|---|---|
8d08fdba | 1 | /* YACC parser for C++ syntax. |
357a4089 | 2 | Copyright (C) 1988, 89, 93, 94, 95, 1996 Free Software Foundation, Inc. |
8d08fdba MS |
3 | Hacked by Michael Tiemann (tiemann@cygnus.com) |
4 | ||
5 | This file is part of GNU CC. | |
6 | ||
7 | GNU CC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GNU CC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GNU CC; see the file COPYING. If not, write to | |
e9fa0c7c RK |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
8d08fdba MS |
21 | |
22 | ||
23 | /* This grammar is based on the GNU CC grammar. */ | |
24 | ||
25 | /* Note: Bison automatically applies a default action of "$$ = $1" for | |
26 | all derivations; this is applied before the explicit action, if one | |
27 | is given. Keep this in mind when reading the actions. */ | |
28 | ||
8d08fdba | 29 | %{ |
8926095f | 30 | /* Cause the `yydebug' variable to be defined. */ |
8d08fdba | 31 | #define YYDEBUG 1 |
8d08fdba MS |
32 | |
33 | #include "config.h" | |
34 | ||
35 | #include <stdio.h> | |
36 | #include <errno.h> | |
37 | ||
38 | #include "tree.h" | |
39 | #include "input.h" | |
40 | #include "flags.h" | |
41 | #include "lex.h" | |
42 | #include "cp-tree.h" | |
e8abc66f | 43 | #include "output.h" |
49c249e1 | 44 | #include "except.h" |
8d08fdba MS |
45 | |
46 | /* Since parsers are distinct for each language, put the language string | |
47 | definition here. (fnf) */ | |
48 | char *language_string = "GNU C++"; | |
49 | ||
50 | extern tree void_list_node; | |
51 | extern struct obstack permanent_obstack; | |
52 | ||
53 | #ifndef errno | |
54 | extern int errno; | |
55 | #endif | |
56 | ||
57 | extern int end_of_file; | |
a28e3c7f | 58 | extern int current_class_depth; |
5566b478 | 59 | extern tree last_tree; |
8d08fdba | 60 | |
37539f4f MS |
61 | /* FSF LOCAL dje prefix attributes */ |
62 | extern tree strip_attrs PROTO((tree)); | |
63 | /* END FSF LOCAL */ | |
64 | ||
8d08fdba MS |
65 | /* Like YYERROR but do call yyerror. */ |
66 | #define YYERROR1 { yyerror ("syntax error"); YYERROR; } | |
67 | ||
a28e3c7f MS |
68 | #define OP0(NODE) (TREE_OPERAND (NODE, 0)) |
69 | #define OP1(NODE) (TREE_OPERAND (NODE, 1)) | |
70 | ||
8d08fdba MS |
71 | /* Contains the statement keyword (if/while/do) to include in an |
72 | error message if the user supplies an empty conditional expression. */ | |
73 | static char *cond_stmt_keyword; | |
74 | ||
49c249e1 JM |
75 | static tree empty_parms PROTO((void)); |
76 | ||
8d08fdba MS |
77 | /* Nonzero if we have an `extern "C"' acting as an extern specifier. */ |
78 | int have_extern_spec; | |
79 | int used_extern_spec; | |
80 | ||
8d08fdba MS |
81 | /* Cons up an empty parameter list. */ |
82 | #ifdef __GNUC__ | |
83 | __inline | |
84 | #endif | |
85 | static tree | |
86 | empty_parms () | |
87 | { | |
88 | tree parms; | |
89 | ||
67d743fe | 90 | if (strict_prototype |
8eeda2ec | 91 | || current_class_type != NULL) |
8d08fdba MS |
92 | parms = void_list_node; |
93 | else | |
94 | parms = NULL_TREE; | |
95 | return parms; | |
96 | } | |
97 | %} | |
98 | ||
99 | %start program | |
100 | ||
46b02c6d | 101 | %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; } |
8d08fdba MS |
102 | |
103 | /* All identifiers that are not reserved words | |
104 | and are not declared typedefs in the current block */ | |
105 | %token IDENTIFIER | |
106 | ||
107 | /* All identifiers that are declared typedefs in the current block. | |
108 | In some contexts, they are treated just like IDENTIFIER, | |
109 | but they can also serve as typespecs in declarations. */ | |
110 | %token TYPENAME | |
a80e4195 | 111 | %token SELFNAME |
8d08fdba | 112 | |
8d08fdba MS |
113 | /* Reserved words that specify storage class. |
114 | yylval contains an IDENTIFIER_NODE which indicates which one. */ | |
115 | %token SCSPEC | |
116 | ||
117 | /* Reserved words that specify type. | |
118 | yylval contains an IDENTIFIER_NODE which indicates which one. */ | |
119 | %token TYPESPEC | |
120 | ||
121 | /* Reserved words that qualify type: "const" or "volatile". | |
122 | yylval contains an IDENTIFIER_NODE which indicates which one. */ | |
c11b6f21 | 123 | %token CV_QUALIFIER |
8d08fdba MS |
124 | |
125 | /* Character or numeric constants. | |
126 | yylval is the node for the constant. */ | |
127 | %token CONSTANT | |
128 | ||
129 | /* String constants in raw form. | |
130 | yylval is a STRING_CST node. */ | |
131 | %token STRING | |
132 | ||
133 | /* "...", used for functions with variable arglists. */ | |
134 | %token ELLIPSIS | |
135 | ||
136 | /* the reserved words */ | |
e92cc029 | 137 | /* SCO include files test "ASM", so use something else. */ |
8d08fdba MS |
138 | %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT |
139 | %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD GCC_ASM_KEYWORD TYPEOF ALIGNOF | |
f30432d7 | 140 | %token SIGOF |
8d08fdba | 141 | %token ATTRIBUTE EXTENSION LABEL |
37c46b43 | 142 | %token REALPART IMAGPART |
8d08fdba MS |
143 | |
144 | /* the reserved words... C++ extensions */ | |
145 | %token <ttype> AGGR | |
be99da77 | 146 | %token <ttype> VISSPEC |
d22c8596 | 147 | %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE |
db5ae43f | 148 | %token NAMESPACE TYPENAME_KEYWORD USING |
8d08fdba | 149 | %token LEFT_RIGHT TEMPLATE |
a4443a08 | 150 | %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST |
8d08fdba MS |
151 | %token <itype> SCOPE |
152 | ||
8d08fdba MS |
153 | /* Define the operator tokens and their precedences. |
154 | The value is an integer because, if used, it is the tree code | |
155 | to use in the expression made from the operator. */ | |
156 | ||
157 | %left EMPTY /* used to resolve s/r with epsilon */ | |
158 | ||
159 | %left error | |
160 | ||
161 | /* Add precedence rules to solve dangling else s/r conflict */ | |
162 | %nonassoc IF | |
163 | %nonassoc ELSE | |
164 | ||
c11b6f21 | 165 | %left IDENTIFIER TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD |
8d08fdba MS |
166 | |
167 | %left '{' ',' ';' | |
168 | ||
db5ae43f | 169 | %nonassoc THROW |
6060a796 | 170 | %right <code> ':' |
8d08fdba | 171 | %right <code> ASSIGN '=' |
6060a796 | 172 | %right <code> '?' |
8d08fdba MS |
173 | %left <code> OROR |
174 | %left <code> ANDAND | |
175 | %left <code> '|' | |
176 | %left <code> '^' | |
177 | %left <code> '&' | |
178 | %left <code> MIN_MAX | |
179 | %left <code> EQCOMPARE | |
180 | %left <code> ARITHCOMPARE '<' '>' | |
181 | %left <code> LSHIFT RSHIFT | |
182 | %left <code> '+' '-' | |
183 | %left <code> '*' '/' '%' | |
51c184be MS |
184 | %left <code> POINTSAT_STAR DOT_STAR |
185 | %right <code> UNARY PLUSPLUS MINUSMINUS '~' | |
8d08fdba MS |
186 | %left HYPERUNARY |
187 | %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT | |
51c184be | 188 | %left <code> POINTSAT '.' '(' '[' |
8d08fdba MS |
189 | |
190 | %right SCOPE /* C++ extension */ | |
db5ae43f | 191 | %nonassoc NEW DELETE TRY CATCH |
8d08fdba MS |
192 | |
193 | %type <code> unop | |
194 | ||
195 | %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist | |
a80e4195 | 196 | %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME |
8d08fdba | 197 | %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING |
46b02c6d MS |
198 | %type <ttype> reserved_declspecs boolean.literal |
199 | %type <ttype> reserved_typespecquals | |
200 | %type <ttype> declmods | |
c11b6f21 | 201 | %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier |
8d08fdba | 202 | %type <itype> initdecls notype_initdecls initdcl /* C++ modification */ |
42976354 | 203 | %type <ttype> init initlist maybeasm maybe_init defarg defarg1 |
8d08fdba | 204 | %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers |
2986ae00 MS |
205 | %type <ttype> maybe_attribute attributes attribute attribute_list attrib |
206 | %type <ttype> any_word | |
8d08fdba | 207 | |
8d2733ca | 208 | %type <ttype> compstmt implicitly_scoped_stmt |
8d08fdba MS |
209 | |
210 | %type <ttype> declarator notype_declarator after_type_declarator | |
51c184be | 211 | %type <ttype> direct_notype_declarator direct_after_type_declarator |
8d08fdba | 212 | |
46b02c6d | 213 | %type <ttype> opt.component_decl_list component_decl_list |
f30432d7 | 214 | %type <ttype> component_decl component_decl_1 components notype_components |
c91a56d2 | 215 | %type <ttype> component_declarator component_declarator0 self_reference |
f30432d7 | 216 | %type <ttype> notype_component_declarator notype_component_declarator0 |
51c184be | 217 | %type <ttype> after_type_component_declarator after_type_component_declarator0 |
8d08fdba | 218 | %type <ttype> enumlist enumerator |
c11b6f21 | 219 | %type <ttype> absdcl cv_qualifiers |
51c184be | 220 | %type <ttype> direct_abstract_declarator conversion_declarator |
46b02c6d MS |
221 | %type <ttype> new_declarator direct_new_declarator |
222 | %type <ttype> xexpr parmlist parms bad_parm | |
8d08fdba | 223 | %type <ttype> identifiers_or_typenames |
f30432d7 | 224 | %type <ttype> fcast_or_absdcl regcast_or_absdcl |
a28e3c7f MS |
225 | %type <ttype> expr_or_declarator complex_notype_declarator |
226 | %type <ttype> notype_unqualified_id unqualified_id qualified_id | |
6060a796 | 227 | %type <ttype> overqualified_id notype_qualified_id any_id |
51c184be | 228 | %type <ttype> complex_direct_notype_declarator functional_cast |
46b02c6d MS |
229 | %type <ttype> complex_parmlist parms_comma |
230 | ||
231 | %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs | |
c11b6f21 | 232 | %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers |
46b02c6d | 233 | %type <ftype> structsp typespecqual_reserved parm named_parm full_parm |
8d08fdba MS |
234 | |
235 | /* C++ extensions */ | |
a28e3c7f | 236 | %token <ttype> TYPENAME_ELLIPSIS PTYPENAME |
8d08fdba | 237 | %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL |
42976354 | 238 | %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER |
a80e4195 | 239 | %type <ttype> fn.def1 /* Not really! */ component_constructor_declarator |
c91a56d2 | 240 | %type <ttype> fn.def2 return_id fn.defpen constructor_declarator |
f30432d7 | 241 | %type <itype> ctor_initializer_opt |
8d08fdba | 242 | %type <ttype> named_class_head named_class_head_sans_basetype |
07674418 | 243 | %type <ttype> named_complex_class_head_sans_basetype |
8d08fdba MS |
244 | %type <ttype> unnamed_class_head |
245 | %type <ttype> class_head base_class_list | |
be99da77 | 246 | %type <ttype> base_class_access_list |
8d08fdba | 247 | %type <ttype> base_class maybe_base_class_list base_class.1 |
e3417fcd | 248 | %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers |
863adfc0 | 249 | %type <ttype> operator_name |
39211cd5 MS |
250 | %type <ttype> object aggr |
251 | %type <itype> new delete | |
8d08fdba | 252 | /* %type <ttype> primary_no_id */ |
a5894242 | 253 | %type <ttype> nonmomentary_expr maybe_parmlist |
863adfc0 | 254 | %type <itype> initdcl0 notype_initdcl0 member_init_list |
8d08fdba | 255 | %type <ttype> template_header template_parm_list template_parm |
a292b002 | 256 | %type <ttype> template_type_parm |
5566b478 | 257 | %type <code> template_close_bracket |
8d08fdba | 258 | %type <ttype> template_type template_arg_list template_arg |
8d2733ca | 259 | %type <ttype> condition xcond paren_cond_or_null |
a28e3c7f | 260 | %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem |
cffa8729 | 261 | %type <ttype> complete_type_name notype_identifier |
a28e3c7f MS |
262 | %type <ttype> complex_type_name nested_name_specifier_1 |
263 | %type <itype> nomods_initdecls nomods_initdcl0 | |
46b02c6d | 264 | %type <ttype> new_initializer new_placement |
863adfc0 | 265 | %type <ttype> using_decl .poplevel |
8d08fdba | 266 | |
e92cc029 | 267 | /* in order to recognize aggr tags as defining and thus shadowing. */ |
8d08fdba | 268 | %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN |
5566b478 | 269 | %type <ttype> named_class_head_sans_basetype_defn |
8d08fdba MS |
270 | %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN |
271 | ||
67d743fe MS |
272 | %type <ttype> self_template_type |
273 | ||
6060a796 MS |
274 | %token NSNAME |
275 | %type <ttype> NSNAME | |
276 | ||
d18c083e MS |
277 | /* Used in lex.c for parsing pragmas. */ |
278 | %token END_OF_LINE | |
279 | ||
5566b478 | 280 | /* lex.c and pt.c depend on this being the last token. Define |
8d08fdba MS |
281 | any new tokens before this one! */ |
282 | %token END_OF_SAVED_INPUT | |
283 | \f | |
284 | %{ | |
285 | /* List of types and structure classes of the current declaration. */ | |
42976354 | 286 | static tree current_declspecs = NULL_TREE; |
f30432d7 MS |
287 | /* List of prefix attributes in effect. |
288 | Prefix attributes are parsed by the reserved_declspecs and declmods | |
289 | rules. They create a list that contains *both* declspecs and attrs. */ | |
290 | /* ??? It is not clear yet that all cases where an attribute can now appear in | |
291 | a declspec list have been updated. */ | |
42976354 | 292 | static tree prefix_attributes = NULL_TREE; |
8d08fdba MS |
293 | |
294 | /* When defining an aggregate, this is the most recent one being defined. */ | |
295 | static tree current_aggr; | |
296 | ||
297 | /* Tell yyparse how to print a token's value, if yydebug is set. */ | |
298 | ||
299 | #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL) | |
49c249e1 | 300 | extern void yyprint PROTO((FILE *, int, YYSTYPE)); |
8d08fdba | 301 | extern tree combine_strings PROTO((tree)); |
8d08fdba MS |
302 | %} |
303 | \f | |
304 | %% | |
c11b6f21 MS |
305 | program: |
306 | /* empty */ | |
8d08fdba MS |
307 | | extdefs |
308 | { | |
309 | /* In case there were missing closebraces, | |
310 | get us back to the global binding level. */ | |
311 | while (! global_bindings_p ()) | |
312 | poplevel (0, 0, 0); | |
313 | finish_file (); | |
314 | } | |
315 | ; | |
316 | ||
317 | /* the reason for the strange actions in this rule | |
318 | is so that notype_initdecls when reached via datadef | |
e92cc029 | 319 | can find a valid list of type and sc specs in $0. */ |
8d08fdba MS |
320 | |
321 | extdefs: | |
c11b6f21 MS |
322 | { $<ttype>$ = NULL_TREE; } |
323 | lang_extdef | |
8d08fdba MS |
324 | { $<ttype>$ = NULL_TREE; } |
325 | | extdefs lang_extdef | |
326 | { $<ttype>$ = NULL_TREE; } | |
327 | ; | |
328 | ||
6060a796 MS |
329 | extdefs_opt: |
330 | extdefs | |
331 | | /* empty */ | |
332 | ; | |
333 | ||
8d08fdba MS |
334 | .hush_warning: |
335 | { have_extern_spec = 1; | |
336 | used_extern_spec = 0; | |
337 | $<ttype>$ = NULL_TREE; } | |
338 | ; | |
339 | .warning_ok: | |
340 | { have_extern_spec = 0; } | |
341 | ; | |
342 | ||
de22184b MS |
343 | extension: |
344 | EXTENSION | |
345 | { $<itype>$ = pedantic; | |
346 | pedantic = 0; } | |
347 | ; | |
348 | ||
8d08fdba | 349 | asm_keyword: |
2986ae00 | 350 | ASM_KEYWORD |
8d08fdba MS |
351 | | GCC_ASM_KEYWORD |
352 | ; | |
353 | ||
354 | lang_extdef: | |
c11b6f21 | 355 | { if (pending_lang_change) do_pending_lang_change(); } |
8d08fdba | 356 | extdef |
c11b6f21 MS |
357 | { if (! toplevel_bindings_p () && ! pseudo_global_level_p()) |
358 | pop_everything (); } | |
8d08fdba MS |
359 | ; |
360 | ||
361 | extdef: | |
8dff1027 | 362 | fndef eat_saved_input |
8d08fdba MS |
363 | { if (pending_inlines) do_pending_inlines (); } |
364 | | datadef | |
365 | { if (pending_inlines) do_pending_inlines (); } | |
366 | | template_def | |
367 | { if (pending_inlines) do_pending_inlines (); } | |
8d08fdba MS |
368 | | asm_keyword '(' string ')' ';' |
369 | { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); | |
370 | assemble_asm ($3); } | |
6060a796 | 371 | | extern_lang_string '{' extdefs_opt '}' |
8d08fdba | 372 | { pop_lang_context (); } |
8dff1027 | 373 | | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input |
8d08fdba MS |
374 | { if (pending_inlines) do_pending_inlines (); |
375 | pop_lang_context (); } | |
376 | | extern_lang_string .hush_warning datadef .warning_ok | |
377 | { if (pending_inlines) do_pending_inlines (); | |
378 | pop_lang_context (); } | |
6060a796 MS |
379 | | NAMESPACE identifier '{' |
380 | { push_namespace ($2); } | |
381 | extdefs_opt '}' | |
382 | { pop_namespace (); } | |
383 | | NAMESPACE '{' | |
384 | { push_namespace (NULL_TREE); } | |
385 | extdefs_opt '}' | |
386 | { pop_namespace (); } | |
387 | | NAMESPACE identifier '=' any_id ';' | |
388 | { do_namespace_alias ($2, $4); } | |
389 | | using_decl ';' | |
a9aedbc2 | 390 | { do_toplevel_using_decl ($1); } |
6060a796 | 391 | | USING NAMESPACE any_id ';' |
6633d636 MS |
392 | { |
393 | if (TREE_CODE ($3) == IDENTIFIER_NODE) | |
394 | $3 = lastiddecl; | |
395 | do_using_directive ($3); | |
396 | } | |
de22184b MS |
397 | | extension extdef |
398 | { pedantic = $<itype>1; } | |
6060a796 MS |
399 | ; |
400 | ||
401 | using_decl: | |
402 | USING qualified_id | |
a9aedbc2 | 403 | { $$ = $2; } |
6060a796 | 404 | | USING global_scope qualified_id |
a9aedbc2 | 405 | { $$ = $3; } |
6060a796 | 406 | | USING global_scope unqualified_id |
a9aedbc2 | 407 | { $$ = $3; } |
6060a796 MS |
408 | ; |
409 | ||
410 | any_id: | |
411 | unqualified_id | |
412 | | qualified_id | |
413 | | global_scope qualified_id | |
414 | { $$ = $2; } | |
415 | | global_scope unqualified_id | |
416 | { $$ = $2; } | |
8d08fdba MS |
417 | ; |
418 | ||
419 | extern_lang_string: | |
28cbf42c | 420 | EXTERN_LANG_STRING |
8d08fdba | 421 | { push_lang_context ($1); } |
28cbf42c MS |
422 | | extern_lang_string EXTERN_LANG_STRING |
423 | { if (current_lang_name != $2) | |
424 | cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name); | |
425 | pop_lang_context (); push_lang_context ($2); } | |
8d08fdba MS |
426 | ; |
427 | ||
428 | template_header: | |
429 | TEMPLATE '<' | |
430 | { begin_template_parm_list (); } | |
431 | template_parm_list '>' | |
432 | { $$ = end_template_parm_list ($4); } | |
73aad9b9 JM |
433 | | TEMPLATE '<' '>' |
434 | { $$ = NULL_TREE; } | |
8d08fdba MS |
435 | ; |
436 | ||
437 | template_parm_list: | |
438 | template_parm | |
439 | { $$ = process_template_parm (NULL_TREE, $1); } | |
440 | | template_parm_list ',' template_parm | |
441 | { $$ = process_template_parm ($1, $3); } | |
442 | ; | |
443 | ||
a292b002 MS |
444 | template_type_parm: |
445 | aggr | |
446 | { | |
447 | $$ = build_tree_list ($1, NULL_TREE); | |
448 | ttpa: | |
449 | if (TREE_PURPOSE ($$) == signature_type_node) | |
450 | sorry ("signature as template type parameter"); | |
451 | else if (TREE_PURPOSE ($$) != class_type_node) | |
ec255269 MS |
452 | { |
453 | pedwarn ("template type parameters must use the keyword `class'"); | |
454 | TREE_PURPOSE ($$) = class_type_node; | |
455 | } | |
a292b002 MS |
456 | } |
457 | | aggr identifier | |
458 | { $$ = build_tree_list ($1, $2); goto ttpa; } | |
f30432d7 MS |
459 | | TYPENAME_KEYWORD |
460 | { $$ = build_tree_list (class_type_node, NULL_TREE); } | |
461 | | TYPENAME_KEYWORD identifier | |
462 | { $$ = build_tree_list (class_type_node, $2); } | |
a292b002 MS |
463 | ; |
464 | ||
8d08fdba MS |
465 | template_parm: |
466 | /* The following rules introduce a new reduce/reduce | |
51c184be MS |
467 | conflict on the ',' and '>' input tokens: they are valid |
468 | prefixes for a `structsp', which means they could match a | |
469 | nameless parameter. See 14.6, paragraph 3. | |
8d08fdba MS |
470 | By putting them before the `parm' rule, we get |
471 | their match before considering them nameless parameter | |
472 | declarations. */ | |
a292b002 | 473 | template_type_parm |
5566b478 MS |
474 | { $$ = build_tree_list (NULL_TREE, $1); } |
475 | | template_type_parm '=' type_id | |
46b02c6d | 476 | { $$ = build_tree_list (groktypename ($3.t), $1); } |
5566b478 | 477 | | parm |
46b02c6d | 478 | { $$ = build_tree_list (NULL_TREE, $1.t); } |
c11b6f21 | 479 | | parm '=' expr_no_commas %prec ARITHCOMPARE |
46b02c6d | 480 | { $$ = build_tree_list ($3, $1.t); } |
8d08fdba MS |
481 | ; |
482 | ||
5566b478 MS |
483 | template_def: |
484 | template_header | |
485 | extdef | |
486 | { end_template_decl (); } | |
487 | | template_header | |
c11b6f21 | 488 | error %prec EMPTY |
5566b478 | 489 | { end_template_decl (); } |
8d08fdba MS |
490 | ; |
491 | ||
492 | datadef: | |
a28e3c7f MS |
493 | nomods_initdecls ';' |
494 | {} | |
8d08fdba MS |
495 | | declmods notype_initdecls ';' |
496 | {} | |
8d08fdba MS |
497 | | typed_declspecs initdecls ';' |
498 | { | |
46b02c6d | 499 | note_list_got_semicolon ($1.t); |
8d08fdba | 500 | } |
8d08fdba | 501 | | declmods ';' |
c11b6f21 | 502 | { pedwarn ("empty declaration"); } |
8d08fdba MS |
503 | | explicit_instantiation ';' |
504 | | typed_declspecs ';' | |
c11b6f21 MS |
505 | { |
506 | tree t, attrs; | |
507 | split_specs_attrs ($1.t, &t, &attrs); | |
508 | shadow_tag (t); | |
509 | note_list_got_semicolon ($1.t); | |
510 | } | |
8d08fdba MS |
511 | | error ';' |
512 | | error '}' | |
513 | | ';' | |
514 | ; | |
515 | ||
f30432d7 MS |
516 | ctor_initializer_opt: |
517 | nodecls | |
518 | { $$ = 0; } | |
519 | | base_init | |
520 | { $$ = 1; } | |
521 | ; | |
8d08fdba | 522 | |
f30432d7 MS |
523 | maybe_return_init: |
524 | /* empty */ | |
525 | | return_init | |
526 | | return_init ';' | |
527 | ; | |
8d08fdba | 528 | |
f30432d7 MS |
529 | eat_saved_input: |
530 | /* empty */ | |
531 | | END_OF_SAVED_INPUT | |
532 | ; | |
533 | ||
534 | fndef: | |
535 | fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error | |
5566b478 | 536 | { finish_function (lineno, (int)$3, 0); } |
f30432d7 | 537 | | fn.def1 maybe_return_init function_try_block |
8dff1027 MS |
538 | { } |
539 | | fn.def1 maybe_return_init error | |
540 | { } | |
8d08fdba MS |
541 | ; |
542 | ||
c91a56d2 | 543 | constructor_declarator: |
a80e4195 | 544 | nested_name_specifier SELFNAME '(' |
c91a56d2 MS |
545 | { |
546 | $$ = build_parse_node (SCOPE_REF, $1, $2); | |
547 | if ($1 != current_class_type) | |
548 | { | |
549 | push_nested_class ($1, 3); | |
550 | TREE_COMPLEXITY ($$) = current_class_depth; | |
551 | } | |
552 | } | |
c11b6f21 MS |
553 | parmlist ')' cv_qualifiers exception_specification_opt |
554 | { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); } | |
555 | | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt | |
c91a56d2 MS |
556 | { |
557 | $$ = build_parse_node (SCOPE_REF, $1, $2); | |
558 | if ($1 != current_class_type) | |
559 | { | |
560 | push_nested_class ($1, 3); | |
561 | TREE_COMPLEXITY ($$) = current_class_depth; | |
562 | } | |
c11b6f21 | 563 | $$ = make_call_declarator ($$, empty_parms (), $4, $5); |
c91a56d2 | 564 | } |
a80e4195 | 565 | | global_scope nested_name_specifier SELFNAME '(' |
c91a56d2 MS |
566 | { |
567 | $$ = build_parse_node (SCOPE_REF, $2, $3); | |
568 | if ($2 != current_class_type) | |
569 | { | |
570 | push_nested_class ($2, 3); | |
571 | TREE_COMPLEXITY ($$) = current_class_depth; | |
572 | } | |
573 | } | |
c11b6f21 MS |
574 | parmlist ')' cv_qualifiers exception_specification_opt |
575 | { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); } | |
576 | | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt | |
c91a56d2 MS |
577 | { |
578 | $$ = build_parse_node (SCOPE_REF, $2, $3); | |
579 | if ($2 != current_class_type) | |
580 | { | |
581 | push_nested_class ($2, 3); | |
582 | TREE_COMPLEXITY ($$) = current_class_depth; | |
583 | } | |
c11b6f21 | 584 | $$ = make_call_declarator ($$, empty_parms (), $5, $6); |
c91a56d2 | 585 | } |
67d743fe MS |
586 | | nested_name_specifier self_template_type '(' |
587 | { | |
588 | $$ = build_parse_node (SCOPE_REF, $1, $2); | |
589 | if ($1 != current_class_type) | |
590 | { | |
591 | push_nested_class ($1, 3); | |
592 | TREE_COMPLEXITY ($$) = current_class_depth; | |
593 | } | |
594 | } | |
c11b6f21 MS |
595 | parmlist ')' cv_qualifiers exception_specification_opt |
596 | { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); } | |
597 | | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt | |
67d743fe MS |
598 | { |
599 | $$ = build_parse_node (SCOPE_REF, $1, $2); | |
600 | if ($1 != current_class_type) | |
601 | { | |
602 | push_nested_class ($1, 3); | |
603 | TREE_COMPLEXITY ($$) = current_class_depth; | |
604 | } | |
c11b6f21 | 605 | $$ = make_call_declarator ($$, empty_parms (), $4, $5); |
67d743fe MS |
606 | } |
607 | | global_scope nested_name_specifier self_template_type '(' | |
608 | { | |
609 | $$ = build_parse_node (SCOPE_REF, $2, $3); | |
610 | if ($2 != current_class_type) | |
611 | { | |
612 | push_nested_class ($2, 3); | |
613 | TREE_COMPLEXITY ($$) = current_class_depth; | |
614 | } | |
615 | } | |
c11b6f21 MS |
616 | parmlist ')' cv_qualifiers exception_specification_opt |
617 | { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); } | |
618 | | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt | |
67d743fe MS |
619 | { |
620 | $$ = build_parse_node (SCOPE_REF, $2, $3); | |
621 | if ($2 != current_class_type) | |
622 | { | |
623 | push_nested_class ($2, 3); | |
624 | TREE_COMPLEXITY ($$) = current_class_depth; | |
625 | } | |
c11b6f21 | 626 | $$ = make_call_declarator ($$, empty_parms (), $5, $6); |
67d743fe | 627 | } |
c91a56d2 MS |
628 | ; |
629 | ||
8d08fdba | 630 | fn.def1: |
c11b6f21 | 631 | typed_declspecs declarator |
f30432d7 | 632 | { tree specs, attrs; |
46b02c6d | 633 | split_specs_attrs ($1.t, &specs, &attrs); |
c11b6f21 | 634 | if (! start_function (specs, $2, attrs, 0)) |
8d08fdba MS |
635 | YYERROR1; |
636 | reinit_parse_for_function (); | |
637 | $$ = NULL_TREE; } | |
c11b6f21 | 638 | | declmods notype_declarator |
72b7eeff MS |
639 | { tree specs, attrs; |
640 | split_specs_attrs ($1, &specs, &attrs); | |
c11b6f21 | 641 | if (! start_function (specs, $2, attrs, 0)) |
8d08fdba MS |
642 | YYERROR1; |
643 | reinit_parse_for_function (); | |
644 | $$ = NULL_TREE; } | |
c11b6f21 MS |
645 | | notype_declarator |
646 | { if (! start_function (NULL_TREE, $$, NULL_TREE, 0)) | |
8d08fdba MS |
647 | YYERROR1; |
648 | reinit_parse_for_function (); | |
649 | $$ = NULL_TREE; } | |
c11b6f21 | 650 | | declmods constructor_declarator |
c91a56d2 MS |
651 | { tree specs, attrs; |
652 | split_specs_attrs ($1, &specs, &attrs); | |
c11b6f21 | 653 | if (! start_function (specs, $2, attrs, 0)) |
c91a56d2 MS |
654 | YYERROR1; |
655 | reinit_parse_for_function (); | |
656 | $$ = NULL_TREE; } | |
c11b6f21 MS |
657 | | constructor_declarator |
658 | { if (! start_function (NULL_TREE, $$, NULL_TREE, 0)) | |
c91a56d2 MS |
659 | YYERROR1; |
660 | reinit_parse_for_function (); | |
661 | $$ = NULL_TREE; } | |
8d08fdba MS |
662 | ; |
663 | ||
a80e4195 | 664 | component_constructor_declarator: |
c11b6f21 MS |
665 | SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt |
666 | { $$ = make_call_declarator ($1, $3, $5, $6); } | |
667 | | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt | |
668 | { $$ = make_call_declarator ($1, empty_parms (), $3, $4); } | |
669 | | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt | |
670 | { $$ = make_call_declarator ($1, $3, $5, $6); } | |
671 | | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt | |
672 | { $$ = make_call_declarator ($1, empty_parms (), $3, $4); } | |
a80e4195 MS |
673 | ; |
674 | ||
51c184be MS |
675 | /* more C++ complexity. See component_decl for a comment on the |
676 | reduce/reduce conflict introduced by these rules. */ | |
8d08fdba | 677 | fn.def2: |
c11b6f21 | 678 | declmods component_constructor_declarator |
f30432d7 | 679 | { tree specs = strip_attrs ($1); |
c11b6f21 | 680 | $$ = start_method (specs, $2); |
a28e3c7f | 681 | rest_of_mdef: |
8d08fdba MS |
682 | if (! $$) |
683 | YYERROR1; | |
684 | if (yychar == YYEMPTY) | |
685 | yychar = YYLEX; | |
686 | reinit_parse_for_method (yychar, $$); } | |
c11b6f21 MS |
687 | | component_constructor_declarator |
688 | { $$ = start_method (NULL_TREE, $1); goto rest_of_mdef; } | |
689 | | typed_declspecs declarator | |
46b02c6d | 690 | { tree specs = strip_attrs ($1.t); |
c11b6f21 MS |
691 | $$ = start_method (specs, $2); goto rest_of_mdef; } |
692 | | declmods notype_declarator | |
f30432d7 | 693 | { tree specs = strip_attrs ($1); |
c11b6f21 MS |
694 | $$ = start_method (specs, $2); goto rest_of_mdef; } |
695 | | notype_declarator | |
696 | { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; } | |
697 | | declmods constructor_declarator | |
c91a56d2 | 698 | { tree specs = strip_attrs ($1); |
c11b6f21 MS |
699 | $$ = start_method (specs, $2); goto rest_of_mdef; } |
700 | | constructor_declarator | |
701 | { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; } | |
8d08fdba MS |
702 | ; |
703 | ||
c11b6f21 MS |
704 | return_id: |
705 | RETURN IDENTIFIER | |
8d08fdba MS |
706 | { |
707 | if (! current_function_parms_stored) | |
708 | store_parm_decls (); | |
709 | $$ = $2; | |
710 | } | |
711 | ; | |
712 | ||
c11b6f21 MS |
713 | return_init: |
714 | return_id maybe_init | |
e3417fcd | 715 | { store_return_init ($<ttype>$, $2); } |
8d08fdba MS |
716 | | return_id '(' nonnull_exprlist ')' |
717 | { store_return_init ($<ttype>$, $3); } | |
718 | | return_id LEFT_RIGHT | |
719 | { store_return_init ($<ttype>$, NULL_TREE); } | |
720 | ; | |
721 | ||
722 | base_init: | |
723 | ':' .set_base_init member_init_list | |
724 | { | |
725 | if ($3 == 0) | |
726 | error ("no base initializers given following ':'"); | |
727 | setup_vtbl_ptr (); | |
728 | /* Always keep the BLOCK node associated with the outermost | |
729 | pair of curley braces of a function. These are needed | |
730 | for correct operation of dwarfout.c. */ | |
731 | keep_next_level (); | |
732 | } | |
733 | ; | |
734 | ||
735 | .set_base_init: | |
c11b6f21 | 736 | /* empty */ |
8d08fdba MS |
737 | { |
738 | if (! current_function_parms_stored) | |
739 | store_parm_decls (); | |
740 | ||
8d08fdba MS |
741 | if (DECL_CONSTRUCTOR_P (current_function_decl)) |
742 | { | |
743 | /* Make a contour for the initializer list. */ | |
744 | pushlevel (0); | |
745 | clear_last_expr (); | |
746 | expand_start_bindings (0); | |
747 | } | |
748 | else if (current_class_type == NULL_TREE) | |
749 | error ("base initializers not allowed for non-member functions"); | |
750 | else if (! DECL_CONSTRUCTOR_P (current_function_decl)) | |
751 | error ("only constructors take base initializers"); | |
752 | } | |
753 | ; | |
754 | ||
755 | member_init_list: | |
756 | /* empty */ | |
757 | { $$ = 0; } | |
758 | | member_init | |
759 | { $$ = 1; } | |
760 | | member_init_list ',' member_init | |
761 | | member_init_list error | |
762 | ; | |
763 | ||
c11b6f21 MS |
764 | member_init: |
765 | '(' nonnull_exprlist ')' | |
8d08fdba | 766 | { |
d22c8596 | 767 | if (current_class_name) |
8d08fdba | 768 | pedwarn ("anachronistic old style base class initializer"); |
4ac14744 | 769 | expand_member_init (current_class_ref, NULL_TREE, $2); |
8d08fdba MS |
770 | } |
771 | | LEFT_RIGHT | |
772 | { | |
d22c8596 | 773 | if (current_class_name) |
8d08fdba | 774 | pedwarn ("anachronistic old style base class initializer"); |
4ac14744 | 775 | expand_member_init (current_class_ref, NULL_TREE, void_type_node); |
8d08fdba | 776 | } |
a28e3c7f | 777 | | notype_identifier '(' nonnull_exprlist ')' |
4ac14744 | 778 | { expand_member_init (current_class_ref, $1, $3); } |
a28e3c7f | 779 | | notype_identifier LEFT_RIGHT |
4ac14744 | 780 | { expand_member_init (current_class_ref, $1, void_type_node); } |
a28e3c7f | 781 | | complete_type_name '(' nonnull_exprlist ')' |
4ac14744 | 782 | { expand_member_init (current_class_ref, $1, $3); } |
a28e3c7f | 783 | | complete_type_name LEFT_RIGHT |
4ac14744 | 784 | { expand_member_init (current_class_ref, $1, void_type_node); } |
a28e3c7f MS |
785 | /* GNU extension */ |
786 | | notype_qualified_id '(' nonnull_exprlist ')' | |
8d08fdba | 787 | { |
a28e3c7f | 788 | do_member_init (OP0 ($1), OP1 ($1), $3); |
8d08fdba | 789 | } |
a28e3c7f | 790 | | notype_qualified_id LEFT_RIGHT |
8d08fdba | 791 | { |
a28e3c7f | 792 | do_member_init (OP0 ($1), OP1 ($1), void_type_node); |
8d08fdba MS |
793 | } |
794 | ; | |
795 | ||
796 | identifier: | |
797 | IDENTIFIER | |
798 | | TYPENAME | |
a80e4195 | 799 | | SELFNAME |
8d08fdba | 800 | | PTYPENAME |
6060a796 | 801 | | NSNAME |
8d08fdba MS |
802 | ; |
803 | ||
a28e3c7f MS |
804 | notype_identifier: |
805 | IDENTIFIER | |
6060a796 | 806 | | PTYPENAME |
c11b6f21 | 807 | | NSNAME %prec EMPTY |
a28e3c7f MS |
808 | ; |
809 | ||
8d08fdba MS |
810 | identifier_defn: |
811 | IDENTIFIER_DEFN | |
812 | | TYPENAME_DEFN | |
813 | | PTYPENAME_DEFN | |
814 | ; | |
815 | ||
8d08fdba | 816 | explicit_instantiation: |
ca79f85d JM |
817 | TEMPLATE typespec ';' |
818 | { do_type_instantiation ($2.t, NULL_TREE); | |
819 | yyungetc (';', 1); } | |
a4443a08 | 820 | | TEMPLATE typed_declspecs declarator |
46b02c6d | 821 | { tree specs = strip_attrs ($2.t); |
6633d636 | 822 | do_decl_instantiation (specs, $3, NULL_TREE); } |
07674418 | 823 | | TEMPLATE notype_declarator |
6633d636 | 824 | { do_decl_instantiation (NULL_TREE, $2, NULL_TREE); } |
c91a56d2 | 825 | | TEMPLATE constructor_declarator |
6633d636 | 826 | { do_decl_instantiation (NULL_TREE, $2, NULL_TREE); } |
ca79f85d JM |
827 | | SCSPEC TEMPLATE typespec ';' |
828 | { do_type_instantiation ($3.t, $1); | |
829 | yyungetc (';', 1); } | |
f0e01782 | 830 | | SCSPEC TEMPLATE typed_declspecs declarator |
46b02c6d | 831 | { tree specs = strip_attrs ($3.t); |
6633d636 | 832 | do_decl_instantiation (specs, $4, $1); } |
07674418 | 833 | | SCSPEC TEMPLATE notype_declarator |
6633d636 | 834 | { do_decl_instantiation (NULL_TREE, $3, $1); } |
c91a56d2 | 835 | | SCSPEC TEMPLATE constructor_declarator |
6633d636 | 836 | { do_decl_instantiation (NULL_TREE, $3, $1); } |
8d08fdba MS |
837 | ; |
838 | ||
5566b478 MS |
839 | /* The TYPENAME expansions are to deal with use of a template class name as |
840 | a template within the class itself, where the template decl is hidden by | |
841 | a type decl. Got all that? */ | |
8d08fdba | 842 | |
5566b478 MS |
843 | template_type: |
844 | PTYPENAME '<' template_arg_list template_close_bracket | |
845 | { | |
846 | $$ = lookup_template_class ($1, $3, NULL_TREE); | |
847 | if ($$ != error_mark_node) | |
848 | $$ = TYPE_STUB_DECL ($$); | |
849 | } | |
850 | | PTYPENAME '<' template_close_bracket | |
851 | { | |
852 | $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE); | |
853 | if ($$ != error_mark_node) | |
854 | $$ = TYPE_STUB_DECL ($$); | |
855 | } | |
856 | | TYPENAME '<' template_arg_list template_close_bracket | |
857 | { | |
858 | $$ = lookup_template_class ($1, $3, NULL_TREE); | |
859 | if ($$ != error_mark_node) | |
860 | $$ = TYPE_STUB_DECL ($$); | |
861 | } | |
862 | | TYPENAME '<' template_close_bracket | |
863 | { | |
864 | $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE); | |
865 | if ($$ != error_mark_node) | |
866 | $$ = TYPE_STUB_DECL ($$); | |
867 | } | |
67d743fe MS |
868 | | self_template_type |
869 | ; | |
870 | ||
871 | self_template_type: | |
872 | SELFNAME '<' template_arg_list template_close_bracket | |
a80e4195 MS |
873 | { |
874 | $$ = lookup_template_class ($1, $3, NULL_TREE); | |
875 | if ($$ != error_mark_node) | |
876 | $$ = TYPE_STUB_DECL ($$); | |
877 | } | |
878 | | SELFNAME '<' template_close_bracket | |
879 | { | |
880 | $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE); | |
881 | if ($$ != error_mark_node) | |
882 | $$ = TYPE_STUB_DECL ($$); | |
883 | } | |
8d08fdba MS |
884 | ; |
885 | ||
5566b478 MS |
886 | template_close_bracket: |
887 | '>' | |
888 | | RSHIFT | |
889 | { | |
890 | /* Handle `Class<Class<Type>>' without space in the `>>' */ | |
891 | pedwarn ("`>>' should be `> >' in template class name"); | |
892 | yyungetc ('>', 1); | |
893 | } | |
8d08fdba MS |
894 | ; |
895 | ||
896 | template_arg_list: | |
897 | template_arg | |
898 | { $$ = build_tree_list (NULL_TREE, $$); } | |
899 | | template_arg_list ',' template_arg | |
900 | { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); } | |
901 | ; | |
902 | ||
903 | template_arg: | |
51c184be | 904 | type_id |
46b02c6d | 905 | { $$ = groktypename ($1.t); } |
5566b478 | 906 | | expr_no_commas %prec ARITHCOMPARE |
8d08fdba MS |
907 | ; |
908 | ||
c11b6f21 MS |
909 | unop: |
910 | '-' | |
8d08fdba MS |
911 | { $$ = NEGATE_EXPR; } |
912 | | '+' | |
913 | { $$ = CONVERT_EXPR; } | |
914 | | PLUSPLUS | |
915 | { $$ = PREINCREMENT_EXPR; } | |
916 | | MINUSMINUS | |
917 | { $$ = PREDECREMENT_EXPR; } | |
918 | | '!' | |
919 | { $$ = TRUTH_NOT_EXPR; } | |
920 | ; | |
921 | ||
c11b6f21 MS |
922 | expr: |
923 | nontrivial_exprlist | |
8d08fdba | 924 | { $$ = build_x_compound_expr ($$); } |
8d08fdba MS |
925 | | expr_no_commas |
926 | ; | |
927 | ||
928 | paren_expr_or_null: | |
929 | LEFT_RIGHT | |
930 | { error ("ANSI C++ forbids an empty condition for `%s'", | |
931 | cond_stmt_keyword); | |
932 | $$ = integer_zero_node; } | |
933 | | '(' expr ')' | |
8ccc31eb | 934 | { $$ = condition_conversion ($2); } |
8d08fdba MS |
935 | ; |
936 | ||
937 | paren_cond_or_null: | |
938 | LEFT_RIGHT | |
939 | { error ("ANSI C++ forbids an empty condition for `%s'", | |
940 | cond_stmt_keyword); | |
941 | $$ = integer_zero_node; } | |
942 | | '(' condition ')' | |
8ccc31eb | 943 | { $$ = condition_conversion ($2); } |
8d08fdba MS |
944 | ; |
945 | ||
946 | xcond: | |
c11b6f21 | 947 | /* empty */ |
8d08fdba MS |
948 | { $$ = NULL_TREE; } |
949 | | condition | |
8ccc31eb | 950 | { $$ = condition_conversion ($$); } |
8d08fdba MS |
951 | | error |
952 | { $$ = NULL_TREE; } | |
953 | ; | |
954 | ||
955 | condition: | |
c11b6f21 | 956 | type_specifier_seq declarator maybeasm maybe_attribute '=' |
8d08fdba MS |
957 | { { |
958 | tree d; | |
959 | for (d = getdecls (); d; d = TREE_CHAIN (d)) | |
960 | if (TREE_CODE (d) == TYPE_DECL) { | |
961 | tree s = TREE_TYPE (d); | |
962 | if (TREE_CODE (s) == RECORD_TYPE) | |
963 | cp_error ("definition of class `%T' in condition", s); | |
964 | else if (TREE_CODE (s) == ENUMERAL_TYPE) | |
965 | cp_error ("definition of enum `%T' in condition", s); | |
966 | } | |
967 | } | |
46b02c6d | 968 | current_declspecs = $1.t; |
c11b6f21 MS |
969 | $<itype>5 = suspend_momentary (); |
970 | $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1); | |
971 | cplus_decl_attributes ($<ttype>$, $4, | |
f30432d7 | 972 | /*prefix_attributes*/ NULL_TREE); |
8d08fdba | 973 | } |
c11b6f21 | 974 | init |
8d08fdba | 975 | { |
c11b6f21 MS |
976 | cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING); |
977 | resume_momentary ($<itype>5); | |
978 | $$ = $<ttype>6; | |
8d08fdba MS |
979 | if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE) |
980 | cp_error ("definition of array `%#D' in condition", $$); | |
981 | } | |
982 | | expr | |
983 | ; | |
984 | ||
863adfc0 MS |
985 | compstmtend: |
986 | '}' | |
987 | | maybe_label_decls stmts '}' | |
988 | | maybe_label_decls stmts error '}' | |
989 | | maybe_label_decls error '}' | |
990 | ; | |
991 | ||
a4443a08 | 992 | already_scoped_stmt: |
5566b478 MS |
993 | '{' |
994 | { | |
5156628f | 995 | if (processing_template_decl) |
5566b478 MS |
996 | { |
997 | $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE); | |
998 | COMPOUND_STMT_NO_SCOPE ($<ttype>$) = 1; | |
999 | add_tree ($<ttype>$); | |
1000 | } | |
1001 | } | |
1002 | compstmtend | |
1003 | { | |
5156628f | 1004 | if (processing_template_decl) |
5566b478 MS |
1005 | { |
1006 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
1007 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
1008 | last_tree = $<ttype>2; | |
1009 | } | |
1010 | finish_stmt (); | |
1011 | } | |
a4443a08 MS |
1012 | | simple_stmt |
1013 | ; | |
1014 | ||
1015 | ||
51c184be MS |
1016 | nontrivial_exprlist: |
1017 | expr_no_commas ',' expr_no_commas | |
1018 | { $$ = tree_cons (NULL_TREE, $$, | |
1019 | build_tree_list (NULL_TREE, $3)); } | |
1020 | | expr_no_commas ',' error | |
1021 | { $$ = tree_cons (NULL_TREE, $$, | |
1022 | build_tree_list (NULL_TREE, error_mark_node)); } | |
1023 | | nontrivial_exprlist ',' expr_no_commas | |
1024 | { chainon ($$, build_tree_list (NULL_TREE, $3)); } | |
1025 | | nontrivial_exprlist ',' error | |
1026 | { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); } | |
1027 | ; | |
1028 | ||
8d08fdba MS |
1029 | nonnull_exprlist: |
1030 | expr_no_commas | |
1031 | { $$ = build_tree_list (NULL_TREE, $$); } | |
51c184be | 1032 | | nontrivial_exprlist |
8d08fdba MS |
1033 | ; |
1034 | ||
1035 | unary_expr: | |
c11b6f21 | 1036 | primary %prec UNARY |
4ac14744 | 1037 | { $$ = $1; } |
8d08fdba | 1038 | /* __extension__ turns off -pedantic for following primary. */ |
de22184b MS |
1039 | | extension cast_expr %prec UNARY |
1040 | { $$ = $2; | |
8d08fdba MS |
1041 | pedantic = $<itype>1; } |
1042 | | '*' cast_expr %prec UNARY | |
1043 | { $$ = build_x_indirect_ref ($2, "unary *"); } | |
1044 | | '&' cast_expr %prec UNARY | |
1045 | { $$ = build_x_unary_op (ADDR_EXPR, $2); } | |
51c184be | 1046 | | '~' cast_expr |
8d08fdba MS |
1047 | { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); } |
1048 | | unop cast_expr %prec UNARY | |
39211cd5 | 1049 | { $$ = build_x_unary_op ($1, $2); |
8d08fdba MS |
1050 | if ($1 == NEGATE_EXPR && TREE_CODE ($2) == INTEGER_CST) |
1051 | TREE_NEGATED_INT ($$) = 1; | |
1052 | overflow_warning ($$); | |
1053 | } | |
1054 | /* Refer to the address of a label as a pointer. */ | |
1055 | | ANDAND identifier | |
1056 | { tree label = lookup_label ($2); | |
1057 | if (label == NULL_TREE) | |
1058 | $$ = null_pointer_node; | |
1059 | else | |
1060 | { | |
1061 | TREE_USED (label) = 1; | |
1062 | $$ = build1 (ADDR_EXPR, ptr_type_node, label); | |
1063 | TREE_CONSTANT ($$) = 1; | |
1064 | } | |
1065 | } | |
1066 | | SIZEOF unary_expr %prec UNARY | |
5566b478 | 1067 | { $$ = expr_sizeof ($2); } |
51c184be | 1068 | | SIZEOF '(' type_id ')' %prec HYPERUNARY |
46b02c6d | 1069 | { $$ = c_sizeof (groktypename ($3.t)); } |
8d08fdba MS |
1070 | | ALIGNOF unary_expr %prec UNARY |
1071 | { $$ = grok_alignof ($2); } | |
51c184be | 1072 | | ALIGNOF '(' type_id ')' %prec HYPERUNARY |
46b02c6d MS |
1073 | { $$ = c_alignof (groktypename ($3.t)); |
1074 | check_for_new_type ("alignof", $3); } | |
8d08fdba | 1075 | |
39211cd5 MS |
1076 | /* The %prec EMPTY's here are required by the = init initializer |
1077 | syntax extension; see below. */ | |
c11b6f21 | 1078 | | new new_type_id %prec EMPTY |
46b02c6d MS |
1079 | { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1); |
1080 | check_for_new_type ("new", $2); } | |
39211cd5 | 1081 | | new new_type_id new_initializer |
46b02c6d MS |
1082 | { $$ = build_new (NULL_TREE, $2.t, $3, $1); |
1083 | check_for_new_type ("new", $2); } | |
c11b6f21 | 1084 | | new new_placement new_type_id %prec EMPTY |
46b02c6d MS |
1085 | { $$ = build_new ($2, $3.t, NULL_TREE, $1); |
1086 | check_for_new_type ("new", $3); } | |
39211cd5 | 1087 | | new new_placement new_type_id new_initializer |
46b02c6d MS |
1088 | { $$ = build_new ($2, $3.t, $4, $1); |
1089 | check_for_new_type ("new", $3); } | |
c11b6f21 | 1090 | | new '(' type_id ')' %prec EMPTY |
46b02c6d MS |
1091 | { $$ = build_new (NULL_TREE, groktypename($3.t), |
1092 | NULL_TREE, $1); | |
1093 | check_for_new_type ("new", $3); } | |
39211cd5 | 1094 | | new '(' type_id ')' new_initializer |
46b02c6d MS |
1095 | { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1); |
1096 | check_for_new_type ("new", $3); } | |
c11b6f21 | 1097 | | new new_placement '(' type_id ')' %prec EMPTY |
46b02c6d MS |
1098 | { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1); |
1099 | check_for_new_type ("new", $4); } | |
39211cd5 | 1100 | | new new_placement '(' type_id ')' new_initializer |
46b02c6d MS |
1101 | { $$ = build_new ($2, groktypename($4.t), $6, $1); |
1102 | check_for_new_type ("new", $4); } | |
8d08fdba MS |
1103 | |
1104 | | delete cast_expr %prec UNARY | |
a28e3c7f | 1105 | { $$ = delete_sanity ($2, NULL_TREE, 0, $1); } |
8d08fdba | 1106 | | delete '[' ']' cast_expr %prec UNARY |
a28e3c7f | 1107 | { $$ = delete_sanity ($4, NULL_TREE, 1, $1); |
8d08fdba MS |
1108 | if (yychar == YYEMPTY) |
1109 | yychar = YYLEX; } | |
c11b6f21 | 1110 | | delete '[' expr ']' cast_expr %prec UNARY |
a28e3c7f | 1111 | { $$ = delete_sanity ($5, $3, 2, $1); |
8d08fdba MS |
1112 | if (yychar == YYEMPTY) |
1113 | yychar = YYLEX; } | |
37c46b43 MS |
1114 | | REALPART cast_expr %prec UNARY |
1115 | { $$ = build_x_unary_op (REALPART_EXPR, $2); } | |
1116 | | IMAGPART cast_expr %prec UNARY | |
1117 | { $$ = build_x_unary_op (IMAGPART_EXPR, $2); } | |
8d08fdba MS |
1118 | ; |
1119 | ||
39211cd5 MS |
1120 | new_placement: |
1121 | '(' nonnull_exprlist ')' | |
1122 | { $$ = $2; } | |
1123 | | '{' nonnull_exprlist '}' | |
1124 | { | |
1125 | $$ = $2; | |
1126 | pedwarn ("old style placement syntax, use () instead"); | |
1127 | } | |
1128 | ; | |
1129 | ||
1130 | new_initializer: | |
1131 | '(' nonnull_exprlist ')' | |
1132 | { $$ = $2; } | |
1133 | | LEFT_RIGHT | |
1134 | { $$ = NULL_TREE; } | |
1135 | | '(' typespec ')' | |
1136 | { | |
46b02c6d | 1137 | cp_error ("`%T' is not a valid expression", $2.t); |
39211cd5 MS |
1138 | $$ = error_mark_node; |
1139 | } | |
1140 | /* GNU extension so people can use initializer lists. Note that | |
1141 | this alters the meaning of `new int = 1', which was previously | |
1142 | syntactically valid but semantically invalid. */ | |
1143 | | '=' init | |
1144 | { | |
b7484fbe | 1145 | if (pedantic) |
39211cd5 MS |
1146 | pedwarn ("ANSI C++ forbids initialization of new expression with `='"); |
1147 | $$ = $2; | |
1148 | } | |
1149 | ; | |
1150 | ||
51c184be MS |
1151 | /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */ |
1152 | regcast_or_absdcl: | |
c11b6f21 | 1153 | '(' type_id ')' %prec EMPTY |
46b02c6d MS |
1154 | { $2.t = tree_cons (NULL_TREE, $2.t, void_list_node); |
1155 | TREE_PARMLIST ($2.t) = 1; | |
c11b6f21 | 1156 | $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE); |
46b02c6d | 1157 | check_for_new_type ("cast", $2); } |
c11b6f21 | 1158 | | regcast_or_absdcl '(' type_id ')' %prec EMPTY |
46b02c6d MS |
1159 | { $3.t = tree_cons (NULL_TREE, $3.t, void_list_node); |
1160 | TREE_PARMLIST ($3.t) = 1; | |
c11b6f21 | 1161 | $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE); |
46b02c6d | 1162 | check_for_new_type ("cast", $3); } |
51c184be MS |
1163 | ; |
1164 | ||
8d08fdba | 1165 | cast_expr: |
f30432d7 MS |
1166 | unary_expr |
1167 | | regcast_or_absdcl unary_expr %prec UNARY | |
51c184be MS |
1168 | { $$ = reparse_absdcl_as_casts ($$, $2); } |
1169 | | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY | |
1170 | { | |
1171 | tree init = build_nt (CONSTRUCTOR, NULL_TREE, | |
1172 | nreverse ($3)); | |
b7484fbe | 1173 | if (pedantic) |
51c184be MS |
1174 | pedwarn ("ANSI C++ forbids constructor-expressions"); |
1175 | /* Indicate that this was a GNU C constructor expression. */ | |
1176 | TREE_HAS_CONSTRUCTOR (init) = 1; | |
8d08fdba | 1177 | |
51c184be | 1178 | $$ = reparse_absdcl_as_casts ($$, init); |
8d08fdba | 1179 | } |
51c184be MS |
1180 | ; |
1181 | ||
8d08fdba MS |
1182 | expr_no_commas: |
1183 | cast_expr | |
51c184be MS |
1184 | /* Handle general members. */ |
1185 | | expr_no_commas POINTSAT_STAR expr_no_commas | |
1186 | { $$ = build_x_binary_op (MEMBER_REF, $$, $3); } | |
1187 | | expr_no_commas DOT_STAR expr_no_commas | |
1188 | { $$ = build_m_component_ref ($$, $3); } | |
8d08fdba MS |
1189 | | expr_no_commas '+' expr_no_commas |
1190 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1191 | | expr_no_commas '-' expr_no_commas | |
1192 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1193 | | expr_no_commas '*' expr_no_commas | |
1194 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1195 | | expr_no_commas '/' expr_no_commas | |
1196 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1197 | | expr_no_commas '%' expr_no_commas | |
1198 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1199 | | expr_no_commas LSHIFT expr_no_commas | |
1200 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1201 | | expr_no_commas RSHIFT expr_no_commas | |
1202 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1203 | | expr_no_commas ARITHCOMPARE expr_no_commas | |
1204 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1205 | | expr_no_commas '<' expr_no_commas | |
1206 | { $$ = build_x_binary_op (LT_EXPR, $$, $3); } | |
1207 | | expr_no_commas '>' expr_no_commas | |
1208 | { $$ = build_x_binary_op (GT_EXPR, $$, $3); } | |
1209 | | expr_no_commas EQCOMPARE expr_no_commas | |
1210 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1211 | | expr_no_commas MIN_MAX expr_no_commas | |
1212 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1213 | | expr_no_commas '&' expr_no_commas | |
1214 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1215 | | expr_no_commas '|' expr_no_commas | |
1216 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1217 | | expr_no_commas '^' expr_no_commas | |
1218 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1219 | | expr_no_commas ANDAND expr_no_commas | |
1220 | { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); } | |
1221 | | expr_no_commas OROR expr_no_commas | |
1222 | { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); } | |
1223 | | expr_no_commas '?' xexpr ':' expr_no_commas | |
1224 | { $$ = build_x_conditional_expr ($$, $3, $5); } | |
1225 | | expr_no_commas '=' expr_no_commas | |
5566b478 | 1226 | { $$ = build_x_modify_expr ($$, NOP_EXPR, $3); |
d2e5ee5c MS |
1227 | if ($$ != error_mark_node) |
1228 | C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); } | |
8d08fdba | 1229 | | expr_no_commas ASSIGN expr_no_commas |
5566b478 | 1230 | { $$ = build_x_modify_expr ($$, $2, $3); } |
8d2733ca MS |
1231 | | THROW |
1232 | { $$ = build_throw (NULL_TREE); } | |
1233 | | THROW expr_no_commas | |
1234 | { $$ = build_throw ($2); } | |
8d08fdba MS |
1235 | /* These extensions are not defined. The second arg to build_m_component_ref |
1236 | is old, build_m_component_ref now does an implicit | |
1237 | build_indirect_ref (x, NULL_PTR) on the second argument. | |
c11b6f21 | 1238 | | object '&' expr_no_commas %prec UNARY |
8d08fdba MS |
1239 | { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); } |
1240 | | object unop expr_no_commas %prec UNARY | |
1241 | { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); } | |
51c184be | 1242 | | object '(' type_id ')' expr_no_commas %prec UNARY |
46b02c6d | 1243 | { tree type = groktypename ($3.t); |
faf5394a | 1244 | $$ = build_m_component_ref ($$, build_c_cast (type, $5)); } |
8d08fdba MS |
1245 | | object primary_no_id %prec UNARY |
1246 | { $$ = build_m_component_ref ($$, $2); } | |
1247 | */ | |
1248 | ; | |
1249 | ||
51c184be | 1250 | notype_unqualified_id: |
a28e3c7f MS |
1251 | '~' see_typename identifier |
1252 | { $$ = build_parse_node (BIT_NOT_EXPR, $3); } | |
8d08fdba | 1253 | | operator_name |
51c184be | 1254 | | IDENTIFIER |
6060a796 | 1255 | | PTYPENAME |
c11b6f21 | 1256 | | NSNAME %prec EMPTY |
51c184be MS |
1257 | ; |
1258 | ||
a28e3c7f MS |
1259 | unqualified_id: |
1260 | notype_unqualified_id | |
1261 | | TYPENAME | |
a80e4195 | 1262 | | SELFNAME |
a28e3c7f MS |
1263 | ; |
1264 | ||
51c184be | 1265 | expr_or_declarator: |
a28e3c7f | 1266 | notype_unqualified_id |
c11b6f21 | 1267 | | '*' expr_or_declarator %prec UNARY |
51c184be | 1268 | { $$ = build_parse_node (INDIRECT_REF, $2); } |
c11b6f21 | 1269 | | '&' expr_or_declarator %prec UNARY |
51c184be | 1270 | { $$ = build_parse_node (ADDR_EXPR, $2); } |
4cabb798 JM |
1271 | | '(' expr_or_declarator ')' |
1272 | { $$ = $2; } | |
51c184be MS |
1273 | ; |
1274 | ||
1275 | direct_notype_declarator: | |
1276 | complex_direct_notype_declarator | |
1277 | | notype_unqualified_id | |
4cabb798 JM |
1278 | | '(' expr_or_declarator ')' |
1279 | { $$ = finish_decl_parsing ($2); } | |
51c184be MS |
1280 | ; |
1281 | ||
1282 | primary: | |
1283 | notype_unqualified_id | |
8d08fdba | 1284 | { |
51c184be MS |
1285 | if (TREE_CODE ($$) == BIT_NOT_EXPR) |
1286 | $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($$, 0)); | |
51c184be | 1287 | else |
5566b478 | 1288 | $$ = do_identifier ($$, 1); |
51c184be | 1289 | } |
8d08fdba | 1290 | | CONSTANT |
2986ae00 | 1291 | | boolean.literal |
8d08fdba | 1292 | | string |
5566b478 | 1293 | { |
5156628f | 1294 | if (processing_template_decl) |
5566b478 MS |
1295 | push_obstacks (&permanent_obstack, &permanent_obstack); |
1296 | $$ = combine_strings ($$); | |
5156628f | 1297 | if (processing_template_decl) |
5566b478 MS |
1298 | pop_obstacks (); |
1299 | } | |
8d08fdba | 1300 | | '(' expr ')' |
e3417fcd MS |
1301 | { char class; |
1302 | $$ = $2; | |
1303 | class = TREE_CODE_CLASS (TREE_CODE ($$)); | |
1304 | if (class == 'e' || class == '1' | |
1305 | || class == '2' || class == '<') | |
e92cc029 | 1306 | /* This inhibits warnings in truthvalue_conversion. */ |
e3417fcd MS |
1307 | C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); } |
1308 | | '(' expr_or_declarator ')' | |
1309 | { char class; | |
1310 | $$ = reparse_decl_as_expr (NULL_TREE, $2); | |
1311 | class = TREE_CODE_CLASS (TREE_CODE ($$)); | |
e1cd6e56 MS |
1312 | if (class == 'e' || class == '1' |
1313 | || class == '2' || class == '<') | |
e92cc029 | 1314 | /* This inhibits warnings in truthvalue_conversion. */ |
e3417fcd | 1315 | C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); } |
8d08fdba MS |
1316 | | '(' error ')' |
1317 | { $$ = error_mark_node; } | |
1318 | | '(' | |
1319 | { if (current_function_decl == 0) | |
1320 | { | |
1321 | error ("braced-group within expression allowed only inside a function"); | |
1322 | YYERROR; | |
1323 | } | |
1324 | keep_next_level (); | |
1325 | $<ttype>$ = expand_start_stmt_expr (); } | |
1326 | compstmt ')' | |
1327 | { tree rtl_exp; | |
b7484fbe | 1328 | if (pedantic) |
8d08fdba MS |
1329 | pedwarn ("ANSI C++ forbids braced-groups within expressions"); |
1330 | rtl_exp = expand_end_stmt_expr ($<ttype>2); | |
1331 | /* The statements have side effects, so the group does. */ | |
1332 | TREE_SIDE_EFFECTS (rtl_exp) = 1; | |
1333 | ||
1334 | if (TREE_CODE ($3) == BLOCK) | |
1335 | { | |
1336 | /* Make a BIND_EXPR for the BLOCK already made. */ | |
1337 | $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp), | |
1338 | NULL_TREE, rtl_exp, $3); | |
1339 | /* Remove the block from the tree at this point. | |
1340 | It gets put back at the proper place | |
1341 | when the BIND_EXPR is expanded. */ | |
1342 | delete_block ($3); | |
1343 | } | |
1344 | else | |
1345 | $$ = $3; | |
1346 | } | |
1347 | | primary '(' nonnull_exprlist ')' | |
5566b478 | 1348 | { |
4ac14744 | 1349 | $$ = build_x_function_call ($1, $3, current_class_ref); |
5566b478 MS |
1350 | if (TREE_CODE ($$) == CALL_EXPR |
1351 | && TREE_TYPE ($$) != void_type_node) | |
1352 | $$ = require_complete_type ($$); | |
8d08fdba MS |
1353 | } |
1354 | | primary LEFT_RIGHT | |
1355 | { | |
4ac14744 | 1356 | $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); |
8d08fdba MS |
1357 | if (TREE_CODE ($$) == CALL_EXPR |
1358 | && TREE_TYPE ($$) != void_type_node) | |
1359 | $$ = require_complete_type ($$); | |
1360 | } | |
1361 | | primary '[' expr ']' | |
8926095f | 1362 | { $$ = grok_array_decl ($$, $3); } |
8d08fdba MS |
1363 | | primary PLUSPLUS |
1364 | { /* If we get an OFFSET_REF, turn it into what it really | |
1365 | means (e.g., a COMPONENT_REF). This way if we've got, | |
1366 | say, a reference to a static member that's being operated | |
1367 | on, we don't end up trying to find a member operator for | |
1368 | the class it's in. */ | |
1369 | if (TREE_CODE ($$) == OFFSET_REF) | |
1370 | $$ = resolve_offset_ref ($$); | |
1371 | $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); } | |
1372 | | primary MINUSMINUS | |
1373 | { if (TREE_CODE ($$) == OFFSET_REF) | |
1374 | $$ = resolve_offset_ref ($$); | |
1375 | $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); } | |
1376 | /* C++ extensions */ | |
1377 | | THIS | |
4ac14744 | 1378 | { if (current_class_ptr) |
8d08fdba MS |
1379 | { |
1380 | #ifdef WARNING_ABOUT_CCD | |
4ac14744 | 1381 | TREE_USED (current_class_ptr) = 1; |
8d08fdba | 1382 | #endif |
4ac14744 | 1383 | $$ = current_class_ptr; |
8d08fdba MS |
1384 | } |
1385 | else if (current_function_decl | |
1386 | && DECL_STATIC_FUNCTION_P (current_function_decl)) | |
1387 | { | |
1388 | error ("`this' is unavailable for static member functions"); | |
1389 | $$ = error_mark_node; | |
1390 | } | |
1391 | else | |
1392 | { | |
1393 | if (current_function_decl) | |
1394 | error ("invalid use of `this' in non-member function"); | |
1395 | else | |
1396 | error ("invalid use of `this' at top level"); | |
1397 | $$ = error_mark_node; | |
1398 | } | |
1399 | } | |
c11b6f21 | 1400 | | CV_QUALIFIER '(' nonnull_exprlist ')' |
8d08fdba MS |
1401 | { |
1402 | tree type; | |
1403 | tree id = $$; | |
1404 | ||
1405 | /* This is a C cast in C++'s `functional' notation. */ | |
1406 | if ($3 == error_mark_node) | |
1407 | { | |
1408 | $$ = error_mark_node; | |
1409 | break; | |
1410 | } | |
1411 | #if 0 | |
1412 | if ($3 == NULL_TREE) | |
1413 | { | |
1414 | error ("cannot cast null list to type `%s'", | |
1415 | IDENTIFIER_POINTER (TYPE_NAME (id))); | |
1416 | $$ = error_mark_node; | |
1417 | break; | |
1418 | } | |
1419 | #endif | |
1420 | #if 0 | |
1421 | /* type is not set! (mrs) */ | |
1422 | if (type == error_mark_node) | |
1423 | $$ = error_mark_node; | |
1424 | else | |
1425 | #endif | |
1426 | { | |
1427 | if (id == ridpointers[(int) RID_CONST]) | |
1428 | type = build_type_variant (integer_type_node, 1, 0); | |
1429 | else if (id == ridpointers[(int) RID_VOLATILE]) | |
1430 | type = build_type_variant (integer_type_node, 0, 1); | |
1431 | #if 0 | |
1432 | /* should not be able to get here (mrs) */ | |
1433 | else if (id == ridpointers[(int) RID_FRIEND]) | |
1434 | { | |
1435 | error ("cannot cast expression to `friend' type"); | |
1436 | $$ = error_mark_node; | |
1437 | break; | |
1438 | } | |
1439 | #endif | |
1440 | else my_friendly_abort (79); | |
faf5394a | 1441 | $$ = build_c_cast (type, build_compound_expr ($3)); |
8d08fdba MS |
1442 | } |
1443 | } | |
51c184be | 1444 | | functional_cast |
46b02c6d MS |
1445 | | DYNAMIC_CAST '<' type_id '>' '(' expr ')' |
1446 | { tree type = groktypename ($3.t); | |
1447 | check_for_new_type ("dynamic_cast", $3); | |
1448 | $$ = build_dynamic_cast (type, $6); } | |
1449 | | STATIC_CAST '<' type_id '>' '(' expr ')' | |
1450 | { tree type = groktypename ($3.t); | |
1451 | check_for_new_type ("static_cast", $3); | |
1452 | $$ = build_static_cast (type, $6); } | |
1453 | | REINTERPRET_CAST '<' type_id '>' '(' expr ')' | |
1454 | { tree type = groktypename ($3.t); | |
1455 | check_for_new_type ("reinterpret_cast", $3); | |
1456 | $$ = build_reinterpret_cast (type, $6); } | |
1457 | | CONST_CAST '<' type_id '>' '(' expr ')' | |
1458 | { tree type = groktypename ($3.t); | |
1459 | check_for_new_type ("const_cast", $3); | |
1460 | $$ = build_const_cast (type, $6); } | |
8d08fdba | 1461 | | TYPEID '(' expr ')' |
5156628f | 1462 | { $$ = build_x_typeid ($3); } |
51c184be | 1463 | | TYPEID '(' type_id ')' |
46b02c6d MS |
1464 | { tree type = groktypename ($3.t); |
1465 | check_for_new_type ("typeid", $3); | |
8145f082 | 1466 | $$ = get_typeid (TYPE_MAIN_VARIANT (type)); } |
a28e3c7f | 1467 | | global_scope IDENTIFIER |
5566b478 | 1468 | { $$ = do_scoped_id ($2, 1); } |
a28e3c7f | 1469 | | global_scope operator_name |
8d08fdba | 1470 | { |
a28e3c7f | 1471 | got_scope = NULL_TREE; |
8d08fdba | 1472 | if (TREE_CODE ($2) == IDENTIFIER_NODE) |
5566b478 MS |
1473 | $$ = do_scoped_id ($2, 1); |
1474 | else | |
1475 | $$ = $2; | |
8d08fdba | 1476 | } |
c11b6f21 | 1477 | | overqualified_id %prec HYPERUNARY |
a28e3c7f MS |
1478 | { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); } |
1479 | | overqualified_id '(' nonnull_exprlist ')' | |
5156628f | 1480 | { if (processing_template_decl) |
4dabb379 | 1481 | $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1), $3, NULL_TREE); |
5566b478 MS |
1482 | else |
1483 | $$ = build_member_call (OP0 ($$), OP1 ($$), $3); } | |
a28e3c7f | 1484 | | overqualified_id LEFT_RIGHT |
5156628f | 1485 | { if (processing_template_decl) |
5566b478 | 1486 | $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1), |
4dabb379 | 1487 | NULL_TREE, NULL_TREE); |
5566b478 MS |
1488 | else |
1489 | $$ = build_member_call (OP0 ($$), OP1 ($$), NULL_TREE); } | |
a28e3c7f | 1490 | | object unqualified_id %prec UNARY |
5156628f | 1491 | { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); } |
c11b6f21 | 1492 | | object overqualified_id %prec UNARY |
5156628f | 1493 | { if (processing_template_decl) |
5566b478 MS |
1494 | $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2)); |
1495 | else | |
1496 | $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); } | |
a28e3c7f | 1497 | | object unqualified_id '(' nonnull_exprlist ')' |
8d08fdba MS |
1498 | { |
1499 | #if 0 | |
1500 | /* This is a future direction of this code, but because | |
1501 | build_x_function_call cannot always undo what is done | |
e92cc029 | 1502 | in build_component_ref entirely yet, we cannot do this. */ |
4ac14744 | 1503 | $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), $4, current_class_ref); |
8d08fdba MS |
1504 | if (TREE_CODE ($$) == CALL_EXPR |
1505 | && TREE_TYPE ($$) != void_type_node) | |
1506 | $$ = require_complete_type ($$); | |
1507 | #else | |
1508 | $$ = build_method_call ($$, $2, $4, NULL_TREE, | |
4ac14744 | 1509 | LOOKUP_NORMAL); |
8d08fdba MS |
1510 | #endif |
1511 | } | |
a28e3c7f | 1512 | | object unqualified_id LEFT_RIGHT |
8d08fdba MS |
1513 | { |
1514 | #if 0 | |
1515 | /* This is a future direction of this code, but because | |
1516 | build_x_function_call cannot always undo what is done | |
e92cc029 | 1517 | in build_component_ref entirely yet, we cannot do this. */ |
4ac14744 | 1518 | $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), NULL_TREE, current_class_ref); |
8d08fdba MS |
1519 | if (TREE_CODE ($$) == CALL_EXPR |
1520 | && TREE_TYPE ($$) != void_type_node) | |
1521 | $$ = require_complete_type ($$); | |
1522 | #else | |
1523 | $$ = build_method_call ($$, $2, NULL_TREE, NULL_TREE, | |
4ac14744 | 1524 | LOOKUP_NORMAL); |
8d08fdba MS |
1525 | #endif |
1526 | } | |
b7484fbe | 1527 | | object overqualified_id '(' nonnull_exprlist ')' |
8d08fdba | 1528 | { |
be99da77 | 1529 | if (IS_SIGNATURE (OP0 ($2))) |
8d08fdba MS |
1530 | { |
1531 | warning ("signature name in scope resolution ignored"); | |
a28e3c7f | 1532 | $$ = build_method_call ($$, OP1 ($2), $4, NULL_TREE, |
4ac14744 | 1533 | LOOKUP_NORMAL); |
8d08fdba MS |
1534 | } |
1535 | else | |
a28e3c7f | 1536 | $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), $4); |
8d08fdba | 1537 | } |
b7484fbe | 1538 | | object overqualified_id LEFT_RIGHT |
8d08fdba | 1539 | { |
be99da77 | 1540 | if (IS_SIGNATURE (OP0 ($2))) |
8d08fdba MS |
1541 | { |
1542 | warning ("signature name in scope resolution ignored"); | |
a28e3c7f | 1543 | $$ = build_method_call ($$, OP1 ($2), NULL_TREE, NULL_TREE, |
4ac14744 | 1544 | LOOKUP_NORMAL); |
8d08fdba MS |
1545 | } |
1546 | else | |
a28e3c7f | 1547 | $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), NULL_TREE); |
8d08fdba MS |
1548 | } |
1549 | /* p->int::~int() is valid -- 12.4 */ | |
1550 | | object '~' TYPESPEC LEFT_RIGHT | |
e1cd6e56 | 1551 | { |
b7484fbe MS |
1552 | if (IDENTIFIER_GLOBAL_VALUE ($3) |
1553 | && (TREE_CODE (TREE_TYPE ($1)) | |
1554 | != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($3))))) | |
8d08fdba | 1555 | cp_error ("`%E' is not of type `%T'", $1, $3); |
37c46b43 | 1556 | $$ = cp_convert (void_type_node, $1); |
8d08fdba MS |
1557 | } |
1558 | | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT | |
e1cd6e56 | 1559 | { |
8d08fdba MS |
1560 | if ($2 != $5) |
1561 | cp_error ("destructor specifier `%T::~%T()' must have matching names", $2, $5); | |
1562 | if (TREE_CODE (TREE_TYPE ($1)) | |
1563 | != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($2)))) | |
1564 | cp_error ("`%E' is not of type `%T'", $1, $2); | |
37c46b43 | 1565 | $$ = cp_convert (void_type_node, $1); |
8d08fdba | 1566 | } |
e1cd6e56 MS |
1567 | | object error |
1568 | { | |
e1cd6e56 MS |
1569 | $$ = error_mark_node; |
1570 | } | |
8d08fdba MS |
1571 | ; |
1572 | ||
1573 | /* Not needed for now. | |
1574 | ||
1575 | primary_no_id: | |
1576 | '(' expr ')' | |
1577 | { $$ = $2; } | |
1578 | | '(' error ')' | |
1579 | { $$ = error_mark_node; } | |
1580 | | '(' | |
1581 | { if (current_function_decl == 0) | |
1582 | { | |
1583 | error ("braced-group within expression allowed only inside a function"); | |
1584 | YYERROR; | |
1585 | } | |
1586 | $<ttype>$ = expand_start_stmt_expr (); } | |
1587 | compstmt ')' | |
b7484fbe | 1588 | { if (pedantic) |
8d08fdba MS |
1589 | pedwarn ("ANSI C++ forbids braced-groups within expressions"); |
1590 | $$ = expand_end_stmt_expr ($<ttype>2); } | |
1591 | | primary_no_id '(' nonnull_exprlist ')' | |
4ac14744 | 1592 | { $$ = build_x_function_call ($$, $3, current_class_ref); } |
8d08fdba | 1593 | | primary_no_id LEFT_RIGHT |
4ac14744 | 1594 | { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); } |
8d08fdba MS |
1595 | | primary_no_id '[' expr ']' |
1596 | { goto do_array; } | |
1597 | | primary_no_id PLUSPLUS | |
1598 | { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); } | |
1599 | | primary_no_id MINUSMINUS | |
1600 | { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); } | |
1601 | | SCOPE IDENTIFIER | |
1602 | { goto do_scoped_id; } | |
1603 | | SCOPE operator_name | |
1604 | { if (TREE_CODE ($2) == IDENTIFIER_NODE) | |
1605 | goto do_scoped_id; | |
1606 | goto do_scoped_operator; | |
1607 | } | |
1608 | ; | |
1609 | */ | |
1610 | ||
c11b6f21 MS |
1611 | new: |
1612 | NEW | |
8d08fdba | 1613 | { $$ = 0; } |
39211cd5 | 1614 | | global_scope NEW |
a28e3c7f | 1615 | { got_scope = NULL_TREE; $$ = 1; } |
8d08fdba MS |
1616 | ; |
1617 | ||
c11b6f21 MS |
1618 | delete: |
1619 | DELETE | |
a28e3c7f MS |
1620 | { $$ = 0; } |
1621 | | global_scope delete | |
1622 | { got_scope = NULL_TREE; $$ = 1; } | |
8d08fdba MS |
1623 | ; |
1624 | ||
2986ae00 MS |
1625 | boolean.literal: |
1626 | CXX_TRUE | |
255512c1 | 1627 | { $$ = boolean_true_node; } |
2986ae00 | 1628 | | CXX_FALSE |
255512c1 | 1629 | { $$ = boolean_false_node; } |
2986ae00 MS |
1630 | ; |
1631 | ||
8d08fdba MS |
1632 | /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */ |
1633 | string: | |
1634 | STRING | |
1635 | | string STRING | |
1636 | { $$ = chainon ($$, $2); } | |
1637 | ; | |
1638 | ||
1639 | nodecls: | |
1640 | /* empty */ | |
1641 | { | |
1642 | if (! current_function_parms_stored) | |
1643 | store_parm_decls (); | |
1644 | setup_vtbl_ptr (); | |
1645 | /* Always keep the BLOCK node associated with the outermost | |
1646 | pair of curley braces of a function. These are needed | |
1647 | for correct operation of dwarfout.c. */ | |
1648 | keep_next_level (); | |
1649 | } | |
1650 | ; | |
1651 | ||
c11b6f21 MS |
1652 | object: |
1653 | primary '.' | |
e1cd6e56 | 1654 | { got_object = TREE_TYPE ($$); } |
8d08fdba MS |
1655 | | primary POINTSAT |
1656 | { | |
e1cd6e56 MS |
1657 | $$ = build_x_arrow ($$); |
1658 | got_object = TREE_TYPE ($$); | |
8d08fdba MS |
1659 | } |
1660 | ; | |
1661 | ||
8d08fdba | 1662 | decl: |
c11b6f21 | 1663 | typespec initdecls ';' |
a28e3c7f MS |
1664 | { |
1665 | resume_momentary ($2); | |
42976354 | 1666 | if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t))) |
46b02c6d | 1667 | note_got_semicolon ($1.t); |
8d08fdba | 1668 | } |
a28e3c7f MS |
1669 | | typed_declspecs initdecls ';' |
1670 | { | |
1671 | resume_momentary ($2); | |
46b02c6d | 1672 | note_list_got_semicolon ($1.t); |
8d08fdba | 1673 | } |
a28e3c7f MS |
1674 | | declmods notype_initdecls ';' |
1675 | { resume_momentary ($2); } | |
8d08fdba MS |
1676 | | typed_declspecs ';' |
1677 | { | |
46b02c6d MS |
1678 | shadow_tag ($1.t); |
1679 | note_list_got_semicolon ($1.t); | |
8d08fdba MS |
1680 | } |
1681 | | declmods ';' | |
1682 | { warning ("empty declaration"); } | |
de22184b MS |
1683 | | extension decl |
1684 | { pedantic = $<itype>1; } | |
8d08fdba MS |
1685 | ; |
1686 | ||
1687 | /* Any kind of declarator (thus, all declarators allowed | |
1688 | after an explicit typespec). */ | |
1689 | ||
1690 | declarator: | |
c11b6f21 MS |
1691 | after_type_declarator %prec EMPTY |
1692 | | notype_declarator %prec EMPTY | |
51c184be MS |
1693 | ; |
1694 | ||
1695 | /* This is necessary to postpone reduction of `int()()()()'. */ | |
1696 | fcast_or_absdcl: | |
c11b6f21 MS |
1697 | LEFT_RIGHT %prec EMPTY |
1698 | { $$ = make_call_declarator (NULL_TREE, empty_parms (), | |
1699 | NULL_TREE, NULL_TREE); } | |
1700 | | fcast_or_absdcl LEFT_RIGHT %prec EMPTY | |
1701 | { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE, | |
1702 | NULL_TREE); } | |
51c184be MS |
1703 | ; |
1704 | ||
1705 | /* ANSI type-id (8.1) */ | |
1706 | type_id: | |
1707 | typed_typespecs absdcl | |
46b02c6d MS |
1708 | { $$.t = build_decl_list ($1.t, $2); |
1709 | $$.new_type_flag = $1.new_type_flag; } | |
c11b6f21 | 1710 | | nonempty_cv_qualifiers absdcl |
46b02c6d MS |
1711 | { $$.t = build_decl_list ($1.t, $2); |
1712 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 1713 | | typespec absdcl |
46b02c6d MS |
1714 | { $$.t = build_decl_list (get_decl_list ($1.t), $2); |
1715 | $$.new_type_flag = $1.new_type_flag; } | |
c11b6f21 | 1716 | | typed_typespecs %prec EMPTY |
46b02c6d MS |
1717 | { $$.t = build_decl_list ($1.t, NULL_TREE); |
1718 | $$.new_type_flag = $1.new_type_flag; } | |
c11b6f21 | 1719 | | nonempty_cv_qualifiers %prec EMPTY |
46b02c6d MS |
1720 | { $$.t = build_decl_list ($1.t, NULL_TREE); |
1721 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba MS |
1722 | ; |
1723 | ||
1724 | /* Declspecs which contain at least one type specifier or typedef name. | |
1725 | (Just `const' or `volatile' is not enough.) | |
f30432d7 MS |
1726 | A typedef'd name following these is taken as a name to be declared. |
1727 | In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */ | |
8d08fdba MS |
1728 | |
1729 | typed_declspecs: | |
c11b6f21 | 1730 | typed_typespecs %prec EMPTY |
51c184be | 1731 | | typed_declspecs1 |
8ccc31eb | 1732 | ; |
51c184be MS |
1733 | |
1734 | typed_declspecs1: | |
1735 | declmods typespec | |
46b02c6d MS |
1736 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1); |
1737 | $$.new_type_flag = $2.new_type_flag; } | |
c11b6f21 | 1738 | | typespec reserved_declspecs %prec HYPERUNARY |
46b02c6d MS |
1739 | { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2); |
1740 | $$.new_type_flag = $1.new_type_flag; } | |
b7484fbe | 1741 | | typespec reserved_typespecquals reserved_declspecs |
46b02c6d MS |
1742 | { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3)); |
1743 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba | 1744 | | declmods typespec reserved_declspecs |
46b02c6d MS |
1745 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1)); |
1746 | $$.new_type_flag = $2.new_type_flag; } | |
8d2733ca | 1747 | | declmods typespec reserved_typespecquals |
46b02c6d MS |
1748 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1)); |
1749 | $$.new_type_flag = $2.new_type_flag; } | |
8d2733ca | 1750 | | declmods typespec reserved_typespecquals reserved_declspecs |
46b02c6d MS |
1751 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, |
1752 | chainon ($3, chainon ($4, $1))); | |
1753 | $$.new_type_flag = $2.new_type_flag; } | |
8d08fdba MS |
1754 | ; |
1755 | ||
51c184be MS |
1756 | reserved_declspecs: |
1757 | SCSPEC | |
8d08fdba MS |
1758 | { if (extra_warnings) |
1759 | warning ("`%s' is not at beginning of declaration", | |
1760 | IDENTIFIER_POINTER ($$)); | |
1761 | $$ = build_decl_list (NULL_TREE, $$); } | |
1762 | | reserved_declspecs typespecqual_reserved | |
46b02c6d | 1763 | { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); } |
8d08fdba MS |
1764 | | reserved_declspecs SCSPEC |
1765 | { if (extra_warnings) | |
1766 | warning ("`%s' is not at beginning of declaration", | |
1767 | IDENTIFIER_POINTER ($2)); | |
1768 | $$ = decl_tree_cons (NULL_TREE, $2, $$); } | |
f30432d7 MS |
1769 | | reserved_declspecs attributes |
1770 | { $$ = decl_tree_cons ($2, NULL_TREE, $1); } | |
1771 | | attributes | |
1772 | { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); } | |
8d08fdba MS |
1773 | ; |
1774 | ||
1775 | /* List of just storage classes and type modifiers. | |
1776 | A declaration can start with just this, but then it cannot be used | |
f30432d7 MS |
1777 | to redeclare a typedef-name. |
1778 | In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */ | |
8d08fdba MS |
1779 | |
1780 | declmods: | |
c11b6f21 | 1781 | nonempty_cv_qualifiers %prec EMPTY |
46b02c6d | 1782 | { $$ = $1.t; TREE_STATIC ($$) = 1; } |
8d08fdba MS |
1783 | | SCSPEC |
1784 | { $$ = IDENTIFIER_AS_LIST ($$); } | |
c11b6f21 | 1785 | | declmods CV_QUALIFIER |
51c184be | 1786 | { $$ = decl_tree_cons (NULL_TREE, $2, $$); |
8d08fdba MS |
1787 | TREE_STATIC ($$) = 1; } |
1788 | | declmods SCSPEC | |
1789 | { if (extra_warnings && TREE_STATIC ($$)) | |
1790 | warning ("`%s' is not at beginning of declaration", | |
1791 | IDENTIFIER_POINTER ($2)); | |
51c184be | 1792 | $$ = decl_tree_cons (NULL_TREE, $2, $$); |
8d08fdba | 1793 | TREE_STATIC ($$) = TREE_STATIC ($1); } |
f30432d7 MS |
1794 | | declmods attributes |
1795 | { $$ = decl_tree_cons ($2, NULL_TREE, $1); } | |
1796 | | attributes | |
1797 | { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); } | |
8d08fdba MS |
1798 | ; |
1799 | ||
8d08fdba MS |
1800 | /* Used instead of declspecs where storage classes are not allowed |
1801 | (that is, for typenames and structure components). | |
1802 | ||
1803 | C++ can takes storage classes for structure components. | |
1804 | Don't accept a typedef-name if anything but a modifier precedes it. */ | |
1805 | ||
1806 | typed_typespecs: | |
1807 | typespec %prec EMPTY | |
46b02c6d MS |
1808 | { $$.t = get_decl_list ($1.t); |
1809 | $$.new_type_flag = $1.new_type_flag; } | |
c11b6f21 | 1810 | | nonempty_cv_qualifiers typespec |
46b02c6d MS |
1811 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t); |
1812 | $$.new_type_flag = $2.new_type_flag; } | |
8d08fdba | 1813 | | typespec reserved_typespecquals |
46b02c6d MS |
1814 | { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2); |
1815 | $$.new_type_flag = $1.new_type_flag; } | |
c11b6f21 | 1816 | | nonempty_cv_qualifiers typespec reserved_typespecquals |
46b02c6d MS |
1817 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t)); |
1818 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba MS |
1819 | ; |
1820 | ||
1821 | reserved_typespecquals: | |
1822 | typespecqual_reserved | |
46b02c6d | 1823 | { $$ = build_decl_list (NULL_TREE, $1.t); } |
8d08fdba | 1824 | | reserved_typespecquals typespecqual_reserved |
46b02c6d | 1825 | { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); } |
8d08fdba MS |
1826 | ; |
1827 | ||
1828 | /* A typespec (but not a type qualifier). | |
1829 | Once we have seen one of these in a declaration, | |
1830 | if a typedef name appears then it is being redeclared. */ | |
1831 | ||
c11b6f21 MS |
1832 | typespec: |
1833 | structsp | |
8d08fdba | 1834 | | TYPESPEC %prec EMPTY |
46b02c6d | 1835 | { $$.t = $1; $$.new_type_flag = 0; } |
a28e3c7f | 1836 | | complete_type_name |
46b02c6d | 1837 | { $$.t = $1; $$.new_type_flag = 0; } |
8d08fdba | 1838 | | TYPEOF '(' expr ')' |
46b02c6d | 1839 | { $$.t = TREE_TYPE ($3); |
6633d636 | 1840 | $$.new_type_flag = 0; } |
51c184be | 1841 | | TYPEOF '(' type_id ')' |
46b02c6d | 1842 | { $$.t = groktypename ($3.t); |
46b02c6d | 1843 | $$.new_type_flag = 0; } |
8d08fdba MS |
1844 | | SIGOF '(' expr ')' |
1845 | { tree type = TREE_TYPE ($3); | |
1846 | ||
46b02c6d | 1847 | $$.new_type_flag = 0; |
8d08fdba MS |
1848 | if (IS_AGGR_TYPE (type)) |
1849 | { | |
1850 | sorry ("sigof type specifier"); | |
46b02c6d | 1851 | $$.t = type; |
8d08fdba MS |
1852 | } |
1853 | else | |
1854 | { | |
1855 | error ("`sigof' applied to non-aggregate expression"); | |
46b02c6d | 1856 | $$.t = error_mark_node; |
8d08fdba MS |
1857 | } |
1858 | } | |
51c184be | 1859 | | SIGOF '(' type_id ')' |
46b02c6d | 1860 | { tree type = groktypename ($3.t); |
8d08fdba | 1861 | |
46b02c6d | 1862 | $$.new_type_flag = 0; |
8d08fdba MS |
1863 | if (IS_AGGR_TYPE (type)) |
1864 | { | |
1865 | sorry ("sigof type specifier"); | |
46b02c6d | 1866 | $$.t = type; |
8d08fdba MS |
1867 | } |
1868 | else | |
1869 | { | |
8d2733ca | 1870 | error("`sigof' applied to non-aggregate type"); |
46b02c6d | 1871 | $$.t = error_mark_node; |
8d08fdba MS |
1872 | } |
1873 | } | |
8d08fdba MS |
1874 | ; |
1875 | ||
1876 | /* A typespec that is a reserved word, or a type qualifier. */ | |
1877 | ||
c11b6f21 MS |
1878 | typespecqual_reserved: |
1879 | TYPESPEC | |
46b02c6d | 1880 | { $$.t = $1; $$.new_type_flag = 0; } |
c11b6f21 | 1881 | | CV_QUALIFIER |
46b02c6d | 1882 | { $$.t = $1; $$.new_type_flag = 0; } |
8d08fdba MS |
1883 | | structsp |
1884 | ; | |
1885 | ||
1886 | initdecls: | |
1887 | initdcl0 | |
1888 | | initdecls ',' initdcl | |
1889 | ; | |
1890 | ||
1891 | notype_initdecls: | |
1892 | notype_initdcl0 | |
1893 | | notype_initdecls ',' initdcl | |
1894 | ; | |
1895 | ||
a28e3c7f MS |
1896 | nomods_initdecls: |
1897 | nomods_initdcl0 | |
1898 | | nomods_initdecls ',' initdcl | |
1899 | ; | |
1900 | ||
8d08fdba MS |
1901 | maybeasm: |
1902 | /* empty */ | |
1903 | { $$ = NULL_TREE; } | |
1904 | | asm_keyword '(' string ')' | |
1905 | { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; } | |
1906 | ; | |
1907 | ||
1908 | initdcl0: | |
c11b6f21 | 1909 | declarator maybeasm maybe_attribute '=' |
f30432d7 MS |
1910 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
1911 | &prefix_attributes); | |
42976354 BK |
1912 | if (current_declspecs |
1913 | && TREE_CODE (current_declspecs) != TREE_LIST) | |
51c184be | 1914 | current_declspecs = get_decl_list (current_declspecs); |
8926095f MS |
1915 | if (have_extern_spec && !used_extern_spec) |
1916 | { | |
1917 | current_declspecs = decl_tree_cons | |
1918 | (NULL_TREE, get_identifier ("extern"), | |
1919 | current_declspecs); | |
1920 | used_extern_spec = 1; | |
1921 | } | |
c11b6f21 MS |
1922 | $<itype>4 = suspend_momentary (); |
1923 | $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1); | |
1924 | cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); } | |
8d08fdba MS |
1925 | init |
1926 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
c11b6f21 MS |
1927 | { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); |
1928 | $$ = $<itype>4; } | |
1929 | | declarator maybeasm maybe_attribute | |
8d08fdba | 1930 | { tree d; |
f30432d7 MS |
1931 | split_specs_attrs ($<ttype>0, ¤t_declspecs, |
1932 | &prefix_attributes); | |
42976354 BK |
1933 | if (current_declspecs |
1934 | && TREE_CODE (current_declspecs) != TREE_LIST) | |
51c184be | 1935 | current_declspecs = get_decl_list (current_declspecs); |
8926095f MS |
1936 | if (have_extern_spec && !used_extern_spec) |
1937 | { | |
1938 | current_declspecs = decl_tree_cons | |
1939 | (NULL_TREE, get_identifier ("extern"), | |
1940 | current_declspecs); | |
1941 | used_extern_spec = 1; | |
1942 | } | |
8d08fdba | 1943 | $$ = suspend_momentary (); |
c11b6f21 MS |
1944 | d = start_decl ($<ttype>1, current_declspecs, 0); |
1945 | cplus_decl_attributes (d, $3, prefix_attributes); | |
1946 | cp_finish_decl (d, NULL_TREE, $2, 1, 0); } | |
8d08fdba MS |
1947 | ; |
1948 | ||
1949 | initdcl: | |
c11b6f21 MS |
1950 | declarator maybeasm maybe_attribute '=' |
1951 | { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1); | |
1952 | cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); } | |
8d08fdba MS |
1953 | init |
1954 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
c11b6f21 MS |
1955 | { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); } |
1956 | | declarator maybeasm maybe_attribute | |
1957 | { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0); | |
1958 | cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); | |
1959 | cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); } | |
8d08fdba MS |
1960 | ; |
1961 | ||
1962 | notype_initdcl0: | |
c11b6f21 | 1963 | notype_declarator maybeasm maybe_attribute '=' |
f30432d7 MS |
1964 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
1965 | &prefix_attributes); | |
c11b6f21 MS |
1966 | $<itype>4 = suspend_momentary (); |
1967 | $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1); | |
1968 | cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); } | |
8d08fdba MS |
1969 | init |
1970 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
c11b6f21 MS |
1971 | { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); |
1972 | $$ = $<itype>4; } | |
1973 | | notype_declarator maybeasm maybe_attribute | |
8d08fdba | 1974 | { tree d; |
f30432d7 MS |
1975 | split_specs_attrs ($<ttype>0, ¤t_declspecs, |
1976 | &prefix_attributes); | |
8d08fdba | 1977 | $$ = suspend_momentary (); |
c11b6f21 MS |
1978 | d = start_decl ($<ttype>1, current_declspecs, 0); |
1979 | cplus_decl_attributes (d, $3, prefix_attributes); | |
1980 | cp_finish_decl (d, NULL_TREE, $2, 1, 0); } | |
8d08fdba MS |
1981 | ; |
1982 | ||
a28e3c7f | 1983 | nomods_initdcl0: |
c11b6f21 | 1984 | notype_declarator maybeasm maybe_attribute '=' |
a28e3c7f | 1985 | { current_declspecs = NULL_TREE; |
f30432d7 | 1986 | prefix_attributes = NULL_TREE; |
c11b6f21 MS |
1987 | $<itype>4 = suspend_momentary (); |
1988 | $<ttype>$ = start_decl ($1, current_declspecs, 1); | |
1989 | cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); } | |
a28e3c7f MS |
1990 | init |
1991 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
c11b6f21 MS |
1992 | { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); |
1993 | $$ = $<itype>4; } | |
1994 | | notype_declarator maybeasm maybe_attribute | |
a28e3c7f MS |
1995 | { tree d; |
1996 | current_declspecs = NULL_TREE; | |
f30432d7 | 1997 | prefix_attributes = NULL_TREE; |
a28e3c7f | 1998 | $$ = suspend_momentary (); |
c11b6f21 MS |
1999 | d = start_decl ($1, current_declspecs, 0); |
2000 | cplus_decl_attributes (d, $3, prefix_attributes); | |
2001 | cp_finish_decl (d, NULL_TREE, $2, 1, 0); } | |
a28e3c7f MS |
2002 | ; |
2003 | ||
8d08fdba | 2004 | /* the * rules are dummies to accept the Apollo extended syntax |
e92cc029 | 2005 | so that the header files compile. */ |
8d08fdba | 2006 | maybe_attribute: |
c11b6f21 | 2007 | /* empty */ |
2986ae00 MS |
2008 | { $$ = NULL_TREE; } |
2009 | | attributes | |
2010 | { $$ = $1; } | |
2011 | ; | |
2012 | ||
2013 | attributes: | |
2014 | attribute | |
2015 | { $$ = $1; } | |
2016 | | attributes attribute | |
2017 | { $$ = chainon ($1, $2); } | |
2018 | ; | |
2019 | ||
2020 | attribute: | |
2021 | ATTRIBUTE '(' '(' attribute_list ')' ')' | |
2022 | { $$ = $4; } | |
2023 | ; | |
2024 | ||
2025 | attribute_list: | |
2026 | attrib | |
44a8d0b3 | 2027 | { $$ = $1; } |
2986ae00 | 2028 | | attribute_list ',' attrib |
44a8d0b3 | 2029 | { $$ = chainon ($1, $3); } |
2986ae00 MS |
2030 | ; |
2031 | ||
2032 | attrib: | |
c11b6f21 | 2033 | /* empty */ |
2986ae00 MS |
2034 | { $$ = NULL_TREE; } |
2035 | | any_word | |
44a8d0b3 | 2036 | { $$ = build_tree_list ($1, NULL_TREE); } |
2986ae00 | 2037 | | any_word '(' IDENTIFIER ')' |
44a8d0b3 | 2038 | { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); } |
2986ae00 | 2039 | | any_word '(' IDENTIFIER ',' nonnull_exprlist ')' |
44a8d0b3 | 2040 | { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); } |
2986ae00 | 2041 | | any_word '(' nonnull_exprlist ')' |
44a8d0b3 | 2042 | { $$ = build_tree_list ($1, $3); } |
2986ae00 MS |
2043 | ; |
2044 | ||
2045 | /* This still leaves out most reserved keywords, | |
2046 | shouldn't we include them? */ | |
2047 | ||
2048 | any_word: | |
2049 | identifier | |
2050 | | SCSPEC | |
2051 | | TYPESPEC | |
c11b6f21 | 2052 | | CV_QUALIFIER |
2986ae00 | 2053 | ; |
8d08fdba MS |
2054 | |
2055 | /* A nonempty list of identifiers, including typenames. */ | |
2056 | identifiers_or_typenames: | |
c11b6f21 | 2057 | identifier |
8d08fdba MS |
2058 | { $$ = build_tree_list (NULL_TREE, $1); } |
2059 | | identifiers_or_typenames ',' identifier | |
2060 | { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); } | |
2061 | ; | |
2062 | ||
e3417fcd | 2063 | maybe_init: |
c11b6f21 | 2064 | /* empty */ %prec EMPTY |
e3417fcd MS |
2065 | { $$ = NULL_TREE; } |
2066 | | '=' init | |
2067 | { $$ = $2; } | |
2068 | ||
5566b478 MS |
2069 | /* If we are processing a template, we don't want to expand this |
2070 | initializer yet. */ | |
2071 | ||
8d08fdba | 2072 | init: |
c11b6f21 | 2073 | expr_no_commas %prec '=' |
8d08fdba MS |
2074 | | '{' '}' |
2075 | { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE); | |
9a0e77ba | 2076 | TREE_HAS_CONSTRUCTOR ($$) = 1; } |
8d08fdba MS |
2077 | | '{' initlist '}' |
2078 | { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); | |
2079 | TREE_HAS_CONSTRUCTOR ($$) = 1; } | |
2080 | | '{' initlist ',' '}' | |
2081 | { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); | |
2082 | TREE_HAS_CONSTRUCTOR ($$) = 1; } | |
2083 | | error | |
2084 | { $$ = NULL_TREE; } | |
2085 | ; | |
2086 | ||
2087 | /* This chain is built in reverse order, | |
2088 | and put in forward order where initlist is used. */ | |
2089 | initlist: | |
2090 | init | |
2091 | { $$ = build_tree_list (NULL_TREE, $$); } | |
2092 | | initlist ',' init | |
2093 | { $$ = tree_cons (NULL_TREE, $3, $$); } | |
2094 | /* These are for labeled elements. */ | |
2095 | | '[' expr_no_commas ']' init | |
2096 | { $$ = build_tree_list ($2, $4); } | |
2097 | | initlist ',' CASE expr_no_commas ':' init | |
2098 | { $$ = tree_cons ($4, $6, $$); } | |
2099 | | identifier ':' init | |
2100 | { $$ = build_tree_list ($$, $3); } | |
2101 | | initlist ',' identifier ':' init | |
2102 | { $$ = tree_cons ($3, $5, $$); } | |
2103 | ; | |
2104 | ||
5566b478 MS |
2105 | fn.defpen: |
2106 | PRE_PARSED_FUNCTION_DECL | |
2107 | { start_function (NULL_TREE, TREE_VALUE ($1), | |
c11b6f21 | 2108 | NULL_TREE, 1); |
5566b478 MS |
2109 | reinit_parse_for_function (); } |
2110 | ||
8dff1027 MS |
2111 | pending_inline: |
2112 | fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error | |
5566b478 | 2113 | { |
fc378698 MS |
2114 | int nested = (hack_decl_function_context |
2115 | (current_function_decl) != NULL_TREE); | |
8dff1027 MS |
2116 | finish_function (lineno, (int)$3, nested); |
2117 | process_next_inline ($1); | |
5566b478 | 2118 | } |
8dff1027 MS |
2119 | | fn.defpen maybe_return_init function_try_block |
2120 | { process_next_inline ($1); } | |
2121 | | fn.defpen maybe_return_init error | |
2122 | { process_next_inline ($1); } | |
2123 | ; | |
2124 | ||
2125 | pending_inlines: | |
2126 | /* empty */ | |
2127 | | pending_inlines pending_inline eat_saved_input | |
5566b478 MS |
2128 | ; |
2129 | ||
42976354 BK |
2130 | /* A regurgitated default argument. The value of DEFARG_MARKER will be |
2131 | the TREE_LIST node for the parameter in question. */ | |
2132 | defarg_again: | |
2133 | DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT | |
2134 | { replace_defarg ($1, $2); } | |
8dff1027 MS |
2135 | | DEFARG_MARKER error END_OF_SAVED_INPUT |
2136 | { replace_defarg ($1, error_mark_node); } | |
42976354 BK |
2137 | |
2138 | pending_defargs: | |
2139 | /* empty */ %prec EMPTY | |
2140 | | pending_defargs defarg_again | |
2141 | { do_pending_defargs (); } | |
2142 | | pending_defargs error | |
2143 | { do_pending_defargs (); } | |
2144 | ; | |
2145 | ||
8d08fdba MS |
2146 | structsp: |
2147 | ENUM identifier '{' | |
2148 | { $<itype>3 = suspend_momentary (); | |
46b02c6d | 2149 | $<ttype>$ = start_enum ($2); } |
8d08fdba | 2150 | enumlist maybecomma_warn '}' |
46b02c6d MS |
2151 | { $$.t = finish_enum ($<ttype>4, $5); |
2152 | $$.new_type_flag = 1; | |
8d08fdba MS |
2153 | resume_momentary ((int) $<itype>3); |
2154 | check_for_missing_semicolon ($<ttype>4); } | |
2155 | | ENUM identifier '{' '}' | |
46b02c6d MS |
2156 | { $$.t = finish_enum (start_enum ($2), NULL_TREE); |
2157 | $$.new_type_flag = 1; | |
2158 | check_for_missing_semicolon ($$.t); } | |
8d08fdba MS |
2159 | | ENUM '{' |
2160 | { $<itype>2 = suspend_momentary (); | |
46b02c6d | 2161 | $<ttype>$ = start_enum (make_anon_name ()); } |
8d08fdba | 2162 | enumlist maybecomma_warn '}' |
46b02c6d | 2163 | { $$.t = finish_enum ($<ttype>3, $4); |
8d08fdba | 2164 | resume_momentary ((int) $<itype>1); |
46b02c6d MS |
2165 | check_for_missing_semicolon ($<ttype>3); |
2166 | $$.new_type_flag = 1; } | |
8d08fdba | 2167 | | ENUM '{' '}' |
46b02c6d MS |
2168 | { $$.t = finish_enum (start_enum (make_anon_name()), NULL_TREE); |
2169 | $$.new_type_flag = 1; | |
2170 | check_for_missing_semicolon ($$.t); } | |
8d08fdba | 2171 | | ENUM identifier |
46b02c6d MS |
2172 | { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1); |
2173 | $$.new_type_flag = 0; } | |
a28e3c7f | 2174 | | ENUM complex_type_name |
46b02c6d MS |
2175 | { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1); |
2176 | $$.new_type_flag = 0; } | |
5566b478 | 2177 | | TYPENAME_KEYWORD nested_name_specifier identifier |
46b02c6d MS |
2178 | { $$.t = make_typename_type ($2, $3); |
2179 | $$.new_type_flag = 0; } | |
5566b478 | 2180 | | TYPENAME_KEYWORD global_scope nested_name_specifier identifier |
46b02c6d MS |
2181 | { $$.t = make_typename_type ($3, $4); |
2182 | $$.new_type_flag = 0; } | |
8d08fdba | 2183 | /* C++ extensions, merged with C to avoid shift/reduce conflicts */ |
2ee887f2 | 2184 | | class_head left_curly opt.component_decl_list '}' maybe_attribute |
8d08fdba MS |
2185 | { |
2186 | int semi; | |
2187 | tree id; | |
2188 | ||
46b02c6d | 2189 | $<ttype>$ = $1; |
8d08fdba MS |
2190 | #if 0 |
2191 | /* Need to rework class nesting in the | |
2192 | presence of nested classes, etc. */ | |
5566b478 | 2193 | shadow_tag (CLASSTYPE_AS_LIST ($1)); */ |
8d08fdba MS |
2194 | #endif |
2195 | if (yychar == YYEMPTY) | |
2196 | yychar = YYLEX; | |
2197 | semi = yychar == ';'; | |
2198 | /* finish_struct nukes this anyway; if | |
e92cc029 | 2199 | finish_exception does too, then it can go. */ |
8d08fdba | 2200 | if (semi) |
5566b478 | 2201 | note_got_semicolon ($1); |
8d08fdba | 2202 | |
5566b478 MS |
2203 | if (TREE_CODE ($1) == ENUMERAL_TYPE) |
2204 | ; | |
8d08fdba MS |
2205 | else |
2206 | { | |
5566b478 MS |
2207 | $<ttype>$ = finish_struct ($1, $3, $5, semi); |
2208 | if (semi) note_got_semicolon ($<ttype>$); | |
8d08fdba MS |
2209 | } |
2210 | ||
2211 | pop_obstacks (); | |
2212 | ||
8d08fdba | 2213 | if (! semi) |
5566b478 | 2214 | check_for_missing_semicolon ($1); |
42976354 | 2215 | if (current_scope () == current_function_decl) |
49c249e1 | 2216 | do_pending_defargs (); |
42976354 BK |
2217 | } |
2218 | pending_defargs | |
2219 | { | |
5566b478 MS |
2220 | if (pending_inlines |
2221 | && current_scope () == current_function_decl) | |
2222 | do_pending_inlines (); | |
2223 | } | |
2224 | pending_inlines | |
42976354 BK |
2225 | { |
2226 | $$.t = $<ttype>6; | |
2227 | $$.new_type_flag = 1; | |
da20811c | 2228 | if (current_class_type == NULL_TREE) |
42976354 BK |
2229 | clear_inline_text_obstack (); |
2230 | } | |
8d08fdba MS |
2231 | | class_head %prec EMPTY |
2232 | { | |
46b02c6d MS |
2233 | $$.t = $1; |
2234 | $$.new_type_flag = 0; | |
8ccc31eb | 2235 | /* struct B: public A; is not accepted by the WP grammar. */ |
46b02c6d MS |
2236 | if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t) |
2237 | && ! TYPE_BEING_DEFINED ($$.t)) | |
8ccc31eb | 2238 | cp_error ("base clause without member specification for `%#T'", |
46b02c6d | 2239 | $$.t); |
8d08fdba MS |
2240 | } |
2241 | ; | |
2242 | ||
2243 | maybecomma: | |
2244 | /* empty */ | |
2245 | | ',' | |
2246 | ; | |
2247 | ||
2248 | maybecomma_warn: | |
2249 | /* empty */ | |
2250 | | ',' | |
594740f3 MS |
2251 | { if (pedantic && !in_system_header) |
2252 | pedwarn ("comma at end of enumerator list"); } | |
8d08fdba MS |
2253 | ; |
2254 | ||
c11b6f21 MS |
2255 | aggr: |
2256 | AGGR | |
8d08fdba MS |
2257 | | aggr SCSPEC |
2258 | { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } | |
2259 | | aggr TYPESPEC | |
2260 | { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } | |
c11b6f21 | 2261 | | aggr CV_QUALIFIER |
8d08fdba MS |
2262 | { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } |
2263 | | aggr AGGR | |
2264 | { error ("no body nor ';' separates two class, struct or union declarations"); } | |
2265 | ; | |
2266 | ||
2267 | named_class_head_sans_basetype: | |
2268 | aggr identifier | |
8d08fdba | 2269 | { current_aggr = $$; $$ = $2; } |
8ccc31eb MS |
2270 | ; |
2271 | ||
2272 | named_class_head_sans_basetype_defn: | |
c11b6f21 | 2273 | aggr identifier_defn %prec EMPTY |
8ccc31eb | 2274 | { current_aggr = $$; $$ = $2; } |
8d08fdba MS |
2275 | ; |
2276 | ||
07674418 MS |
2277 | named_complex_class_head_sans_basetype: |
2278 | aggr nested_name_specifier identifier | |
fc378698 MS |
2279 | { |
2280 | current_aggr = $1; | |
f62dbf03 JM |
2281 | $$ = handle_class_head ($1, $2, $3); |
2282 | } | |
2283 | | aggr global_scope nested_name_specifier identifier | |
2284 | { | |
2285 | current_aggr = $1; | |
2286 | $$ = handle_class_head ($1, $3, $4); | |
2287 | } | |
2288 | | aggr global_scope identifier | |
2289 | { | |
2290 | current_aggr = $1; | |
2291 | $$ = handle_class_head ($1, NULL_TREE, $3); | |
fc378698 | 2292 | } |
5566b478 | 2293 | | aggr template_type |
07674418 | 2294 | { current_aggr = $$; $$ = $2; } |
5566b478 MS |
2295 | | aggr nested_name_specifier template_type |
2296 | { current_aggr = $$; $$ = $3; } | |
07674418 MS |
2297 | ; |
2298 | ||
c11b6f21 MS |
2299 | do_xref_defn: |
2300 | /* empty */ %prec EMPTY | |
2301 | { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); } | |
8ccc31eb | 2302 | ; |
51c184be | 2303 | |
8d08fdba | 2304 | named_class_head: |
c11b6f21 | 2305 | named_class_head_sans_basetype %prec EMPTY |
8ccc31eb MS |
2306 | { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); } |
2307 | | named_class_head_sans_basetype_defn do_xref_defn | |
c11b6f21 | 2308 | maybe_base_class_list %prec EMPTY |
8ccc31eb MS |
2309 | { |
2310 | $$ = $<ttype>2; | |
8d08fdba | 2311 | if ($3) |
8ccc31eb | 2312 | xref_basetypes (current_aggr, $1, $<ttype>2, $3); |
8d08fdba | 2313 | } |
07674418 MS |
2314 | | named_complex_class_head_sans_basetype maybe_base_class_list |
2315 | { | |
2316 | $$ = TREE_TYPE ($1); | |
ec255269 MS |
2317 | if (TREE_INT_CST_LOW (current_aggr) == union_type |
2318 | && TREE_CODE ($$) != UNION_TYPE) | |
2319 | cp_pedwarn ("`union' tag used in declaring `%#T'", $$); | |
2320 | else if (TREE_CODE ($$) == UNION_TYPE | |
2321 | && TREE_INT_CST_LOW (current_aggr) != union_type) | |
2322 | cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$); | |
07674418 | 2323 | if ($2) |
ec255269 MS |
2324 | { |
2325 | if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$)) | |
2326 | { | |
2327 | if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$) | |
2328 | && TYPE_SIZE ($$) == NULL_TREE) | |
73aad9b9 JM |
2329 | { |
2330 | SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$); | |
5156628f | 2331 | if (processing_template_decl) |
73aad9b9 JM |
2332 | push_template_decl (TYPE_MAIN_DECL ($$)); |
2333 | } | |
ec255269 MS |
2334 | else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$)) |
2335 | cp_error ("specialization after instantiation of `%T'", $$); | |
2336 | } | |
2337 | xref_basetypes (current_aggr, $1, $$, $2); | |
2338 | } | |
07674418 | 2339 | } |
8d08fdba MS |
2340 | ; |
2341 | ||
c11b6f21 MS |
2342 | unnamed_class_head: |
2343 | aggr '{' | |
8d08fdba MS |
2344 | { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0); |
2345 | yyungetc ('{', 1); } | |
2346 | ; | |
2347 | ||
c11b6f21 MS |
2348 | class_head: |
2349 | unnamed_class_head | |
2350 | | named_class_head | |
2351 | ; | |
8d08fdba MS |
2352 | |
2353 | maybe_base_class_list: | |
c11b6f21 | 2354 | /* empty */ %prec EMPTY |
8d08fdba | 2355 | { $$ = NULL_TREE; } |
c11b6f21 | 2356 | | ':' see_typename %prec EMPTY |
8d08fdba | 2357 | { yyungetc(':', 1); $$ = NULL_TREE; } |
f30432d7 MS |
2358 | | ':' see_typename base_class_list %prec EMPTY |
2359 | { $$ = $3; } | |
8d08fdba MS |
2360 | ; |
2361 | ||
2362 | base_class_list: | |
2363 | base_class | |
f30432d7 MS |
2364 | | base_class_list ',' see_typename base_class |
2365 | { $$ = chainon ($$, $4); } | |
8d08fdba MS |
2366 | ; |
2367 | ||
2368 | base_class: | |
2369 | base_class.1 | |
2370 | { | |
45537677 | 2371 | tree type = TREE_TYPE ($1); |
be99da77 | 2372 | if (! is_aggr_type (type, 1)) |
8d08fdba MS |
2373 | $$ = NULL_TREE; |
2374 | else if (current_aggr == signature_type_node | |
2375 | && (! type) && (! IS_SIGNATURE (type))) | |
2376 | { | |
2377 | error ("class name not allowed as base signature"); | |
2378 | $$ = NULL_TREE; | |
2379 | } | |
2380 | else if (current_aggr == signature_type_node) | |
2381 | { | |
2382 | sorry ("signature inheritance, base type `%s' ignored", | |
2383 | IDENTIFIER_POINTER ($$)); | |
45537677 | 2384 | $$ = build_tree_list (access_public_node, type); |
8d08fdba MS |
2385 | } |
2386 | else if (type && IS_SIGNATURE (type)) | |
2387 | { | |
2388 | error ("signature name not allowed as base class"); | |
2389 | $$ = NULL_TREE; | |
2390 | } | |
2391 | else | |
45537677 | 2392 | $$ = build_tree_list (access_default_node, type); |
8d08fdba | 2393 | } |
f30432d7 | 2394 | | base_class_access_list see_typename base_class.1 |
8d08fdba | 2395 | { |
45537677 | 2396 | tree type = TREE_TYPE ($3); |
8d08fdba MS |
2397 | if (current_aggr == signature_type_node) |
2398 | error ("access and source specifiers not allowed in signature"); | |
be99da77 | 2399 | if (! IS_AGGR_TYPE (type)) |
8d08fdba MS |
2400 | $$ = NULL_TREE; |
2401 | else if (current_aggr == signature_type_node | |
2402 | && (! type) && (! IS_SIGNATURE (type))) | |
2403 | { | |
2404 | error ("class name not allowed as base signature"); | |
2405 | $$ = NULL_TREE; | |
2406 | } | |
2407 | else if (current_aggr == signature_type_node) | |
2408 | { | |
2409 | sorry ("signature inheritance, base type `%s' ignored", | |
2410 | IDENTIFIER_POINTER ($$)); | |
45537677 | 2411 | $$ = build_tree_list (access_public_node, type); |
8d08fdba MS |
2412 | } |
2413 | else if (type && IS_SIGNATURE (type)) | |
2414 | { | |
2415 | error ("signature name not allowed as base class"); | |
2416 | $$ = NULL_TREE; | |
2417 | } | |
2418 | else | |
45537677 | 2419 | $$ = build_tree_list ($$, type); |
8d08fdba | 2420 | } |
8d08fdba MS |
2421 | ; |
2422 | ||
8d08fdba | 2423 | base_class.1: |
a28e3c7f | 2424 | complete_type_name |
a80e4195 MS |
2425 | | TYPENAME_KEYWORD nested_name_specifier identifier |
2426 | { $$ = TYPE_MAIN_DECL (make_typename_type ($2, $3)); } | |
2427 | | TYPENAME_KEYWORD global_scope nested_name_specifier identifier | |
2428 | { $$ = TYPE_MAIN_DECL (make_typename_type ($3, $4)); } | |
8d08fdba MS |
2429 | | SIGOF '(' expr ')' |
2430 | { | |
2431 | if (current_aggr == signature_type_node) | |
2432 | { | |
2433 | if (IS_AGGR_TYPE (TREE_TYPE ($3))) | |
2434 | { | |
2435 | sorry ("`sigof' as base signature specifier"); | |
be99da77 | 2436 | $$ = TREE_TYPE ($3); |
8d08fdba MS |
2437 | } |
2438 | else | |
2439 | { | |
2440 | error ("`sigof' applied to non-aggregate expression"); | |
2441 | $$ = error_mark_node; | |
2442 | } | |
2443 | } | |
2444 | else | |
2445 | { | |
2446 | error ("`sigof' in struct or class declaration"); | |
2447 | $$ = error_mark_node; | |
2448 | } | |
2449 | } | |
51c184be | 2450 | | SIGOF '(' type_id ')' |
8d08fdba MS |
2451 | { |
2452 | if (current_aggr == signature_type_node) | |
2453 | { | |
46b02c6d | 2454 | if (IS_AGGR_TYPE (groktypename ($3.t))) |
8d08fdba MS |
2455 | { |
2456 | sorry ("`sigof' as base signature specifier"); | |
46b02c6d | 2457 | $$ = groktypename ($3.t); |
8d08fdba MS |
2458 | } |
2459 | else | |
2460 | { | |
2461 | error ("`sigof' applied to non-aggregate expression"); | |
2462 | $$ = error_mark_node; | |
2463 | } | |
2464 | } | |
2465 | else | |
2466 | { | |
2467 | error ("`sigof' in struct or class declaration"); | |
2468 | $$ = error_mark_node; | |
2469 | } | |
2470 | } | |
2471 | ; | |
2472 | ||
2473 | base_class_access_list: | |
f30432d7 MS |
2474 | VISSPEC see_typename |
2475 | | SCSPEC see_typename | |
8d08fdba MS |
2476 | { if ($<ttype>$ != ridpointers[(int)RID_VIRTUAL]) |
2477 | sorry ("non-virtual access"); | |
be99da77 | 2478 | $$ = access_default_virtual_node; } |
f30432d7 | 2479 | | base_class_access_list VISSPEC see_typename |
8d08fdba | 2480 | { int err = 0; |
be99da77 | 2481 | if ($2 == access_protected_node) |
8d08fdba MS |
2482 | { |
2483 | warning ("`protected' access not implemented"); | |
be99da77 | 2484 | $2 = access_public_node; |
8d08fdba MS |
2485 | err++; |
2486 | } | |
be99da77 | 2487 | else if ($2 == access_public_node) |
8d08fdba | 2488 | { |
be99da77 | 2489 | if ($1 == access_private_node) |
8d08fdba MS |
2490 | { |
2491 | mixed: | |
2492 | error ("base class cannot be public and private"); | |
2493 | } | |
be99da77 MS |
2494 | else if ($1 == access_default_virtual_node) |
2495 | $$ = access_public_virtual_node; | |
8d08fdba | 2496 | } |
be99da77 | 2497 | else /* $2 == access_private_node */ |
8d08fdba | 2498 | { |
be99da77 | 2499 | if ($1 == access_public_node) |
8d08fdba | 2500 | goto mixed; |
be99da77 MS |
2501 | else if ($1 == access_default_virtual_node) |
2502 | $$ = access_private_virtual_node; | |
8d08fdba MS |
2503 | } |
2504 | } | |
f30432d7 | 2505 | | base_class_access_list SCSPEC see_typename |
8d08fdba MS |
2506 | { if ($2 != ridpointers[(int)RID_VIRTUAL]) |
2507 | sorry ("non-virtual access"); | |
be99da77 MS |
2508 | if ($$ == access_public_node) |
2509 | $$ = access_public_virtual_node; | |
2510 | else if ($$ == access_private_node) | |
2511 | $$ = access_private_virtual_node; } | |
8d08fdba MS |
2512 | ; |
2513 | ||
c11b6f21 MS |
2514 | left_curly: |
2515 | '{' | |
00595019 | 2516 | { tree t = $<ttype>0; |
8d08fdba MS |
2517 | push_obstacks_nochange (); |
2518 | end_temporary_allocation (); | |
2519 | ||
bd6dd845 MS |
2520 | if (t == error_mark_node |
2521 | || ! IS_AGGR_TYPE (t)) | |
8d08fdba | 2522 | { |
00595019 | 2523 | t = $<ttype>0 = make_lang_type (RECORD_TYPE); |
bd6dd845 | 2524 | pushtag (make_anon_name (), t, 0); |
8d08fdba | 2525 | } |
00595019 MS |
2526 | if (TYPE_SIZE (t)) |
2527 | duplicate_tag_error (t); | |
2528 | if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t)) | |
8d08fdba | 2529 | { |
00595019 | 2530 | t = make_lang_type (TREE_CODE (t)); |
8d08fdba MS |
2531 | pushtag (TYPE_IDENTIFIER ($<ttype>0), t, 0); |
2532 | $<ttype>0 = t; | |
2533 | } | |
5156628f | 2534 | if (processing_template_decl && TYPE_CONTEXT (t) |
5566b478 MS |
2535 | && ! current_class_type) |
2536 | push_template_decl (TYPE_STUB_DECL (t)); | |
00595019 MS |
2537 | pushclass (t, 0); |
2538 | TYPE_BEING_DEFINED (t) = 1; | |
5566b478 MS |
2539 | if (IS_AGGR_TYPE (t) && CLASSTYPE_USE_TEMPLATE (t)) |
2540 | { | |
2541 | if (CLASSTYPE_IMPLICIT_INSTANTIATION (t) | |
2542 | && TYPE_SIZE (t) == NULL_TREE) | |
73aad9b9 JM |
2543 | { |
2544 | SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t); | |
5156628f | 2545 | if (processing_template_decl) |
73aad9b9 JM |
2546 | push_template_decl (TYPE_MAIN_DECL (t)); |
2547 | } | |
5566b478 MS |
2548 | else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t)) |
2549 | cp_error ("specialization after instantiation of `%T'", t); | |
2550 | } | |
00595019 MS |
2551 | /* Reset the interface data, at the earliest possible |
2552 | moment, as it might have been set via a class foo; | |
2553 | before. */ | |
2554 | /* Don't change signatures. */ | |
2555 | if (! IS_SIGNATURE (t)) | |
2556 | { | |
2557 | extern tree pending_vtables; | |
2558 | int needs_writing; | |
2559 | tree name = TYPE_IDENTIFIER (t); | |
2560 | ||
db5ae43f MS |
2561 | if (! ANON_AGGRNAME_P (name)) |
2562 | { | |
2563 | CLASSTYPE_INTERFACE_ONLY (t) = interface_only; | |
2564 | SET_CLASSTYPE_INTERFACE_UNKNOWN_X | |
2565 | (t, interface_unknown); | |
2566 | } | |
00595019 MS |
2567 | |
2568 | /* Record how to set the access of this class's | |
2569 | virtual functions. If write_virtuals == 2 or 3, then | |
2570 | inline virtuals are ``extern inline''. */ | |
2571 | switch (write_virtuals) | |
2572 | { | |
2573 | case 0: | |
2574 | case 1: | |
2575 | needs_writing = 1; | |
2576 | break; | |
2577 | case 2: | |
2578 | needs_writing = !! value_member (name, pending_vtables); | |
2579 | break; | |
2580 | case 3: | |
2581 | needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t) | |
2582 | && CLASSTYPE_INTERFACE_KNOWN (t); | |
2583 | break; | |
2584 | default: | |
2585 | needs_writing = 0; | |
2586 | } | |
2587 | CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing; | |
2588 | } | |
a28e3c7f | 2589 | #if 0 |
8d08fdba MS |
2590 | t = TYPE_IDENTIFIER ($<ttype>0); |
2591 | if (t && IDENTIFIER_TEMPLATE (t)) | |
2592 | overload_template_name (t, 1); | |
a28e3c7f | 2593 | #endif |
8d08fdba MS |
2594 | } |
2595 | ; | |
2596 | ||
c91a56d2 MS |
2597 | self_reference: |
2598 | /* empty */ | |
2599 | { | |
c91a56d2 MS |
2600 | $$ = build_self_reference (); |
2601 | } | |
2602 | ; | |
2603 | ||
8d08fdba | 2604 | opt.component_decl_list: |
c91a56d2 MS |
2605 | self_reference |
2606 | { if ($$) $$ = build_tree_list (access_public_node, $$); } | |
2607 | | self_reference component_decl_list | |
8d08fdba MS |
2608 | { |
2609 | if (current_aggr == signature_type_node) | |
c91a56d2 | 2610 | $$ = build_tree_list (access_public_node, $2); |
8d08fdba | 2611 | else |
c91a56d2 MS |
2612 | $$ = build_tree_list (access_default_node, $2); |
2613 | if ($1) $$ = tree_cons (access_public_node, $1, $$); | |
8d08fdba MS |
2614 | } |
2615 | | opt.component_decl_list VISSPEC ':' component_decl_list | |
2616 | { | |
be99da77 | 2617 | tree visspec = $2; |
8d08fdba MS |
2618 | |
2619 | if (current_aggr == signature_type_node) | |
2620 | { | |
2621 | error ("access specifier not allowed in signature"); | |
be99da77 | 2622 | visspec = access_public_node; |
8d08fdba MS |
2623 | } |
2624 | $$ = chainon ($$, build_tree_list (visspec, $4)); | |
2625 | } | |
2626 | | opt.component_decl_list VISSPEC ':' | |
2627 | { | |
2628 | if (current_aggr == signature_type_node) | |
2629 | error ("access specifier not allowed in signature"); | |
2630 | } | |
2631 | ; | |
2632 | ||
2633 | /* Note: we no longer warn about the semicolon after a component_decl_list. | |
2634 | ARM $9.2 says that the semicolon is optional, and therefore allowed. */ | |
2635 | component_decl_list: | |
2636 | component_decl | |
2637 | { if ($$ == void_type_node) $$ = NULL_TREE; | |
2638 | } | |
2639 | | component_decl_list component_decl | |
2640 | { /* In pushdecl, we created a reverse list of names | |
2641 | in this binding level. Make sure that the chain | |
2642 | of what we're trying to add isn't the item itself | |
2643 | (which can happen with what pushdecl's doing). */ | |
2644 | if ($2 != NULL_TREE && $2 != void_type_node) | |
2645 | { | |
2646 | if (TREE_CHAIN ($2) != $$) | |
2647 | $$ = chainon ($$, $2); | |
2648 | else | |
2649 | $$ = $2; | |
2650 | } | |
2651 | } | |
8d08fdba MS |
2652 | ; |
2653 | ||
2654 | component_decl: | |
a28e3c7f | 2655 | component_decl_1 ';' |
f30432d7 | 2656 | { } |
a28e3c7f MS |
2657 | | component_decl_1 '}' |
2658 | { error ("missing ';' before right brace"); | |
2659 | yyungetc ('}', 0); } | |
2660 | /* C++: handle constructors, destructors and inline functions */ | |
2661 | /* note that INLINE is like a TYPESPEC */ | |
2662 | | fn.def2 ':' /* base_init compstmt */ | |
2663 | { $$ = finish_method ($$); } | |
f30432d7 MS |
2664 | | fn.def2 TRY /* base_init compstmt */ |
2665 | { $$ = finish_method ($$); } | |
2666 | | fn.def2 RETURN /* base_init compstmt */ | |
2667 | { $$ = finish_method ($$); } | |
a28e3c7f MS |
2668 | | fn.def2 '{' /* nodecls compstmt */ |
2669 | { $$ = finish_method ($$); } | |
a5894242 MS |
2670 | | ';' |
2671 | { $$ = NULL_TREE; } | |
de22184b MS |
2672 | | extension component_decl |
2673 | { $$ = $2; | |
2674 | pedantic = $<itype>1; } | |
a28e3c7f MS |
2675 | ; |
2676 | ||
2677 | component_decl_1: | |
2678 | /* Do not add a "typed_declspecs declarator" rule here for | |
51c184be MS |
2679 | speed; we need to call grok_x_components for enums, so the |
2680 | speedup would be insignificant. */ | |
a28e3c7f | 2681 | typed_declspecs components |
46b02c6d | 2682 | { $$ = grok_x_components ($1.t, $2); } |
a28e3c7f | 2683 | | declmods notype_components |
f30432d7 | 2684 | { $$ = grok_x_components ($1, $2); } |
c11b6f21 MS |
2685 | | notype_declarator maybeasm maybe_attribute maybe_init |
2686 | { $$ = grokfield ($$, NULL_TREE, $4, $2, | |
2687 | build_tree_list ($3, NULL_TREE)); } | |
2688 | | constructor_declarator maybeasm maybe_attribute maybe_init | |
2689 | { $$ = grokfield ($$, NULL_TREE, $4, $2, | |
2690 | build_tree_list ($3, NULL_TREE)); } | |
a28e3c7f | 2691 | | ':' expr_no_commas |
8d08fdba | 2692 | { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); } |
8d08fdba MS |
2693 | | error |
2694 | { $$ = NULL_TREE; } | |
2695 | ||
a28e3c7f MS |
2696 | /* These rules introduce a reduce/reduce conflict; in |
2697 | typedef int foo, bar; | |
2698 | class A { | |
2699 | foo (bar); | |
2700 | }; | |
2701 | should "A::foo" be declared as a function or "A::bar" as a data | |
2702 | member? In other words, is "bar" an after_type_declarator or a | |
2703 | parmlist? */ | |
c11b6f21 | 2704 | | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2705 | { tree specs, attrs; |
2706 | split_specs_attrs ($1, &specs, &attrs); | |
c11b6f21 MS |
2707 | $$ = grokfield ($2, specs, $5, $3, |
2708 | build_tree_list ($4, attrs)); } | |
2709 | | component_constructor_declarator maybeasm maybe_attribute maybe_init | |
5156628f MS |
2710 | { $$ = grokfield ($$, NULL_TREE, $4, $2, |
2711 | build_tree_list ($3, NULL_TREE)); } | |
6060a796 | 2712 | | using_decl |
a9aedbc2 | 2713 | { $$ = do_class_using_decl ($1); } |
8d08fdba MS |
2714 | ; |
2715 | ||
e92cc029 | 2716 | /* The case of exactly one component is handled directly by component_decl. */ |
f30432d7 | 2717 | /* ??? Huh? ^^^ */ |
8d08fdba MS |
2718 | components: |
2719 | /* empty: possibly anonymous */ | |
2720 | { $$ = NULL_TREE; } | |
2721 | | component_declarator0 | |
2722 | | components ',' component_declarator | |
2723 | { | |
2724 | /* In this context, void_type_node encodes | |
2725 | friends. They have been recorded elsewhere. */ | |
2726 | if ($$ == void_type_node) | |
2727 | $$ = $3; | |
2728 | else | |
2729 | $$ = chainon ($$, $3); | |
2730 | } | |
2731 | ; | |
2732 | ||
51c184be MS |
2733 | notype_components: |
2734 | /* empty: possibly anonymous */ | |
2735 | { $$ = NULL_TREE; } | |
2736 | | notype_component_declarator0 | |
2737 | | notype_components ',' notype_component_declarator | |
2738 | { | |
2739 | /* In this context, void_type_node encodes | |
2740 | friends. They have been recorded elsewhere. */ | |
2741 | if ($$ == void_type_node) | |
2742 | $$ = $3; | |
2743 | else | |
2744 | $$ = chainon ($$, $3); | |
2745 | } | |
2746 | ; | |
2747 | ||
8d08fdba | 2748 | component_declarator0: |
51c184be MS |
2749 | after_type_component_declarator0 |
2750 | | notype_component_declarator0 | |
2751 | ; | |
2752 | ||
2753 | component_declarator: | |
2754 | after_type_component_declarator | |
2755 | | notype_component_declarator | |
2756 | ; | |
2757 | ||
2758 | after_type_component_declarator0: | |
c11b6f21 | 2759 | after_type_declarator maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2760 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2761 | &prefix_attributes); | |
2762 | $<ttype>0 = current_declspecs; | |
c11b6f21 MS |
2763 | $$ = grokfield ($$, current_declspecs, $4, $2, |
2764 | build_tree_list ($3, prefix_attributes)); } | |
51c184be | 2765 | | TYPENAME ':' expr_no_commas maybe_attribute |
f30432d7 MS |
2766 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2767 | &prefix_attributes); | |
2768 | $<ttype>0 = current_declspecs; | |
8d08fdba | 2769 | $$ = grokbitfield ($$, current_declspecs, $3); |
f6abb50a | 2770 | cplus_decl_attributes ($$, $4, prefix_attributes); } |
51c184be MS |
2771 | ; |
2772 | ||
2773 | notype_component_declarator0: | |
c11b6f21 | 2774 | notype_declarator maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2775 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2776 | &prefix_attributes); | |
2777 | $<ttype>0 = current_declspecs; | |
c11b6f21 MS |
2778 | $$ = grokfield ($$, current_declspecs, $4, $2, |
2779 | build_tree_list ($3, prefix_attributes)); } | |
2780 | | constructor_declarator maybeasm maybe_attribute maybe_init | |
c91a56d2 MS |
2781 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2782 | &prefix_attributes); | |
2783 | $<ttype>0 = current_declspecs; | |
c11b6f21 MS |
2784 | $$ = grokfield ($$, current_declspecs, $4, $2, |
2785 | build_tree_list ($3, prefix_attributes)); } | |
51c184be | 2786 | | IDENTIFIER ':' expr_no_commas maybe_attribute |
f30432d7 MS |
2787 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2788 | &prefix_attributes); | |
2789 | $<ttype>0 = current_declspecs; | |
8d08fdba | 2790 | $$ = grokbitfield ($$, current_declspecs, $3); |
f6abb50a | 2791 | cplus_decl_attributes ($$, $4, prefix_attributes); } |
8d08fdba | 2792 | | ':' expr_no_commas maybe_attribute |
f30432d7 MS |
2793 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2794 | &prefix_attributes); | |
2795 | $<ttype>0 = current_declspecs; | |
39211cd5 | 2796 | $$ = grokbitfield (NULL_TREE, current_declspecs, $2); |
f6abb50a | 2797 | cplus_decl_attributes ($$, $3, prefix_attributes); } |
8d08fdba MS |
2798 | ; |
2799 | ||
51c184be | 2800 | after_type_component_declarator: |
c11b6f21 MS |
2801 | after_type_declarator maybeasm maybe_attribute maybe_init |
2802 | { $$ = grokfield ($$, current_declspecs, $4, $2, | |
2803 | build_tree_list ($3, prefix_attributes)); } | |
51c184be | 2804 | | TYPENAME ':' expr_no_commas maybe_attribute |
8d08fdba | 2805 | { $$ = grokbitfield ($$, current_declspecs, $3); |
f6abb50a | 2806 | cplus_decl_attributes ($$, $4, prefix_attributes); } |
51c184be MS |
2807 | ; |
2808 | ||
2809 | notype_component_declarator: | |
c11b6f21 MS |
2810 | notype_declarator maybeasm maybe_attribute maybe_init |
2811 | { $$ = grokfield ($$, current_declspecs, $4, $2, | |
2812 | build_tree_list ($3, prefix_attributes)); } | |
51c184be | 2813 | | IDENTIFIER ':' expr_no_commas maybe_attribute |
8d08fdba | 2814 | { $$ = grokbitfield ($$, current_declspecs, $3); |
f6abb50a | 2815 | cplus_decl_attributes ($$, $4, prefix_attributes); } |
8d08fdba | 2816 | | ':' expr_no_commas maybe_attribute |
39211cd5 | 2817 | { $$ = grokbitfield (NULL_TREE, current_declspecs, $2); |
f6abb50a | 2818 | cplus_decl_attributes ($$, $3, prefix_attributes); } |
8d08fdba MS |
2819 | ; |
2820 | ||
2821 | /* We chain the enumerators in reverse order. | |
2822 | Because of the way enums are built, the order is | |
2823 | insignificant. Take advantage of this fact. */ | |
2824 | ||
2825 | enumlist: | |
2826 | enumerator | |
2827 | | enumlist ',' enumerator | |
2828 | { TREE_CHAIN ($3) = $$; $$ = $3; } | |
2829 | ; | |
2830 | ||
2831 | enumerator: | |
2832 | identifier | |
2833 | { $$ = build_enumerator ($$, NULL_TREE); } | |
2834 | | identifier '=' expr_no_commas | |
2835 | { $$ = build_enumerator ($$, $3); } | |
2836 | ; | |
2837 | ||
51c184be MS |
2838 | /* ANSI new-type-id (5.3.4) */ |
2839 | new_type_id: | |
a4443a08 | 2840 | type_specifier_seq new_declarator |
46b02c6d MS |
2841 | { $$.t = build_decl_list ($1.t, $2); |
2842 | $$.new_type_flag = $1.new_type_flag; } | |
c11b6f21 | 2843 | | type_specifier_seq %prec EMPTY |
46b02c6d MS |
2844 | { $$.t = build_decl_list ($1.t, NULL_TREE); |
2845 | $$.new_type_flag = $1.new_type_flag; } | |
39211cd5 MS |
2846 | /* GNU extension to allow arrays of arbitrary types with |
2847 | non-constant dimension. */ | |
2848 | | '(' type_id ')' '[' expr ']' | |
2849 | { | |
b7484fbe | 2850 | if (pedantic) |
39211cd5 | 2851 | pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new"); |
46b02c6d MS |
2852 | $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5); |
2853 | $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t); | |
2854 | $$.new_type_flag = $2.new_type_flag; | |
39211cd5 | 2855 | } |
8d08fdba MS |
2856 | ; |
2857 | ||
c11b6f21 MS |
2858 | cv_qualifiers: |
2859 | /* empty */ %prec EMPTY | |
51c184be | 2860 | { $$ = NULL_TREE; } |
c11b6f21 | 2861 | | cv_qualifiers CV_QUALIFIER |
51c184be MS |
2862 | { $$ = decl_tree_cons (NULL_TREE, $2, $$); } |
2863 | ; | |
2864 | ||
c11b6f21 MS |
2865 | nonempty_cv_qualifiers: |
2866 | CV_QUALIFIER | |
46b02c6d MS |
2867 | { $$.t = IDENTIFIER_AS_LIST ($1); |
2868 | $$.new_type_flag = 0; } | |
c11b6f21 | 2869 | | nonempty_cv_qualifiers CV_QUALIFIER |
46b02c6d MS |
2870 | { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t); |
2871 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba MS |
2872 | ; |
2873 | ||
8d08fdba MS |
2874 | /* These rules must follow the rules for function declarations |
2875 | and component declarations. That way, longer rules are preferred. */ | |
2876 | ||
a5894242 | 2877 | suspend_mom: |
c11b6f21 MS |
2878 | /* empty */ |
2879 | { $<itype>$ = suspend_momentary (); } | |
a5894242 | 2880 | |
8d08fdba MS |
2881 | /* An expression which will not live on the momentary obstack. */ |
2882 | nonmomentary_expr: | |
c11b6f21 MS |
2883 | suspend_mom expr |
2884 | { resume_momentary ((int) $<itype>1); $$ = $2; } | |
51c184be | 2885 | ; |
8d08fdba | 2886 | |
a5894242 MS |
2887 | /* An expression which will not live on the momentary obstack. */ |
2888 | maybe_parmlist: | |
2889 | suspend_mom '(' nonnull_exprlist ')' | |
2890 | { resume_momentary ((int) $<itype>1); $$ = $3; } | |
2891 | | suspend_mom '(' parmlist ')' | |
2892 | { resume_momentary ((int) $<itype>1); $$ = $3; } | |
2893 | | suspend_mom LEFT_RIGHT | |
2894 | { resume_momentary ((int) $<itype>1); $$ = empty_parms (); } | |
2895 | | suspend_mom '(' error ')' | |
2896 | { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; } | |
2897 | ; | |
2898 | ||
8d08fdba MS |
2899 | /* A declarator that is allowed only after an explicit typespec. */ |
2900 | /* may all be followed by prec '.' */ | |
2901 | after_type_declarator: | |
c11b6f21 | 2902 | '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY |
46b02c6d | 2903 | { $$ = make_pointer_declarator ($2.t, $3); } |
c11b6f21 | 2904 | | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY |
46b02c6d | 2905 | { $$ = make_reference_declarator ($2.t, $3); } |
a28e3c7f | 2906 | | '*' after_type_declarator %prec UNARY |
51c184be | 2907 | { $$ = make_pointer_declarator (NULL_TREE, $2); } |
a28e3c7f | 2908 | | '&' after_type_declarator %prec UNARY |
51c184be | 2909 | { $$ = make_reference_declarator (NULL_TREE, $2); } |
c11b6f21 | 2910 | | ptr_to_mem cv_qualifiers after_type_declarator |
a28e3c7f MS |
2911 | { tree arg = make_pointer_declarator ($2, $3); |
2912 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
2913 | } |
2914 | | direct_after_type_declarator | |
8d08fdba MS |
2915 | ; |
2916 | ||
cffa8729 | 2917 | complete_type_name: |
c11b6f21 | 2918 | type_name %prec EMPTY |
8d2733ca | 2919 | { |
cffa8729 MS |
2920 | if (TREE_CODE ($1) == IDENTIFIER_NODE) |
2921 | { | |
2922 | if (current_class_type | |
2923 | && TYPE_BEING_DEFINED (current_class_type) | |
cffa8729 MS |
2924 | && ! IDENTIFIER_CLASS_VALUE ($1)) |
2925 | { | |
2926 | /* Be sure to get an inherited typedef. */ | |
2927 | $$ = lookup_name ($1, 1); | |
2928 | /* Remember that this name has been used in the class | |
2929 | definition, as per [class.scope0] */ | |
2930 | pushdecl_class_level ($$); | |
2931 | } | |
2932 | else | |
2933 | $$ = identifier_typedecl_value ($1); | |
2934 | } | |
2935 | else | |
2936 | $$ = $1; | |
2937 | } | |
2938 | | global_scope type_name | |
2939 | { | |
2940 | if (TREE_CODE ($2) == IDENTIFIER_NODE) | |
a80e4195 | 2941 | $$ = identifier_typedecl_value ($2); |
cffa8729 MS |
2942 | else |
2943 | $$ = $2; | |
2944 | got_scope = NULL_TREE; | |
8d2733ca | 2945 | } |
a28e3c7f | 2946 | | nested_type |
cffa8729 MS |
2947 | | global_scope nested_type |
2948 | { $$ = $2; } | |
a28e3c7f MS |
2949 | ; |
2950 | ||
2951 | nested_type: | |
c11b6f21 | 2952 | nested_name_specifier type_name %prec EMPTY |
5566b478 | 2953 | { $$ = get_type_decl ($2); } |
a28e3c7f MS |
2954 | ; |
2955 | ||
51c184be | 2956 | direct_after_type_declarator: |
c11b6f21 MS |
2957 | direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.' |
2958 | { $$ = make_call_declarator ($$, $2, $3, $4); } | |
51c184be | 2959 | | direct_after_type_declarator '[' nonmomentary_expr ']' |
8d08fdba | 2960 | { $$ = build_parse_node (ARRAY_REF, $$, $3); } |
51c184be | 2961 | | direct_after_type_declarator '[' ']' |
8d08fdba | 2962 | { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); } |
a28e3c7f | 2963 | | '(' after_type_declarator ')' |
8d08fdba | 2964 | { $$ = $2; } |
c11b6f21 | 2965 | | nested_name_specifier type_name %prec EMPTY |
c91a56d2 | 2966 | { push_nested_class ($1, 3); |
a28e3c7f MS |
2967 | $$ = build_parse_node (SCOPE_REF, $$, $2); |
2968 | TREE_COMPLEXITY ($$) = current_class_depth; } | |
c11b6f21 | 2969 | | type_name %prec EMPTY |
8d08fdba MS |
2970 | ; |
2971 | ||
2972 | /* A declarator allowed whether or not there has been | |
2973 | an explicit typespec. These cannot redeclare a typedef-name. */ | |
2974 | ||
2975 | notype_declarator: | |
c11b6f21 | 2976 | '*' nonempty_cv_qualifiers notype_declarator %prec UNARY |
46b02c6d | 2977 | { $$ = make_pointer_declarator ($2.t, $3); } |
c11b6f21 | 2978 | | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY |
46b02c6d | 2979 | { $$ = make_reference_declarator ($2.t, $3); } |
a28e3c7f | 2980 | | '*' notype_declarator %prec UNARY |
51c184be | 2981 | { $$ = make_pointer_declarator (NULL_TREE, $2); } |
a28e3c7f | 2982 | | '&' notype_declarator %prec UNARY |
51c184be | 2983 | { $$ = make_reference_declarator (NULL_TREE, $2); } |
c11b6f21 | 2984 | | ptr_to_mem cv_qualifiers notype_declarator |
a28e3c7f MS |
2985 | { tree arg = make_pointer_declarator ($2, $3); |
2986 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
2987 | } |
2988 | | direct_notype_declarator | |
2989 | ; | |
2990 | ||
a28e3c7f | 2991 | complex_notype_declarator: |
c11b6f21 | 2992 | '*' nonempty_cv_qualifiers notype_declarator %prec UNARY |
46b02c6d | 2993 | { $$ = make_pointer_declarator ($2.t, $3); } |
c11b6f21 | 2994 | | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY |
46b02c6d | 2995 | { $$ = make_reference_declarator ($2.t, $3); } |
a28e3c7f | 2996 | | '*' complex_notype_declarator %prec UNARY |
51c184be | 2997 | { $$ = make_pointer_declarator (NULL_TREE, $2); } |
a28e3c7f | 2998 | | '&' complex_notype_declarator %prec UNARY |
51c184be | 2999 | { $$ = make_reference_declarator (NULL_TREE, $2); } |
c11b6f21 | 3000 | | ptr_to_mem cv_qualifiers notype_declarator |
a28e3c7f MS |
3001 | { tree arg = make_pointer_declarator ($2, $3); |
3002 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
3003 | } |
3004 | | complex_direct_notype_declarator | |
3005 | ; | |
3006 | ||
3007 | complex_direct_notype_declarator: | |
c11b6f21 MS |
3008 | direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.' |
3009 | { $$ = make_call_declarator ($$, $2, $3, $4); } | |
a28e3c7f | 3010 | | '(' complex_notype_declarator ')' |
8d08fdba | 3011 | { $$ = $2; } |
51c184be | 3012 | | direct_notype_declarator '[' nonmomentary_expr ']' |
8d08fdba | 3013 | { $$ = build_parse_node (ARRAY_REF, $$, $3); } |
51c184be | 3014 | | direct_notype_declarator '[' ']' |
8d08fdba | 3015 | { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); } |
b7484fbe | 3016 | | notype_qualified_id |
be99da77 | 3017 | { if (OP0 ($$) != current_class_type) |
f30432d7 | 3018 | { |
be99da77 | 3019 | push_nested_class (OP0 ($$), 3); |
f30432d7 MS |
3020 | TREE_COMPLEXITY ($$) = current_class_depth; |
3021 | } | |
3022 | } | |
a28e3c7f | 3023 | ; |
8d08fdba | 3024 | |
a28e3c7f | 3025 | qualified_id: |
c11b6f21 | 3026 | nested_name_specifier unqualified_id |
a28e3c7f MS |
3027 | { got_scope = NULL_TREE; |
3028 | $$ = build_parse_node (SCOPE_REF, $$, $2); } | |
3029 | ; | |
51c184be | 3030 | |
a28e3c7f | 3031 | notype_qualified_id: |
c11b6f21 | 3032 | nested_name_specifier notype_unqualified_id |
a28e3c7f MS |
3033 | { got_scope = NULL_TREE; |
3034 | $$ = build_parse_node (SCOPE_REF, $$, $2); } | |
3035 | ; | |
3036 | ||
3037 | overqualified_id: | |
3038 | notype_qualified_id | |
3039 | | global_scope notype_qualified_id | |
3040 | { $$ = $2; } | |
51c184be MS |
3041 | ; |
3042 | ||
3043 | functional_cast: | |
3044 | typespec '(' nonnull_exprlist ')' | |
46b02c6d | 3045 | { $$ = build_functional_cast ($1.t, $3); } |
51c184be | 3046 | | typespec '(' expr_or_declarator ')' |
46b02c6d | 3047 | { $$ = reparse_decl_as_expr ($1.t, $3); } |
c11b6f21 | 3048 | | typespec fcast_or_absdcl %prec EMPTY |
46b02c6d | 3049 | { $$ = reparse_absdcl_as_expr ($1.t, $2); } |
8d08fdba MS |
3050 | ; |
3051 | ||
a28e3c7f MS |
3052 | type_name: |
3053 | TYPENAME | |
a80e4195 | 3054 | | SELFNAME |
c11b6f21 | 3055 | | template_type %prec EMPTY |
a28e3c7f | 3056 | ; |
8d08fdba | 3057 | |
a28e3c7f MS |
3058 | nested_name_specifier: |
3059 | nested_name_specifier_1 | |
3060 | | nested_name_specifier nested_name_specifier_1 | |
3061 | { $$ = $2; } | |
3062 | ; | |
3063 | ||
3064 | /* Why the @#$%^& do type_name and notype_identifier need to be expanded | |
3065 | inline here?!? (jason) */ | |
3066 | nested_name_specifier_1: | |
3067 | TYPENAME SCOPE | |
45537677 | 3068 | { |
a80e4195 MS |
3069 | if (TREE_CODE ($1) == IDENTIFIER_NODE) |
3070 | { | |
3071 | $$ = lastiddecl; | |
3072 | /* Remember that this name has been used in the class | |
3073 | definition, as per [class.scope0] */ | |
3074 | if (current_class_type | |
3075 | && TYPE_BEING_DEFINED (current_class_type) | |
3076 | && ! IDENTIFIER_CLASS_VALUE ($1)) | |
3077 | pushdecl_class_level ($$); | |
3078 | } | |
3079 | got_scope = $$ = TREE_TYPE ($$); | |
3080 | } | |
3081 | | SELFNAME SCOPE | |
3082 | { | |
3083 | if (TREE_CODE ($1) == IDENTIFIER_NODE) | |
3084 | $$ = lastiddecl; | |
45537677 MS |
3085 | got_scope = $$ = TREE_TYPE ($$); |
3086 | } | |
6060a796 | 3087 | | NSNAME SCOPE |
6633d636 MS |
3088 | { |
3089 | if (TREE_CODE ($$) == IDENTIFIER_NODE) | |
3090 | $$ = lastiddecl; | |
3091 | if (TREE_CODE ($$) == NAMESPACE_DECL | |
3092 | && DECL_NAME ($$) == get_identifier ("std")) | |
3093 | got_scope = void_type_node; | |
3094 | else | |
3095 | got_scope = $$; | |
3096 | } | |
a28e3c7f | 3097 | | template_type SCOPE |
5566b478 | 3098 | { got_scope = $$ = complete_type (TREE_TYPE ($1)); } |
a28e3c7f | 3099 | /* These break 'const i;' |
8d08fdba | 3100 | | IDENTIFIER SCOPE |
8d08fdba | 3101 | { |
a28e3c7f MS |
3102 | failed_scope: |
3103 | cp_error ("`%D' is not an aggregate typedef", | |
3104 | lastiddecl ? lastiddecl : $$); | |
3105 | $$ = error_mark_node; | |
8d08fdba | 3106 | } |
a28e3c7f MS |
3107 | | PTYPENAME SCOPE |
3108 | { goto failed_scope; } */ | |
8d08fdba MS |
3109 | ; |
3110 | ||
a28e3c7f | 3111 | complex_type_name: |
cffa8729 MS |
3112 | global_scope type_name |
3113 | { | |
3114 | if (TREE_CODE ($2) == IDENTIFIER_NODE) | |
a80e4195 | 3115 | $$ = identifier_typedecl_value ($2); |
cffa8729 MS |
3116 | else |
3117 | $$ = $2; | |
3118 | got_scope = NULL_TREE; | |
3119 | } | |
3120 | | nested_type | |
3121 | | global_scope nested_type | |
a28e3c7f MS |
3122 | { $$ = $2; } |
3123 | ; | |
3124 | ||
3125 | ptr_to_mem: | |
3126 | nested_name_specifier '*' | |
3127 | { got_scope = NULL_TREE; } | |
3128 | | global_scope nested_name_specifier '*' | |
3129 | { $$ = $2; got_scope = NULL_TREE; } | |
3130 | ; | |
3131 | ||
3132 | /* All uses of explicit global scope must go through this nonterminal so | |
e92cc029 | 3133 | that got_scope will be set before yylex is called to get the next token. */ |
a28e3c7f MS |
3134 | global_scope: |
3135 | SCOPE | |
3136 | { got_scope = void_type_node; } | |
8d08fdba MS |
3137 | ; |
3138 | ||
51c184be MS |
3139 | /* ANSI new-declarator (5.3.4) */ |
3140 | new_declarator: | |
c11b6f21 | 3141 | '*' cv_qualifiers new_declarator |
8d08fdba | 3142 | { $$ = make_pointer_declarator ($2, $3); } |
c11b6f21 | 3143 | | '*' cv_qualifiers %prec EMPTY |
8d08fdba | 3144 | { $$ = make_pointer_declarator ($2, NULL_TREE); } |
c11b6f21 | 3145 | | '&' cv_qualifiers new_declarator %prec EMPTY |
51c184be | 3146 | { $$ = make_reference_declarator ($2, $3); } |
c11b6f21 | 3147 | | '&' cv_qualifiers %prec EMPTY |
51c184be | 3148 | { $$ = make_reference_declarator ($2, NULL_TREE); } |
c11b6f21 | 3149 | | ptr_to_mem cv_qualifiers %prec EMPTY |
a28e3c7f MS |
3150 | { tree arg = make_pointer_declarator ($2, NULL_TREE); |
3151 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be | 3152 | } |
c11b6f21 | 3153 | | ptr_to_mem cv_qualifiers new_declarator |
a28e3c7f MS |
3154 | { tree arg = make_pointer_declarator ($2, $3); |
3155 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be | 3156 | } |
c11b6f21 | 3157 | | direct_new_declarator %prec EMPTY |
51c184be MS |
3158 | ; |
3159 | ||
3160 | /* ANSI direct-new-declarator (5.3.4) */ | |
3161 | direct_new_declarator: | |
3162 | '[' expr ']' | |
3163 | { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); } | |
3164 | | direct_new_declarator '[' nonmomentary_expr ']' | |
3165 | { $$ = build_parse_node (ARRAY_REF, $$, $3); } | |
3166 | ; | |
3167 | ||
3168 | /* ANSI abstract-declarator (8.1) */ | |
a28e3c7f | 3169 | absdcl: |
c11b6f21 | 3170 | '*' nonempty_cv_qualifiers absdcl |
46b02c6d | 3171 | { $$ = make_pointer_declarator ($2.t, $3); } |
a28e3c7f | 3172 | | '*' absdcl |
51c184be | 3173 | { $$ = make_pointer_declarator (NULL_TREE, $2); } |
c11b6f21 | 3174 | | '*' nonempty_cv_qualifiers %prec EMPTY |
46b02c6d | 3175 | { $$ = make_pointer_declarator ($2.t, NULL_TREE); } |
c11b6f21 | 3176 | | '*' %prec EMPTY |
a0a33927 | 3177 | { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); } |
c11b6f21 | 3178 | | '&' nonempty_cv_qualifiers absdcl |
46b02c6d | 3179 | { $$ = make_reference_declarator ($2.t, $3); } |
a28e3c7f | 3180 | | '&' absdcl |
51c184be | 3181 | { $$ = make_reference_declarator (NULL_TREE, $2); } |
c11b6f21 | 3182 | | '&' nonempty_cv_qualifiers %prec EMPTY |
46b02c6d | 3183 | { $$ = make_reference_declarator ($2.t, NULL_TREE); } |
c11b6f21 | 3184 | | '&' %prec EMPTY |
a0a33927 | 3185 | { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); } |
c11b6f21 | 3186 | | ptr_to_mem cv_qualifiers %prec EMPTY |
a28e3c7f MS |
3187 | { tree arg = make_pointer_declarator ($2, NULL_TREE); |
3188 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be | 3189 | } |
c11b6f21 | 3190 | | ptr_to_mem cv_qualifiers absdcl |
a28e3c7f MS |
3191 | { tree arg = make_pointer_declarator ($2, $3); |
3192 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be | 3193 | } |
c11b6f21 | 3194 | | direct_abstract_declarator %prec EMPTY |
51c184be MS |
3195 | ; |
3196 | ||
3197 | /* ANSI direct-abstract-declarator (8.1) */ | |
3198 | direct_abstract_declarator: | |
a28e3c7f MS |
3199 | '(' absdcl ')' |
3200 | { $$ = $2; } | |
51c184be MS |
3201 | /* `(typedef)1' is `int'. */ |
3202 | | PAREN_STAR_PAREN | |
c11b6f21 MS |
3203 | | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.' |
3204 | { $$ = make_call_declarator ($$, $3, $5, $6); } | |
3205 | | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.' | |
3206 | { $$ = make_call_declarator ($$, empty_parms (), $3, $4); } | |
51c184be | 3207 | | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.' |
8d08fdba | 3208 | { $$ = build_parse_node (ARRAY_REF, $$, $3); } |
51c184be | 3209 | | direct_abstract_declarator '[' ']' %prec '.' |
8d08fdba | 3210 | { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); } |
c11b6f21 MS |
3211 | | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.' |
3212 | { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); } | |
3213 | | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.' | |
3214 | { set_quals_and_spec ($$, $2, $3); } | |
3215 | | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.' | |
3216 | { set_quals_and_spec ($$, $2, $3); } | |
8d08fdba MS |
3217 | | '[' nonmomentary_expr ']' %prec '.' |
3218 | { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); } | |
3219 | | '[' ']' %prec '.' | |
3220 | { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); } | |
3221 | ; | |
3222 | ||
8d08fdba MS |
3223 | /* For C++, decls and stmts can be intermixed, so we don't need to |
3224 | have a special rule that won't start parsing the stmt section | |
3225 | until we have a stmt that parses without errors. */ | |
3226 | ||
3227 | stmts: | |
3228 | stmt | |
3229 | | errstmt | |
3230 | | stmts stmt | |
3231 | | stmts errstmt | |
3232 | ; | |
3233 | ||
c11b6f21 MS |
3234 | errstmt: |
3235 | error ';' | |
8d08fdba MS |
3236 | ; |
3237 | ||
3238 | /* build the LET_STMT node before parsing its contents, | |
3239 | so that any LET_STMTs within the context can have their display pointers | |
3240 | set up to point at this one. */ | |
3241 | ||
c11b6f21 MS |
3242 | .pushlevel: |
3243 | /* empty */ | |
5566b478 | 3244 | { do_pushlevel (); } |
8d08fdba MS |
3245 | ; |
3246 | ||
c11b6f21 MS |
3247 | .poplevel: |
3248 | /* empty */ | |
5566b478 | 3249 | { $$ = do_poplevel (); } |
863adfc0 MS |
3250 | ; |
3251 | ||
8d08fdba MS |
3252 | /* Read zero or more forward-declarations for labels |
3253 | that nested functions can jump to. */ | |
3254 | maybe_label_decls: | |
3255 | /* empty */ | |
3256 | | label_decls | |
b7484fbe | 3257 | { if (pedantic) |
8d08fdba MS |
3258 | pedwarn ("ANSI C++ forbids label declarations"); } |
3259 | ; | |
3260 | ||
3261 | label_decls: | |
3262 | label_decl | |
3263 | | label_decls label_decl | |
3264 | ; | |
3265 | ||
3266 | label_decl: | |
3267 | LABEL identifiers_or_typenames ';' | |
3268 | { tree link; | |
3269 | for (link = $2; link; link = TREE_CHAIN (link)) | |
3270 | { | |
3271 | tree label = shadow_label (TREE_VALUE (link)); | |
3272 | C_DECLARED_LABEL_FLAG (label) = 1; | |
3273 | declare_nonlocal_label (label); | |
3274 | } | |
3275 | } | |
3276 | ; | |
3277 | ||
3278 | /* This is the body of a function definition. | |
3279 | It causes syntax errors to ignore to the next openbrace. */ | |
3280 | compstmt_or_error: | |
3281 | compstmt | |
3282 | {} | |
3283 | | error compstmt | |
3284 | ; | |
3285 | ||
c11b6f21 MS |
3286 | compstmt: |
3287 | '{' | |
5566b478 | 3288 | { |
5156628f | 3289 | if (processing_template_decl) |
5566b478 MS |
3290 | { |
3291 | $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE); | |
3292 | add_tree ($<ttype>$); | |
3293 | } | |
3294 | } | |
3295 | .pushlevel compstmtend .poplevel | |
3296 | { | |
5156628f | 3297 | if (processing_template_decl) |
5566b478 MS |
3298 | { |
3299 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
3300 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3301 | last_tree = $<ttype>2; | |
3302 | } | |
3303 | $$ = $5; | |
3304 | } | |
8d08fdba MS |
3305 | ; |
3306 | ||
3307 | simple_if: | |
3308 | IF | |
5566b478 | 3309 | { |
5156628f | 3310 | if (processing_template_decl) |
5566b478 MS |
3311 | { |
3312 | $<ttype>$ = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE, | |
3313 | NULL_TREE); | |
3314 | add_tree ($<ttype>$); | |
3315 | } | |
3316 | cond_stmt_keyword = "if"; | |
3317 | } | |
8d08fdba | 3318 | .pushlevel paren_cond_or_null |
5566b478 | 3319 | { |
5156628f | 3320 | if (processing_template_decl) |
5566b478 MS |
3321 | { |
3322 | if (last_tree != $<ttype>2) | |
3323 | { | |
3324 | TREE_OPERAND ($<ttype>2, 0) = last_tree; | |
3325 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3326 | last_tree = $<ttype>2; | |
3327 | } | |
3328 | else | |
3329 | TREE_OPERAND ($<ttype>2, 0) = $4; | |
3330 | } | |
3331 | else | |
3332 | { | |
3333 | emit_line_note (input_filename, lineno); | |
3334 | expand_start_cond ($4, 0); | |
3335 | } | |
3336 | } | |
8d2733ca | 3337 | implicitly_scoped_stmt |
5566b478 | 3338 | { |
5156628f | 3339 | if (processing_template_decl) |
5566b478 MS |
3340 | { |
3341 | TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2); | |
3342 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3343 | $<ttype>$ = last_tree = $<ttype>2; | |
3344 | } | |
3345 | } | |
8d08fdba MS |
3346 | ; |
3347 | ||
3348 | implicitly_scoped_stmt: | |
3349 | compstmt | |
3350 | { finish_stmt (); } | |
5566b478 MS |
3351 | | .pushlevel |
3352 | { | |
5156628f | 3353 | if (processing_template_decl) |
5566b478 MS |
3354 | { |
3355 | $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE); | |
3356 | add_tree ($<ttype>$); | |
3357 | } | |
3358 | } | |
3359 | simple_stmt .poplevel | |
3360 | { | |
5156628f | 3361 | if (processing_template_decl) |
5566b478 MS |
3362 | { |
3363 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
3364 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3365 | last_tree = $<ttype>2; | |
3366 | } | |
3367 | $$ = $4; | |
3368 | } | |
8d08fdba MS |
3369 | ; |
3370 | ||
3371 | stmt: | |
3372 | compstmt | |
3373 | { finish_stmt (); } | |
3374 | | simple_stmt | |
3375 | ; | |
3376 | ||
3377 | simple_stmt: | |
3378 | decl | |
f30432d7 | 3379 | { finish_stmt (); } |
8d08fdba MS |
3380 | | expr ';' |
3381 | { | |
8d2733ca | 3382 | tree expr = $1; |
5156628f | 3383 | if (! processing_template_decl) |
5566b478 MS |
3384 | { |
3385 | emit_line_note (input_filename, lineno); | |
3386 | /* Do default conversion if safe and possibly important, | |
3387 | in case within ({...}). */ | |
3388 | if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE | |
3389 | && lvalue_p (expr)) | |
3390 | || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE) | |
3391 | expr = default_conversion (expr); | |
3392 | } | |
8d08fdba MS |
3393 | cplus_expand_expr_stmt (expr); |
3394 | clear_momentary (); | |
3395 | finish_stmt (); } | |
3396 | | simple_if ELSE | |
5156628f | 3397 | { if (! processing_template_decl) expand_start_else (); } |
8d2733ca | 3398 | implicitly_scoped_stmt |
5566b478 | 3399 | { |
5156628f | 3400 | if (processing_template_decl) |
5566b478 MS |
3401 | { |
3402 | TREE_OPERAND ($<ttype>1, 2) = TREE_CHAIN ($<ttype>1); | |
3403 | TREE_CHAIN ($<ttype>1) = NULL_TREE; | |
3404 | last_tree = $<ttype>1; | |
3405 | } | |
3406 | else | |
3407 | expand_end_cond (); | |
3408 | } | |
863adfc0 MS |
3409 | .poplevel |
3410 | { finish_stmt (); } | |
c11b6f21 | 3411 | | simple_if %prec IF |
5156628f | 3412 | { if (! processing_template_decl) expand_end_cond (); |
c11b6f21 | 3413 | do_poplevel (); |
8d08fdba MS |
3414 | finish_stmt (); } |
3415 | | WHILE | |
5566b478 | 3416 | { |
5156628f | 3417 | if (processing_template_decl) |
5566b478 MS |
3418 | { |
3419 | $<ttype>$ = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE); | |
3420 | add_tree ($<ttype>$); | |
3421 | } | |
3422 | else | |
3423 | { | |
3424 | emit_nop (); | |
3425 | emit_line_note (input_filename, lineno); | |
3426 | expand_start_loop (1); | |
3427 | } | |
3428 | cond_stmt_keyword = "while"; | |
3429 | } | |
8d08fdba | 3430 | .pushlevel paren_cond_or_null |
5566b478 | 3431 | { |
5156628f | 3432 | if (processing_template_decl) |
5566b478 MS |
3433 | { |
3434 | if (last_tree != $<ttype>2) | |
3435 | { | |
3436 | TREE_OPERAND ($<ttype>2, 0) = last_tree; | |
3437 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3438 | last_tree = $<ttype>2; | |
3439 | } | |
3440 | else | |
3441 | TREE_OPERAND ($<ttype>2, 0) = $4; | |
3442 | } | |
3443 | else | |
3444 | { | |
3445 | emit_line_note (input_filename, lineno); | |
3446 | expand_exit_loop_if_false (0, $4); | |
3447 | } | |
3448 | } | |
863adfc0 | 3449 | already_scoped_stmt .poplevel |
5566b478 | 3450 | { |
5156628f | 3451 | if (processing_template_decl) |
5566b478 MS |
3452 | { |
3453 | TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2); | |
3454 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3455 | last_tree = $<ttype>2; | |
3456 | } | |
3457 | else | |
3458 | expand_end_loop (); | |
3459 | finish_stmt (); | |
3460 | } | |
8d08fdba | 3461 | | DO |
5566b478 | 3462 | { |
5156628f | 3463 | if (processing_template_decl) |
5566b478 MS |
3464 | { |
3465 | $<ttype>$ = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE); | |
3466 | add_tree ($<ttype>$); | |
3467 | } | |
3468 | else | |
3469 | { | |
3470 | emit_nop (); | |
3471 | emit_line_note (input_filename, lineno); | |
3472 | expand_start_loop_continue_elsewhere (1); | |
3473 | } | |
3474 | } | |
8d08fdba | 3475 | implicitly_scoped_stmt WHILE |
5566b478 | 3476 | { |
5156628f | 3477 | if (processing_template_decl) |
5566b478 MS |
3478 | { |
3479 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
3480 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3481 | last_tree = $<ttype>2; | |
3482 | } | |
3483 | else | |
3484 | { | |
3485 | expand_loop_continue_here (); | |
3486 | cond_stmt_keyword = "do"; | |
3487 | } | |
3488 | } | |
8d08fdba | 3489 | paren_expr_or_null ';' |
5566b478 | 3490 | { |
5156628f | 3491 | if (processing_template_decl) |
5566b478 MS |
3492 | TREE_OPERAND ($<ttype>2, 1) = $6; |
3493 | else | |
3494 | { | |
3495 | emit_line_note (input_filename, lineno); | |
3496 | expand_exit_loop_if_false (0, $6); | |
3497 | expand_end_loop (); | |
3498 | } | |
8d08fdba | 3499 | clear_momentary (); |
5566b478 MS |
3500 | finish_stmt (); |
3501 | } | |
863adfc0 | 3502 | | FOR |
5156628f | 3503 | { if (processing_template_decl) |
5566b478 MS |
3504 | { |
3505 | $<ttype>$ = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE, | |
3506 | NULL_TREE, NULL_TREE); | |
3507 | add_tree ($<ttype>$); | |
3508 | } | |
3509 | else | |
3510 | emit_line_note (input_filename, lineno); | |
c7fdde6d | 3511 | if (flag_new_for_scope > 0) |
863adfc0 MS |
3512 | { |
3513 | /* Conditionalize .pushlevel */ | |
3514 | pushlevel (0); | |
c7fdde6d | 3515 | note_level_for_for (); |
863adfc0 MS |
3516 | clear_last_expr (); |
3517 | push_momentary (); | |
3518 | expand_start_bindings (0); | |
3519 | } | |
3520 | } | |
3521 | '(' for.init.statement | |
5566b478 | 3522 | { |
5156628f | 3523 | if (processing_template_decl) |
5566b478 MS |
3524 | { |
3525 | if (last_tree != $<ttype>2) | |
3526 | { | |
e76a2646 | 3527 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); |
5566b478 MS |
3528 | TREE_CHAIN ($<ttype>2) = NULL_TREE; |
3529 | last_tree = $<ttype>2; | |
3530 | } | |
3531 | } | |
3532 | else | |
3533 | { | |
3534 | emit_nop (); | |
3535 | emit_line_note (input_filename, lineno); | |
3536 | expand_start_loop_continue_elsewhere (1); | |
3537 | } | |
3538 | } | |
8d08fdba | 3539 | .pushlevel xcond ';' |
5566b478 | 3540 | { |
5156628f | 3541 | if (processing_template_decl) |
5566b478 MS |
3542 | { |
3543 | if (last_tree != $<ttype>2) | |
3544 | { | |
3545 | TREE_OPERAND ($<ttype>2, 1) = last_tree; | |
3546 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3547 | last_tree = $<ttype>2; | |
3548 | } | |
3549 | else | |
3550 | TREE_OPERAND ($<ttype>2, 1) = $7; | |
3551 | } | |
3552 | else | |
3553 | { | |
3554 | emit_line_note (input_filename, lineno); | |
3555 | if ($7) expand_exit_loop_if_false (0, $7); | |
3556 | } | |
3557 | } | |
8d08fdba | 3558 | xexpr ')' |
863adfc0 | 3559 | /* Don't let the tree nodes for $10 be discarded |
8d08fdba | 3560 | by clear_momentary during the parsing of the next stmt. */ |
5566b478 | 3561 | { |
5156628f | 3562 | if (processing_template_decl) |
5566b478 MS |
3563 | TREE_OPERAND ($<ttype>2, 2) = $10; |
3564 | push_momentary (); | |
3565 | } | |
863adfc0 | 3566 | already_scoped_stmt .poplevel |
5566b478 | 3567 | { |
5156628f | 3568 | if (processing_template_decl) |
5566b478 MS |
3569 | { |
3570 | TREE_OPERAND ($<ttype>2, 3) = TREE_CHAIN ($<ttype>2); | |
3571 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3572 | last_tree = $<ttype>2; | |
3573 | } | |
3574 | else | |
3575 | { | |
3576 | emit_line_note (input_filename, lineno); | |
3577 | expand_loop_continue_here (); | |
3578 | if ($10) cplus_expand_expr_stmt ($10); | |
3579 | expand_end_loop (); | |
3580 | } | |
a4443a08 | 3581 | pop_momentary (); |
c7fdde6d | 3582 | if (flag_new_for_scope > 0) |
863adfc0 | 3583 | { |
c11b6f21 | 3584 | do_poplevel (); |
863adfc0 | 3585 | } |
8d08fdba | 3586 | finish_stmt (); } |
8d08fdba | 3587 | | SWITCH .pushlevel '(' condition ')' |
5566b478 | 3588 | { |
5156628f | 3589 | if (processing_template_decl) |
5566b478 MS |
3590 | { |
3591 | $<ttype>$ = build_min_nt (SWITCH_STMT, $4, NULL_TREE); | |
3592 | add_tree ($<ttype>$); | |
3593 | } | |
3594 | else | |
3595 | { | |
3596 | emit_line_note (input_filename, lineno); | |
3597 | c_expand_start_case ($4); | |
3598 | } | |
a5894242 | 3599 | push_switch (); |
8d08fdba MS |
3600 | /* Don't let the tree nodes for $4 be discarded by |
3601 | clear_momentary during the parsing of the next stmt. */ | |
5566b478 MS |
3602 | push_momentary (); |
3603 | } | |
8d2733ca | 3604 | implicitly_scoped_stmt |
5566b478 | 3605 | { |
5156628f | 3606 | if (processing_template_decl) |
5566b478 MS |
3607 | { |
3608 | TREE_OPERAND ($<ttype>6, 1) = TREE_CHAIN ($<ttype>6); | |
3609 | TREE_CHAIN ($<ttype>6) = NULL_TREE; | |
3610 | last_tree = $<ttype>6; | |
3611 | } | |
3612 | else | |
3613 | expand_end_case ($4); | |
8d08fdba | 3614 | pop_momentary (); |
5566b478 MS |
3615 | pop_switch (); |
3616 | } | |
863adfc0 MS |
3617 | .poplevel |
3618 | { finish_stmt (); } | |
8d08fdba | 3619 | | CASE expr_no_commas ':' |
5566b478 | 3620 | { do_case ($2, NULL_TREE); } |
8d08fdba | 3621 | stmt |
f0e01782 | 3622 | | CASE expr_no_commas ELLIPSIS expr_no_commas ':' |
5566b478 | 3623 | { do_case ($2, $4); } |
8d08fdba MS |
3624 | stmt |
3625 | | DEFAULT ':' | |
5566b478 | 3626 | { do_case (NULL_TREE, NULL_TREE); } |
8d08fdba MS |
3627 | stmt |
3628 | | BREAK ';' | |
3629 | { emit_line_note (input_filename, lineno); | |
5156628f | 3630 | if (processing_template_decl) |
5566b478 MS |
3631 | add_tree (build_min_nt (BREAK_STMT)); |
3632 | else if ( ! expand_exit_something ()) | |
8d08fdba MS |
3633 | error ("break statement not within loop or switch"); } |
3634 | | CONTINUE ';' | |
3635 | { emit_line_note (input_filename, lineno); | |
5156628f | 3636 | if (processing_template_decl) |
5566b478 MS |
3637 | add_tree (build_min_nt (CONTINUE_STMT)); |
3638 | else if (! expand_continue_loop (0)) | |
8d08fdba MS |
3639 | error ("continue statement not within a loop"); } |
3640 | | RETURN ';' | |
3641 | { emit_line_note (input_filename, lineno); | |
3642 | c_expand_return (NULL_TREE); } | |
3643 | | RETURN expr ';' | |
3644 | { emit_line_note (input_filename, lineno); | |
3645 | c_expand_return ($2); | |
3646 | finish_stmt (); | |
3647 | } | |
c11b6f21 | 3648 | | asm_keyword maybe_cv_qualifier '(' string ')' ';' |
8d08fdba MS |
3649 | { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); |
3650 | emit_line_note (input_filename, lineno); | |
3651 | expand_asm ($4); | |
3652 | finish_stmt (); | |
3653 | } | |
3654 | /* This is the case with just output operands. */ | |
c11b6f21 | 3655 | | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';' |
8d08fdba MS |
3656 | { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); |
3657 | emit_line_note (input_filename, lineno); | |
3658 | c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE, | |
3659 | $2 == ridpointers[(int)RID_VOLATILE], | |
3660 | input_filename, lineno); | |
3661 | finish_stmt (); | |
3662 | } | |
3663 | /* This is the case with input operands as well. */ | |
c11b6f21 | 3664 | | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';' |
8d08fdba MS |
3665 | { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); |
3666 | emit_line_note (input_filename, lineno); | |
3667 | c_expand_asm_operands ($4, $6, $8, NULL_TREE, | |
3668 | $2 == ridpointers[(int)RID_VOLATILE], | |
3669 | input_filename, lineno); | |
3670 | finish_stmt (); | |
3671 | } | |
3672 | /* This is the case with clobbered registers as well. */ | |
c11b6f21 | 3673 | | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' |
8d2733ca | 3674 | asm_operands ':' asm_clobbers ')' ';' |
8d08fdba MS |
3675 | { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); |
3676 | emit_line_note (input_filename, lineno); | |
3677 | c_expand_asm_operands ($4, $6, $8, $10, | |
3678 | $2 == ridpointers[(int)RID_VOLATILE], | |
3679 | input_filename, lineno); | |
3680 | finish_stmt (); | |
3681 | } | |
3682 | | GOTO '*' expr ';' | |
5566b478 | 3683 | { |
5156628f | 3684 | if (processing_template_decl) |
5566b478 MS |
3685 | add_tree (build_min_nt (GOTO_STMT, $3)); |
3686 | else | |
3687 | { emit_line_note (input_filename, lineno); | |
3688 | expand_computed_goto ($3); } | |
3689 | } | |
8d08fdba | 3690 | | GOTO identifier ';' |
5566b478 | 3691 | { |
5156628f | 3692 | if (processing_template_decl) |
5566b478 MS |
3693 | add_tree (build_min_nt (GOTO_STMT, $2)); |
3694 | else | |
3695 | { | |
3696 | tree decl; | |
3697 | emit_line_note (input_filename, lineno); | |
3698 | decl = lookup_label ($2); | |
3699 | TREE_USED (decl) = 1; | |
3700 | expand_goto (decl); | |
3701 | } | |
3702 | } | |
8d08fdba MS |
3703 | | label_colon stmt |
3704 | { finish_stmt (); } | |
3705 | | label_colon '}' | |
3706 | { error ("label must be followed by statement"); | |
3707 | yyungetc ('}', 0); | |
3708 | finish_stmt (); } | |
3709 | | ';' | |
3710 | { finish_stmt (); } | |
8d2733ca | 3711 | | try_block |
8d08fdba MS |
3712 | ; |
3713 | ||
f30432d7 MS |
3714 | function_try_block: |
3715 | TRY | |
3716 | { | |
3717 | if (! current_function_parms_stored) | |
3718 | store_parm_decls (); | |
3719 | expand_start_early_try_stmts (); | |
3720 | } | |
da20811c | 3721 | ctor_initializer_opt compstmt |
9ffa2541 | 3722 | { expand_start_all_catch (); } |
f30432d7 MS |
3723 | handler_seq |
3724 | { | |
fc378698 MS |
3725 | int nested = (hack_decl_function_context |
3726 | (current_function_decl) != NULL_TREE); | |
f30432d7 | 3727 | expand_end_all_catch (); |
fc378698 | 3728 | finish_function (lineno, (int)$3, nested); |
f30432d7 MS |
3729 | } |
3730 | ; | |
3731 | ||
8d2733ca | 3732 | try_block: |
863adfc0 | 3733 | TRY |
faf5394a MS |
3734 | { |
3735 | if (processing_template_decl) | |
3736 | { | |
3737 | $<ttype>$ = build_min_nt (TRY_BLOCK, NULL_TREE, | |
3738 | NULL_TREE); | |
3739 | add_tree ($<ttype>$); | |
3740 | } | |
3741 | else | |
3742 | { | |
3743 | emit_line_note (input_filename, lineno); | |
3744 | expand_start_try_stmts (); | |
3745 | } | |
3746 | } | |
863adfc0 | 3747 | compstmt |
faf5394a MS |
3748 | { |
3749 | if (processing_template_decl) | |
3750 | { | |
3751 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
3752 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3753 | last_tree = $<ttype>2; | |
3754 | } | |
3755 | else | |
3756 | expand_start_all_catch (); | |
3757 | } | |
8d2733ca | 3758 | handler_seq |
faf5394a MS |
3759 | { |
3760 | if (processing_template_decl) | |
3761 | { | |
3762 | TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2); | |
3763 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3764 | last_tree = $<ttype>2; | |
3765 | } | |
3766 | else | |
3767 | expand_end_all_catch (); | |
3768 | } | |
8d08fdba MS |
3769 | ; |
3770 | ||
8d2733ca | 3771 | handler_seq: |
824b9a4c MS |
3772 | handler |
3773 | | handler_seq handler | |
3774 | ; | |
3775 | ||
3776 | handler: | |
3777 | CATCH | |
faf5394a MS |
3778 | { |
3779 | if (processing_template_decl) | |
3780 | { | |
3781 | $<ttype>$ = build_min_nt (HANDLER, NULL_TREE, | |
3782 | NULL_TREE); | |
3783 | add_tree ($<ttype>$); | |
3784 | } | |
3785 | } | |
824b9a4c | 3786 | .pushlevel handler_args |
faf5394a MS |
3787 | { |
3788 | if (processing_template_decl) | |
3789 | { | |
2ba25f50 MS |
3790 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); |
3791 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3792 | last_tree = $<ttype>2; | |
faf5394a MS |
3793 | } |
3794 | } | |
824b9a4c | 3795 | compstmt |
faf5394a MS |
3796 | { |
3797 | if (processing_template_decl) | |
3798 | { | |
2ba25f50 MS |
3799 | TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2); |
3800 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3801 | last_tree = $<ttype>2; | |
faf5394a MS |
3802 | } |
3803 | else | |
3804 | expand_end_catch_block (); | |
3805 | } | |
824b9a4c | 3806 | .poplevel |
8d2733ca | 3807 | ; |
8d08fdba | 3808 | |
a4443a08 | 3809 | type_specifier_seq: |
c11b6f21 MS |
3810 | typed_typespecs %prec EMPTY |
3811 | | nonempty_cv_qualifiers %prec EMPTY | |
a4443a08 MS |
3812 | ; |
3813 | ||
8d2733ca MS |
3814 | handler_args: |
3815 | '(' ELLIPSIS ')' | |
3816 | { expand_start_catch_block (NULL_TREE, NULL_TREE); } | |
a3b49ccd | 3817 | /* This doesn't allow reference parameters, the below does. |
a4443a08 | 3818 | | '(' type_specifier_seq absdcl ')' |
46b02c6d MS |
3819 | { check_for_new_type ("inside exception declarations", $2); |
3820 | expand_start_catch_block ($2.t, $3); } | |
a4443a08 | 3821 | | '(' type_specifier_seq ')' |
46b02c6d MS |
3822 | { check_for_new_type ("inside exception declarations", $2); |
3823 | expand_start_catch_block ($2.t, NULL_TREE); } | |
a4443a08 | 3824 | | '(' type_specifier_seq notype_declarator ')' |
46b02c6d MS |
3825 | { check_for_new_type ("inside exception declarations", $2); |
3826 | expand_start_catch_block ($2.t, $3); } | |
a4443a08 | 3827 | | '(' typed_typespecs after_type_declarator ')' |
46b02c6d MS |
3828 | { check_for_new_type ("inside exception declarations", $2); |
3829 | expand_start_catch_block ($2.t, $3); } | |
e92cc029 | 3830 | This allows reference parameters... */ |
a3b49ccd | 3831 | | '(' parm ')' |
46b02c6d MS |
3832 | { check_for_new_type ("inside exception declarations", $2); |
3833 | expand_start_catch_block (TREE_PURPOSE ($2.t), | |
3834 | TREE_VALUE ($2.t)); } | |
8d2733ca | 3835 | ; |
8d08fdba | 3836 | |
8d2733ca MS |
3837 | label_colon: |
3838 | IDENTIFIER ':' | |
3839 | { tree label; | |
3840 | do_label: | |
3841 | label = define_label (input_filename, lineno, $1); | |
5566b478 | 3842 | if (label && ! minimal_parse_mode) |
8d2733ca | 3843 | expand_label (label); |
8d08fdba | 3844 | } |
8d2733ca MS |
3845 | | PTYPENAME ':' |
3846 | { goto do_label; } | |
f376e137 MS |
3847 | | TYPENAME ':' |
3848 | { goto do_label; } | |
a80e4195 MS |
3849 | | SELFNAME ':' |
3850 | { goto do_label; } | |
8d08fdba MS |
3851 | ; |
3852 | ||
863adfc0 MS |
3853 | for.init.statement: |
3854 | xexpr ';' | |
3855 | { if ($1) cplus_expand_expr_stmt ($1); } | |
3856 | | decl | |
3857 | | '{' compstmtend | |
72b7eeff MS |
3858 | { if (pedantic) |
3859 | pedwarn ("ANSI C++ forbids compound statements inside for initializations"); | |
3860 | } | |
8d08fdba MS |
3861 | ; |
3862 | ||
3863 | /* Either a type-qualifier or nothing. First thing in an `asm' statement. */ | |
3864 | ||
c11b6f21 MS |
3865 | maybe_cv_qualifier: |
3866 | /* empty */ | |
8d08fdba MS |
3867 | { emit_line_note (input_filename, lineno); |
3868 | $$ = NULL_TREE; } | |
c11b6f21 | 3869 | | CV_QUALIFIER |
8d08fdba MS |
3870 | { emit_line_note (input_filename, lineno); } |
3871 | ; | |
3872 | ||
3873 | xexpr: | |
c11b6f21 | 3874 | /* empty */ |
8d08fdba MS |
3875 | { $$ = NULL_TREE; } |
3876 | | expr | |
3877 | | error | |
3878 | { $$ = NULL_TREE; } | |
3879 | ; | |
3880 | ||
3881 | /* These are the operands other than the first string and colon | |
3882 | in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */ | |
c11b6f21 MS |
3883 | asm_operands: |
3884 | /* empty */ | |
8d08fdba MS |
3885 | { $$ = NULL_TREE; } |
3886 | | nonnull_asm_operands | |
3887 | ; | |
3888 | ||
3889 | nonnull_asm_operands: | |
3890 | asm_operand | |
3891 | | nonnull_asm_operands ',' asm_operand | |
3892 | { $$ = chainon ($$, $3); } | |
3893 | ; | |
3894 | ||
3895 | asm_operand: | |
3896 | STRING '(' expr ')' | |
3897 | { $$ = build_tree_list ($$, $3); } | |
3898 | ; | |
3899 | ||
3900 | asm_clobbers: | |
3901 | STRING | |
3902 | { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); } | |
3903 | | asm_clobbers ',' STRING | |
3904 | { $$ = tree_cons (NULL_TREE, $3, $$); } | |
3905 | ; | |
3906 | ||
3907 | /* This is what appears inside the parens in a function declarator. | |
3908 | Its value is represented in the format that grokdeclarator expects. | |
3909 | ||
3910 | In C++, declaring a function with no parameters | |
3911 | means that that function takes *no* parameters. */ | |
51c184be | 3912 | |
c11b6f21 MS |
3913 | parmlist: |
3914 | /* empty */ | |
8d08fdba | 3915 | { |
46b02c6d | 3916 | $$ = empty_parms(); |
8d08fdba | 3917 | } |
51c184be MS |
3918 | | complex_parmlist |
3919 | | type_id | |
46b02c6d MS |
3920 | { $$ = tree_cons (NULL_TREE, $1.t, void_list_node); |
3921 | TREE_PARMLIST ($$) = 1; | |
3922 | check_for_new_type ("inside parameter list", $1); } | |
51c184be MS |
3923 | ; |
3924 | ||
3925 | /* This nonterminal does not include the common sequence '(' type_id ')', | |
3926 | as it is ambiguous and must be disambiguated elsewhere. */ | |
3927 | complex_parmlist: | |
3928 | parms | |
8d2733ca | 3929 | { |
8d08fdba MS |
3930 | $$ = chainon ($$, void_list_node); |
3931 | TREE_PARMLIST ($$) = 1; | |
3932 | } | |
51c184be | 3933 | | parms_comma ELLIPSIS |
8d08fdba MS |
3934 | { |
3935 | TREE_PARMLIST ($$) = 1; | |
3936 | } | |
3937 | /* C++ allows an ellipsis without a separating ',' */ | |
3938 | | parms ELLIPSIS | |
3939 | { | |
3940 | TREE_PARMLIST ($$) = 1; | |
3941 | } | |
51c184be MS |
3942 | | type_id ELLIPSIS |
3943 | { | |
46b02c6d | 3944 | $$ = build_tree_list (NULL_TREE, $1.t); |
51c184be MS |
3945 | TREE_PARMLIST ($$) = 1; |
3946 | } | |
8d08fdba MS |
3947 | | ELLIPSIS |
3948 | { | |
8d08fdba MS |
3949 | $$ = NULL_TREE; |
3950 | } | |
3951 | | TYPENAME_ELLIPSIS | |
3952 | { | |
3953 | TREE_PARMLIST ($$) = 1; | |
3954 | } | |
3955 | | parms TYPENAME_ELLIPSIS | |
3956 | { | |
3957 | TREE_PARMLIST ($$) = 1; | |
3958 | } | |
51c184be MS |
3959 | | type_id TYPENAME_ELLIPSIS |
3960 | { | |
46b02c6d | 3961 | $$ = build_tree_list (NULL_TREE, $1.t); |
51c184be MS |
3962 | TREE_PARMLIST ($$) = 1; |
3963 | } | |
8d08fdba MS |
3964 | | parms ':' |
3965 | { | |
3966 | /* This helps us recover from really nasty | |
3967 | parse errors, for example, a missing right | |
3968 | parenthesis. */ | |
3969 | yyerror ("possibly missing ')'"); | |
3970 | $$ = chainon ($$, void_list_node); | |
3971 | TREE_PARMLIST ($$) = 1; | |
3972 | yyungetc (':', 0); | |
3973 | yychar = ')'; | |
3974 | } | |
51c184be MS |
3975 | | type_id ':' |
3976 | { | |
3977 | /* This helps us recover from really nasty | |
3978 | parse errors, for example, a missing right | |
3979 | parenthesis. */ | |
3980 | yyerror ("possibly missing ')'"); | |
46b02c6d | 3981 | $$ = tree_cons (NULL_TREE, $1.t, void_list_node); |
51c184be MS |
3982 | TREE_PARMLIST ($$) = 1; |
3983 | yyungetc (':', 0); | |
3984 | yychar = ')'; | |
3985 | } | |
8d08fdba MS |
3986 | ; |
3987 | ||
42976354 BK |
3988 | /* A default argument to a */ |
3989 | defarg: | |
3990 | '=' | |
3991 | { maybe_snarf_defarg (); } | |
3992 | defarg1 | |
3993 | { $$ = $3; } | |
3994 | ; | |
3995 | ||
3996 | defarg1: | |
3997 | DEFARG | |
3998 | | init | |
3999 | ; | |
4000 | ||
8d08fdba MS |
4001 | /* A nonempty list of parameter declarations or type names. */ |
4002 | parms: | |
51c184be | 4003 | named_parm |
46b02c6d MS |
4004 | { check_for_new_type ("in a parameter list", $1); |
4005 | $$ = build_tree_list (NULL_TREE, $1.t); } | |
42976354 | 4006 | | parm defarg |
46b02c6d | 4007 | { check_for_new_type ("in a parameter list", $1); |
42976354 | 4008 | $$ = build_tree_list ($2, $1.t); } |
a292b002 | 4009 | | parms_comma full_parm |
46b02c6d MS |
4010 | { check_for_new_type ("in a parameter list", $2); |
4011 | $$ = chainon ($$, $2.t); } | |
51c184be MS |
4012 | | parms_comma bad_parm |
4013 | { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); } | |
4014 | | parms_comma bad_parm '=' init | |
4015 | { $$ = chainon ($$, build_tree_list ($4, $2)); } | |
4016 | ; | |
4017 | ||
4018 | parms_comma: | |
4019 | parms ',' | |
4020 | | type_id ',' | |
46b02c6d MS |
4021 | { check_for_new_type ("in a parameter list", $1); |
4022 | $$ = build_tree_list (NULL_TREE, $1.t); } | |
8d08fdba MS |
4023 | ; |
4024 | ||
4025 | /* A single parameter declaration or parameter type name, | |
c11b6f21 | 4026 | as found in a parmlist. */ |
51c184be | 4027 | named_parm: |
51c184be MS |
4028 | /* Here we expand typed_declspecs inline to avoid mis-parsing of |
4029 | TYPESPEC IDENTIFIER. */ | |
4030 | typed_declspecs1 declarator | |
46b02c6d MS |
4031 | { tree specs = strip_attrs ($1.t); |
4032 | $$.new_type_flag = $1.new_type_flag; | |
4033 | $$.t = build_tree_list (specs, $2); } | |
51c184be | 4034 | | typed_typespecs declarator |
46b02c6d MS |
4035 | { $$.t = build_tree_list ($1.t, $2); |
4036 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 4037 | | typespec declarator |
46b02c6d MS |
4038 | { $$.t = build_tree_list (get_decl_list ($1.t), $2); |
4039 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 4040 | | typed_declspecs1 absdcl |
46b02c6d MS |
4041 | { tree specs = strip_attrs ($1.t); |
4042 | $$.t = build_tree_list (specs, $2); | |
4043 | $$.new_type_flag = $1.new_type_flag; } | |
c11b6f21 | 4044 | | typed_declspecs1 %prec EMPTY |
46b02c6d MS |
4045 | { tree specs = strip_attrs ($1.t); |
4046 | $$.t = build_tree_list (specs, NULL_TREE); | |
4047 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 4048 | | declmods notype_declarator |
f30432d7 | 4049 | { tree specs = strip_attrs ($1); |
46b02c6d MS |
4050 | $$.t = build_tree_list (specs, $2); |
4051 | $$.new_type_flag = 0; } | |
8d08fdba MS |
4052 | ; |
4053 | ||
a292b002 | 4054 | full_parm: |
42976354 BK |
4055 | parm |
4056 | { $$.t = build_tree_list (NULL_TREE, $1.t); | |
4057 | $$.new_type_flag = $1.new_type_flag; } | |
4058 | | parm defarg | |
46b02c6d MS |
4059 | { $$.t = build_tree_list ($2, $1.t); |
4060 | $$.new_type_flag = $1.new_type_flag; } | |
a292b002 MS |
4061 | ; |
4062 | ||
51c184be | 4063 | parm: |
c11b6f21 | 4064 | named_parm |
51c184be | 4065 | | type_id |
8d08fdba MS |
4066 | ; |
4067 | ||
c11b6f21 MS |
4068 | see_typename: |
4069 | /* empty */ %prec EMPTY | |
4070 | { see_typename (); } | |
8d08fdba MS |
4071 | ; |
4072 | ||
8d08fdba | 4073 | bad_parm: |
51c184be MS |
4074 | /* empty */ %prec EMPTY |
4075 | { | |
6060a796 MS |
4076 | error ("type specifier omitted for parameter"); |
4077 | $$ = build_tree_list (integer_type_node, NULL_TREE); | |
51c184be MS |
4078 | } |
4079 | | notype_declarator | |
8d08fdba | 4080 | { |
6060a796 | 4081 | error ("type specifier omitted for parameter"); |
fc378698 MS |
4082 | if (TREE_CODE ($$) == SCOPE_REF |
4083 | && TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM) | |
4084 | cp_error (" perhaps you want `typename %E' to make it a type", $$); | |
6060a796 | 4085 | $$ = build_tree_list (integer_type_node, $$); |
8d08fdba MS |
4086 | } |
4087 | ; | |
4088 | ||
e3417fcd | 4089 | exception_specification_opt: |
c11b6f21 | 4090 | /* empty */ %prec EMPTY |
8d08fdba | 4091 | { $$ = NULL_TREE; } |
c11b6f21 | 4092 | | THROW '(' ansi_raise_identifiers ')' %prec EMPTY |
8d08fdba | 4093 | { $$ = $3; } |
c11b6f21 | 4094 | | THROW LEFT_RIGHT %prec EMPTY |
6060a796 | 4095 | { $$ = build_decl_list (NULL_TREE, NULL_TREE); } |
8d08fdba MS |
4096 | ; |
4097 | ||
8d08fdba | 4098 | ansi_raise_identifier: |
51c184be | 4099 | type_id |
46b02c6d | 4100 | { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); } |
8d08fdba MS |
4101 | ; |
4102 | ||
8d08fdba MS |
4103 | ansi_raise_identifiers: |
4104 | ansi_raise_identifier | |
4105 | | ansi_raise_identifiers ',' ansi_raise_identifier | |
4106 | { | |
8d2733ca | 4107 | TREE_CHAIN ($3) = $$; |
8d08fdba MS |
4108 | $$ = $3; |
4109 | } | |
4110 | ; | |
4111 | ||
51c184be | 4112 | conversion_declarator: |
c11b6f21 | 4113 | /* empty */ %prec EMPTY |
51c184be | 4114 | { $$ = NULL_TREE; } |
c11b6f21 | 4115 | | '*' cv_qualifiers conversion_declarator |
51c184be | 4116 | { $$ = make_pointer_declarator ($2, $3); } |
c11b6f21 | 4117 | | '&' cv_qualifiers conversion_declarator |
51c184be | 4118 | { $$ = make_reference_declarator ($2, $3); } |
c11b6f21 | 4119 | | ptr_to_mem cv_qualifiers conversion_declarator |
a28e3c7f MS |
4120 | { tree arg = make_pointer_declarator ($2, $3); |
4121 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
4122 | } |
4123 | ; | |
4124 | ||
c11b6f21 MS |
4125 | operator: |
4126 | OPERATOR | |
a28e3c7f MS |
4127 | { got_scope = NULL_TREE; } |
4128 | ; | |
4129 | ||
8d08fdba | 4130 | operator_name: |
a28e3c7f | 4131 | operator '*' |
8d08fdba | 4132 | { $$ = ansi_opname[MULT_EXPR]; } |
a28e3c7f | 4133 | | operator '/' |
8d08fdba | 4134 | { $$ = ansi_opname[TRUNC_DIV_EXPR]; } |
a28e3c7f | 4135 | | operator '%' |
8d08fdba | 4136 | { $$ = ansi_opname[TRUNC_MOD_EXPR]; } |
a28e3c7f | 4137 | | operator '+' |
8d08fdba | 4138 | { $$ = ansi_opname[PLUS_EXPR]; } |
a28e3c7f | 4139 | | operator '-' |
8d08fdba | 4140 | { $$ = ansi_opname[MINUS_EXPR]; } |
a28e3c7f | 4141 | | operator '&' |
8d08fdba | 4142 | { $$ = ansi_opname[BIT_AND_EXPR]; } |
a28e3c7f | 4143 | | operator '|' |
8d08fdba | 4144 | { $$ = ansi_opname[BIT_IOR_EXPR]; } |
a28e3c7f | 4145 | | operator '^' |
8d08fdba | 4146 | { $$ = ansi_opname[BIT_XOR_EXPR]; } |
a28e3c7f | 4147 | | operator '~' |
8d08fdba | 4148 | { $$ = ansi_opname[BIT_NOT_EXPR]; } |
a28e3c7f | 4149 | | operator ',' |
8d08fdba | 4150 | { $$ = ansi_opname[COMPOUND_EXPR]; } |
a28e3c7f | 4151 | | operator ARITHCOMPARE |
8d08fdba | 4152 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4153 | | operator '<' |
8d08fdba | 4154 | { $$ = ansi_opname[LT_EXPR]; } |
a28e3c7f | 4155 | | operator '>' |
8d08fdba | 4156 | { $$ = ansi_opname[GT_EXPR]; } |
a28e3c7f | 4157 | | operator EQCOMPARE |
8d08fdba | 4158 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4159 | | operator ASSIGN |
8d08fdba | 4160 | { $$ = ansi_assopname[$2]; } |
a28e3c7f | 4161 | | operator '=' |
8d08fdba | 4162 | { $$ = ansi_opname [MODIFY_EXPR]; } |
a28e3c7f | 4163 | | operator LSHIFT |
8d08fdba | 4164 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4165 | | operator RSHIFT |
8d08fdba | 4166 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4167 | | operator PLUSPLUS |
8d08fdba | 4168 | { $$ = ansi_opname[POSTINCREMENT_EXPR]; } |
a28e3c7f | 4169 | | operator MINUSMINUS |
8d08fdba | 4170 | { $$ = ansi_opname[PREDECREMENT_EXPR]; } |
a28e3c7f | 4171 | | operator ANDAND |
8d08fdba | 4172 | { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; } |
a28e3c7f | 4173 | | operator OROR |
8d08fdba | 4174 | { $$ = ansi_opname[TRUTH_ORIF_EXPR]; } |
a28e3c7f | 4175 | | operator '!' |
8d08fdba | 4176 | { $$ = ansi_opname[TRUTH_NOT_EXPR]; } |
a28e3c7f | 4177 | | operator '?' ':' |
8d08fdba | 4178 | { $$ = ansi_opname[COND_EXPR]; } |
a28e3c7f | 4179 | | operator MIN_MAX |
8d08fdba | 4180 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4181 | | operator POINTSAT %prec EMPTY |
8d08fdba | 4182 | { $$ = ansi_opname[COMPONENT_REF]; } |
a28e3c7f | 4183 | | operator POINTSAT_STAR %prec EMPTY |
8d08fdba | 4184 | { $$ = ansi_opname[MEMBER_REF]; } |
a28e3c7f | 4185 | | operator LEFT_RIGHT |
8d08fdba | 4186 | { $$ = ansi_opname[CALL_EXPR]; } |
a28e3c7f | 4187 | | operator '[' ']' |
8d08fdba | 4188 | { $$ = ansi_opname[ARRAY_REF]; } |
c11b6f21 | 4189 | | operator NEW %prec EMPTY |
8d08fdba | 4190 | { $$ = ansi_opname[NEW_EXPR]; } |
c11b6f21 | 4191 | | operator DELETE %prec EMPTY |
8d08fdba | 4192 | { $$ = ansi_opname[DELETE_EXPR]; } |
a28e3c7f | 4193 | | operator NEW '[' ']' |
51c184be | 4194 | { $$ = ansi_opname[VEC_NEW_EXPR]; } |
a28e3c7f MS |
4195 | | operator DELETE '[' ']' |
4196 | { $$ = ansi_opname[VEC_DELETE_EXPR]; } | |
700f8a87 | 4197 | /* Names here should be looked up in class scope ALSO. */ |
a4443a08 | 4198 | | operator type_specifier_seq conversion_declarator |
46b02c6d | 4199 | { $$ = grokoptypename ($2.t, $3); } |
a28e3c7f | 4200 | | operator error |
8d08fdba MS |
4201 | { $$ = ansi_opname[ERROR_MARK]; } |
4202 | ; | |
4203 | ||
4204 | %% | |
00595019 MS |
4205 | |
4206 | #ifdef SPEW_DEBUG | |
4207 | const char * | |
4208 | debug_yytranslate (value) | |
4209 | int value; | |
4210 | { | |
4211 | return yytname[YYTRANSLATE (value)]; | |
4212 | } | |
4213 | ||
4214 | #endif |