* cp-tree.h (SCALAR_TYPE_P): New macro.
[official-gcc/alias-decl.git] / gcc / cp / parse.y
blobacb45abbb81a517cedf5ddb8dfa6f1eaa07b7072
1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 Hacked by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 /* This grammar is based on the GNU CC grammar. */
26 /* Note: Bison automatically applies a default action of "$$ = $1" for
27 all derivations; this is applied before the explicit action, if one
28 is given. Keep this in mind when reading the actions. */
31 #include "config.h"
33 #include "system.h"
35 #include "tree.h"
36 #include "input.h"
37 #include "flags.h"
38 #include "cp-tree.h"
39 #include "lex.h"
40 #include "c-pragma.h" /* For YYDEBUG definition. */
41 #include "output.h"
42 #include "except.h"
43 #include "toplev.h"
44 #include "ggc.h"
46 extern struct obstack permanent_obstack;
48 /* Like YYERROR but do call yyerror. */
49 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
51 /* Like the default stack expander, except (1) use realloc when possible,
52 (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
54 Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
55 give malloced_yyvs its proper type. This is ok since all we need from
56 it is to be able to free it. */
58 static short *malloced_yyss;
59 static void *malloced_yyvs;
61 #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
62 do { \
63 size_t newsize; \
64 short *newss; \
65 YYSTYPE *newvs; \
66 newsize = *(YYSSZ) *= 2; \
67 if (malloced_yyss) \
68 { \
69 newss = (short *) \
70 really_call_realloc (*(SS), newsize * sizeof (short)); \
71 newvs = (YYSTYPE *) \
72 really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
73 } \
74 else \
75 { \
76 newss = (short *) really_call_malloc (newsize * sizeof (short)); \
77 newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
78 if (newss) \
79 memcpy (newss, *(SS), (SSSIZE)); \
80 if (newvs) \
81 memcpy (newvs, *(VS), (VSSIZE)); \
82 } \
83 if (!newss || !newvs) \
84 { \
85 yyerror (MSG); \
86 return 2; \
87 } \
88 *(SS) = newss; \
89 *(VS) = newvs; \
90 malloced_yyss = newss; \
91 malloced_yyvs = (void *) newvs; \
92 } while (0)
94 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
95 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
97 /* Contains the statement keyword (if/while/do) to include in an
98 error message if the user supplies an empty conditional expression. */
99 static const char *cond_stmt_keyword;
101 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
102 int have_extern_spec;
103 int used_extern_spec;
105 /* List of types and structure classes of the current declaration. */
106 static GTY(()) tree current_declspecs;
108 /* List of prefix attributes in effect.
109 Prefix attributes are parsed by the reserved_declspecs and declmods
110 rules. They create a list that contains *both* declspecs and attrs. */
111 /* ??? It is not clear yet that all cases where an attribute can now appear in
112 a declspec list have been updated. */
113 static GTY(()) tree prefix_attributes;
115 /* When defining an enumeration, this is the type of the enumeration. */
116 static GTY(()) tree current_enum_type;
118 /* When parsing a conversion operator name, this is the scope of the
119 operator itself. */
120 static GTY(()) tree saved_scopes;
122 static tree empty_parms PARAMS ((void));
123 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
124 static tree parse_decl PARAMS ((tree, tree, int));
125 static void parse_end_decl PARAMS ((tree, tree, tree));
126 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
127 static tree parse_field PARAMS ((tree, tree, tree, tree));
128 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
129 static tree parse_bitfield PARAMS ((tree, tree, tree));
130 static tree parse_method PARAMS ((tree, tree, tree));
131 static void frob_specs PARAMS ((tree, tree));
132 static void check_class_key PARAMS ((tree, tree));
133 static tree parse_scoped_id PARAMS ((tree));
135 /* Cons up an empty parameter list. */
136 static inline tree
137 empty_parms ()
139 tree parms;
141 #ifndef NO_IMPLICIT_EXTERN_C
142 if (in_system_header && current_class_type == NULL
143 && current_lang_name == lang_name_c)
144 parms = NULL_TREE;
145 else
146 #endif
147 parms = void_list_node;
148 return parms;
151 /* Record the decl-specifiers, attributes and type lookups from the
152 decl-specifier-seq in a declaration. */
154 static void
155 frob_specs (specs_attrs, lookups)
156 tree specs_attrs, lookups;
158 save_type_access_control (lookups);
159 split_specs_attrs (specs_attrs, &current_declspecs, &prefix_attributes);
160 if (current_declspecs
161 && TREE_CODE (current_declspecs) != TREE_LIST)
162 current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
163 if (have_extern_spec && !used_extern_spec)
165 /* We have to indicate that there is an "extern", but that it
166 was part of a language specifier. For instance,
168 extern "C" typedef int (*Ptr) ();
170 is well formed. */
171 current_declspecs = tree_cons (error_mark_node,
172 get_identifier ("extern"),
173 current_declspecs);
174 used_extern_spec = 1;
178 static tree
179 parse_decl (declarator, attributes, initialized)
180 tree declarator, attributes;
181 int initialized;
183 return start_decl (declarator, current_declspecs, initialized,
184 attributes, prefix_attributes);
187 static tree
188 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
189 tree declarator, specs_attrs, lookups, attributes;
190 int initialized;
192 frob_specs (specs_attrs, lookups);
193 return parse_decl (declarator, attributes, initialized);
196 static void
197 parse_end_decl (decl, init, asmspec)
198 tree decl, init, asmspec;
200 /* If decl is NULL_TREE, then this was a variable declaration using
201 () syntax for the initializer, so we handled it in grokdeclarator. */
202 if (decl)
203 decl_type_access_control (decl);
204 cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
207 static tree
208 parse_field (declarator, attributes, asmspec, init)
209 tree declarator, attributes, asmspec, init;
211 tree d = grokfield (declarator, current_declspecs, init, asmspec,
212 chainon (attributes, prefix_attributes));
213 decl_type_access_control (d);
214 return d;
217 static tree
218 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
219 tree declarator, specs_attrs, lookups, attributes, asmspec, init;
221 frob_specs (specs_attrs, lookups);
222 return parse_field (declarator, attributes, asmspec, init);
225 static tree
226 parse_bitfield (declarator, attributes, width)
227 tree declarator, attributes, width;
229 tree d = grokbitfield (declarator, current_declspecs, width);
230 cplus_decl_attributes (&d, chainon (attributes, prefix_attributes), 0);
231 decl_type_access_control (d);
232 return d;
235 static tree
236 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
237 tree declarator, specs_attrs, lookups, attributes, width;
239 frob_specs (specs_attrs, lookups);
240 return parse_bitfield (declarator, attributes, width);
243 static tree
244 parse_method (declarator, specs_attrs, lookups)
245 tree declarator, specs_attrs, lookups;
247 tree d;
248 frob_specs (specs_attrs, lookups);
249 d = start_method (current_declspecs, declarator, prefix_attributes);
250 decl_type_access_control (d);
251 return d;
254 static void
255 check_class_key (key, aggr)
256 tree key;
257 tree aggr;
259 if (TREE_CODE (key) == TREE_LIST)
260 key = TREE_VALUE (key);
261 if ((key == union_type_node) != (TREE_CODE (aggr) == UNION_TYPE))
262 pedwarn ("`%s' tag used in naming `%#T'",
263 key == union_type_node ? "union"
264 : key == record_type_node ? "struct" : "class", aggr);
269 %start program
271 %union { GTY(())
272 long itype;
273 tree ttype;
274 char *strtype;
275 enum tree_code code;
276 flagged_type_tree ftype;
277 struct unparsed_text *pi;
280 /* All identifiers that are not reserved words
281 and are not declared typedefs in the current block */
282 %token IDENTIFIER
284 /* All identifiers that are declared typedefs in the current block.
285 In some contexts, they are treated just like IDENTIFIER,
286 but they can also serve as typespecs in declarations. */
287 %token tTYPENAME
288 %token SELFNAME
290 /* A template function. */
291 %token PFUNCNAME
293 /* Reserved words that specify storage class.
294 yylval contains an IDENTIFIER_NODE which indicates which one. */
295 %token SCSPEC
297 /* Reserved words that specify type.
298 yylval contains an IDENTIFIER_NODE which indicates which one. */
299 %token TYPESPEC
301 /* Reserved words that qualify type: "const" or "volatile".
302 yylval contains an IDENTIFIER_NODE which indicates which one. */
303 %token CV_QUALIFIER
305 /* Character or numeric constants.
306 yylval is the node for the constant. */
307 %token CONSTANT
309 /* __func__, __FUNCTION__ or __PRETTY_FUNCTION__.
310 yylval contains an IDENTIFIER_NODE which indicates which one. */
311 %token <ttype> VAR_FUNC_NAME
313 /* String constants in raw form.
314 yylval is a STRING_CST node. */
315 %token STRING
317 /* "...", used for functions with variable arglists. */
318 %token ELLIPSIS
320 /* the reserved words */
321 /* SCO include files test "ASM", so use something else. */
322 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
323 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
324 %token SIGOF
325 %token ATTRIBUTE EXTENSION LABEL
326 %token REALPART IMAGPART VA_ARG
328 /* the reserved words... C++ extensions */
329 %token <ttype> AGGR
330 %token <ttype> VISSPEC
331 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
332 %token NAMESPACE TYPENAME_KEYWORD USING
333 %token LEFT_RIGHT TEMPLATE
334 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
335 %token SCOPE EXPORT
337 /* Define the operator tokens and their precedences.
338 The value is an integer because, if used, it is the tree code
339 to use in the expression made from the operator. */
341 %left EMPTY /* used to resolve s/r with epsilon */
343 %left error
345 /* Add precedence rules to solve dangling else s/r conflict */
346 %nonassoc IF
347 %nonassoc ELSE
349 %left IDENTIFIER PFUNCNAME tTYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD ATTRIBUTE
351 %left '{' ',' ';'
353 %nonassoc THROW
354 %right <code> ':'
355 %right <code> ASSIGN '='
356 %right <code> '?'
357 %left <code> OROR
358 %left <code> ANDAND
359 %left <code> '|'
360 %left <code> '^'
361 %left <code> '&'
362 %left <code> MIN_MAX
363 %left <code> EQCOMPARE
364 %left <code> ARITHCOMPARE '<' '>'
365 %left <code> LSHIFT RSHIFT
366 %left <code> '+' '-'
367 %left <code> '*' '/' '%'
368 %left <code> POINTSAT_STAR DOT_STAR
369 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
370 %left HYPERUNARY
371 %left <ttype> LEFT_RIGHT
372 %left <code> POINTSAT '.' '(' '['
374 %right SCOPE /* C++ extension */
375 %nonassoc NEW DELETE TRY CATCH
377 %type <code> unop
379 %type <ttype> identifier IDENTIFIER tTYPENAME CONSTANT expr nonnull_exprlist
380 %type <ttype> PFUNCNAME maybe_identifier
381 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
382 %type <ttype> expr_no_commas expr_no_comma_rangle
383 %type <ttype> cast_expr unary_expr primary STRING
384 %type <ttype> reserved_declspecs boolean_literal
385 %type <ttype> reserved_typespecquals
386 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
387 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
388 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
389 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
390 %type <ttype> any_word
392 %type <itype> save_lineno
393 %type <ttype> simple_stmt simple_if
395 %type <ttype> declarator notype_declarator after_type_declarator
396 %type <ttype> notype_declarator_intern absdcl_intern
397 %type <ttype> after_type_declarator_intern
398 %type <ttype> direct_notype_declarator direct_after_type_declarator
399 %type <itype> components notype_components
400 %type <ttype> component_decl component_decl_1
401 %type <ttype> component_declarator component_declarator0
402 %type <ttype> notype_component_declarator notype_component_declarator0
403 %type <ttype> after_type_component_declarator after_type_component_declarator0
404 %type <ttype> absdcl cv_qualifiers
405 %type <ttype> direct_abstract_declarator conversion_declarator
406 %type <ttype> new_declarator direct_new_declarator
407 %type <ttype> xexpr parmlist parms bad_parm
408 %type <ttype> identifiers_or_typenames
409 %type <ttype> fcast_or_absdcl regcast_or_absdcl
410 %type <ttype> expr_or_declarator expr_or_declarator_intern
411 %type <ttype> complex_notype_declarator
412 %type <ttype> notype_unqualified_id unqualified_id qualified_id
413 %type <ttype> template_id do_id object_template_id notype_template_declarator
414 %type <ttype> overqualified_id notype_qualified_id any_id
415 %type <ttype> complex_direct_notype_declarator functional_cast
416 %type <ttype> complex_parmlist parms_comma
417 %type <ttype> namespace_qualifier namespace_using_decl
419 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
420 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
421 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
422 %type <ftype> declmods
424 %type <itype> extension
426 /* C++ extensions */
427 %token <ttype> PTYPENAME
428 %token <ttype> EXTERN_LANG_STRING ALL
429 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
430 %token <pi> PRE_PARSED_FUNCTION_DECL
431 %type <ttype> component_constructor_declarator
432 %type <ttype> fn_def2 return_id constructor_declarator
433 %type <ttype> begin_function_body_
434 %type <ttype> class_head class_head_apparent_template
435 %type <ftype> class_head_decl class_head_defn
436 %type <ttype> base_class_list
437 %type <ttype> base_class_access_list
438 %type <ttype> base_class maybe_base_class_list base_class_1
439 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
440 %type <ttype> operator_name
441 %type <ttype> object aggr
442 %type <itype> new delete
443 /* %type <ttype> primary_no_id */
444 %type <ttype> maybe_parmlist
445 %type <ttype> member_init
446 %type <ftype> member_init_list
447 %type <ttype> template_parm_header template_spec_header template_header
448 %type <ttype> template_parm_list template_parm
449 %type <ttype> template_type_parm template_template_parm
450 %type <code> template_close_bracket
451 %type <ttype> apparent_template_type
452 %type <ttype> template_type template_arg_list template_arg_list_opt
453 %type <ttype> template_arg
454 %type <ttype> condition xcond paren_cond_or_null
455 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
456 %type <ttype> complete_type_name notype_identifier nonnested_type
457 %type <ttype> complex_type_name nested_name_specifier_1
458 %type <ttype> new_initializer new_placement
459 %type <ttype> using_decl
460 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
461 %type <ttype> explicit_template_type
462 /* in order to recognize aggr tags as defining and thus shadowing. */
463 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
464 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
465 %type <ttype> handler_args
466 %type <ttype> self_template_type finish_template_type_
468 %token NSNAME
469 %type <ttype> NSNAME
471 /* Used in lex.c for parsing pragmas. */
472 %token END_OF_LINE
474 /* lex.c and pt.c depend on this being the last token. Define
475 any new tokens before this one! */
476 %token END_OF_SAVED_INPUT
479 /* Tell yyparse how to print a token's value, if yydebug is set. */
480 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
481 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
485 program:
486 /* empty */
487 { finish_translation_unit (); }
488 | extdefs
489 { finish_translation_unit (); }
492 /* the reason for the strange actions in this rule
493 is so that notype_initdecls when reached via datadef
494 can find a valid list of type and sc specs in $0. */
496 extdefs:
497 { $<ttype>$ = NULL_TREE; }
498 lang_extdef
499 { $<ttype>$ = NULL_TREE; ggc_collect (); }
500 | extdefs lang_extdef
501 { $<ttype>$ = NULL_TREE; ggc_collect (); }
504 extdefs_opt:
505 extdefs
506 | /* empty */
509 .hush_warning:
510 { have_extern_spec = 1;
511 used_extern_spec = 0;
512 $<ttype>$ = NULL_TREE; }
514 .warning_ok:
515 { have_extern_spec = 0; }
518 extension:
519 EXTENSION
520 { $$ = pedantic;
521 pedantic = 0; }
524 asm_keyword:
525 ASM_KEYWORD
528 lang_extdef:
529 { if (pending_lang_change) do_pending_lang_change();
530 type_lookups = NULL_TREE; }
531 extdef
532 { if (! toplevel_bindings_p ())
533 pop_everything (); }
536 extdef:
537 fndef eat_saved_input
538 { do_pending_inlines (); }
539 | datadef
540 { do_pending_inlines (); }
542 | EXPORT
543 { warning ("keyword `export' not implemented, and will be ignored"); }
544 template_def
545 { do_pending_inlines (); }
546 | template_def
547 { do_pending_inlines (); }
548 | asm_keyword '(' STRING ')' ';'
549 { assemble_asm ($3); }
550 | extern_lang_string '{' extdefs_opt '}'
551 { pop_lang_context (); }
552 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
553 { do_pending_inlines (); pop_lang_context (); }
554 | extern_lang_string .hush_warning datadef .warning_ok
555 { do_pending_inlines (); pop_lang_context (); }
556 | NAMESPACE identifier '{'
557 { push_namespace ($2); }
558 extdefs_opt '}'
559 { pop_namespace (); }
560 | NAMESPACE '{'
561 { push_namespace (NULL_TREE); }
562 extdefs_opt '}'
563 { pop_namespace (); }
564 | namespace_alias
565 | using_decl ';'
566 { do_toplevel_using_decl ($1); }
567 | using_directive
568 | extension extdef
569 { pedantic = $1; }
572 namespace_alias:
573 NAMESPACE identifier '='
574 { begin_only_namespace_names (); }
575 any_id ';'
577 end_only_namespace_names ();
578 if (lastiddecl)
579 $5 = lastiddecl;
580 do_namespace_alias ($2, $5);
584 using_decl:
585 USING qualified_id
586 { $$ = $2; }
587 | USING global_scope qualified_id
588 { $$ = $3; }
589 | USING global_scope unqualified_id
590 { $$ = $3; }
593 namespace_using_decl:
594 USING namespace_qualifier identifier
595 { $$ = build_nt (SCOPE_REF, $2, $3); }
596 | USING global_scope identifier
597 { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
598 | USING global_scope namespace_qualifier identifier
599 { $$ = build_nt (SCOPE_REF, $3, $4); }
602 using_directive:
603 USING NAMESPACE
604 { begin_only_namespace_names (); }
605 any_id ';'
607 end_only_namespace_names ();
608 /* If no declaration was found, the using-directive is
609 invalid. Since that was not reported, we need the
610 identifier for the error message. */
611 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
612 $4 = lastiddecl;
613 do_using_directive ($4);
617 namespace_qualifier:
618 NSNAME SCOPE
620 if (TREE_CODE ($$) == IDENTIFIER_NODE)
621 $$ = lastiddecl;
622 got_scope = $$;
624 | namespace_qualifier NSNAME SCOPE
626 $$ = $2;
627 if (TREE_CODE ($$) == IDENTIFIER_NODE)
628 $$ = lastiddecl;
629 got_scope = $$;
633 any_id:
634 unqualified_id
635 | qualified_id
636 | global_scope qualified_id
637 { $$ = $2; }
638 | global_scope unqualified_id
639 { $$ = $2; }
642 extern_lang_string:
643 EXTERN_LANG_STRING
644 { push_lang_context ($1); }
645 | extern_lang_string EXTERN_LANG_STRING
646 { if (current_lang_name != $2)
647 error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
648 pop_lang_context (); push_lang_context ($2); }
651 template_parm_header:
652 TEMPLATE '<'
653 { begin_template_parm_list (); }
654 template_parm_list '>'
655 { $$ = end_template_parm_list ($4); }
658 template_spec_header:
659 TEMPLATE '<' '>'
660 { begin_specialization();
661 $$ = NULL_TREE; }
664 template_header:
665 template_parm_header
666 | template_spec_header
669 template_parm_list:
670 template_parm
671 { $$ = process_template_parm (NULL_TREE, $1); }
672 | template_parm_list ',' template_parm
673 { $$ = process_template_parm ($1, $3); }
676 maybe_identifier:
677 identifier
678 { $$ = $1; }
679 | /* empty */
680 { $$ = NULL_TREE; }
683 template_type_parm:
684 aggr maybe_identifier
685 { $$ = finish_template_type_parm ($1, $2); }
686 | TYPENAME_KEYWORD maybe_identifier
687 { $$ = finish_template_type_parm (class_type_node, $2); }
690 template_template_parm:
691 template_parm_header aggr maybe_identifier
692 { $$ = finish_template_template_parm ($2, $3); }
695 template_parm:
696 /* The following rules introduce a new reduce/reduce
697 conflict on the ',' and '>' input tokens: they are valid
698 prefixes for a `structsp', which means they could match a
699 nameless parameter. See 14.6, paragraph 3.
700 By putting them before the `parm' rule, we get
701 their match before considering them nameless parameter
702 declarations. */
703 template_type_parm
704 { $$ = build_tree_list (NULL_TREE, $1); }
705 | template_type_parm '=' type_id
706 { $$ = build_tree_list (groktypename ($3.t), $1); }
707 | parm
708 { $$ = build_tree_list (NULL_TREE, $1.t); }
709 | parm '=' expr_no_comma_rangle
710 { $$ = build_tree_list ($3, $1.t); }
711 | template_template_parm
712 { $$ = build_tree_list (NULL_TREE, $1); }
713 | template_template_parm '=' template_arg
715 if (TREE_CODE ($3) != TEMPLATE_DECL
716 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
717 && TREE_CODE ($3) != TYPE_DECL
718 && TREE_CODE ($3) != UNBOUND_CLASS_TEMPLATE)
720 error ("invalid default template argument");
721 $3 = error_mark_node;
723 $$ = build_tree_list ($3, $1);
727 template_def:
728 template_header template_extdef
729 { finish_template_decl ($1); }
730 | template_header error %prec EMPTY
731 { finish_template_decl ($1); }
734 template_extdef:
735 fndef eat_saved_input
736 { do_pending_inlines (); }
737 | template_datadef
738 { do_pending_inlines (); }
739 | template_def
740 { do_pending_inlines (); }
741 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
742 { do_pending_inlines ();
743 pop_lang_context (); }
744 | extern_lang_string .hush_warning template_datadef .warning_ok
745 { do_pending_inlines ();
746 pop_lang_context (); }
747 | extension template_extdef
748 { pedantic = $1; }
751 template_datadef:
752 nomods_initdecls ';'
753 | declmods notype_initdecls ';'
755 | typed_declspecs initdecls ';'
756 { note_list_got_semicolon ($1.t); }
757 | structsp ';'
759 if ($1.t != error_mark_node)
761 maybe_process_partial_specialization ($1.t);
762 note_got_semicolon ($1.t);
767 datadef:
768 nomods_initdecls ';'
769 | declmods notype_initdecls ';'
771 | typed_declspecs initdecls ';'
772 { note_list_got_semicolon ($1.t); }
773 | declmods ';'
774 { pedwarn ("empty declaration"); }
775 | explicit_instantiation ';'
776 | typed_declspecs ';'
778 tree t, attrs;
779 split_specs_attrs ($1.t, &t, &attrs);
780 shadow_tag (t);
781 note_list_got_semicolon ($1.t);
783 | error ';'
784 | error '}'
785 | error END_OF_SAVED_INPUT
786 { end_input (); }
787 | ';'
788 | bad_decl
791 ctor_initializer_opt:
792 nodecls
793 | base_init
796 maybe_return_init:
797 /* empty */
798 | return_init
799 | return_init ';'
802 eat_saved_input:
803 /* empty */
804 | END_OF_SAVED_INPUT
807 /* The outermost block of a function really begins before the
808 mem-initializer-list, so we open one there and suppress the one that
809 actually corresponds to the curly braces. */
810 function_body:
811 begin_function_body_ ctor_initializer_opt save_lineno '{'
812 { $<ttype>$ = begin_compound_stmt (/*has_no_scope=*/1); }
813 compstmtend
815 STMT_LINENO ($<ttype>5) = $3;
816 finish_compound_stmt (/*has_no_scope=*/1, $<ttype>5);
817 finish_function_body ($1);
821 fndef:
822 fn.def1 maybe_return_init function_body
823 { expand_body (finish_function (0)); }
824 | fn.def1 maybe_return_init function_try_block
825 { expand_body (finish_function (0)); }
826 | fn.def1 maybe_return_init error
830 constructor_declarator:
831 nested_name_specifier SELFNAME '('
832 { $$ = begin_constructor_declarator ($1, $2); }
833 parmlist ')' cv_qualifiers exception_specification_opt
834 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
835 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
836 { $$ = begin_constructor_declarator ($1, $2);
837 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
839 | global_scope nested_name_specifier SELFNAME '('
840 { $$ = begin_constructor_declarator ($2, $3); }
841 parmlist ')' cv_qualifiers exception_specification_opt
842 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
843 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
844 { $$ = begin_constructor_declarator ($2, $3);
845 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
847 | nested_name_specifier self_template_type '('
848 { $$ = begin_constructor_declarator ($1, $2); }
849 parmlist ')' cv_qualifiers exception_specification_opt
850 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
851 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
852 { $$ = begin_constructor_declarator ($1, $2);
853 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
855 | global_scope nested_name_specifier self_template_type '('
856 { $$ = begin_constructor_declarator ($2, $3); }
857 parmlist ')' cv_qualifiers exception_specification_opt
858 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
859 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
860 { $$ = begin_constructor_declarator ($2, $3);
861 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
865 fn.def1:
866 typed_declspecs declarator
867 { check_for_new_type ("return type", $1);
868 if (!begin_function_definition ($1.t, $2))
869 YYERROR1; }
870 | declmods notype_declarator
871 { if (!begin_function_definition ($1.t, $2))
872 YYERROR1; }
873 | notype_declarator
874 { if (!begin_function_definition (NULL_TREE, $1))
875 YYERROR1; }
876 | declmods constructor_declarator
877 { if (!begin_function_definition ($1.t, $2))
878 YYERROR1; }
879 | constructor_declarator
880 { if (!begin_function_definition (NULL_TREE, $1))
881 YYERROR1; }
884 /* ANSI allows optional parentheses around constructor class names.
885 See ISO/IEC 14882:1998(E) 12.1. */
887 component_constructor_declarator:
888 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
889 { $$ = make_call_declarator ($1, $3, $5, $6); }
890 | '(' SELFNAME ')' '(' parmlist ')' cv_qualifiers
891 exception_specification_opt
892 { $$ = make_call_declarator ($2, $5, $7, $8); }
893 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
894 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
895 | '(' SELFNAME ')' LEFT_RIGHT cv_qualifiers exception_specification_opt
896 { $$ = make_call_declarator ($2, empty_parms (), $5, $6); }
897 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
898 { $$ = make_call_declarator ($1, $3, $5, $6); }
899 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
900 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
903 /* more C++ complexity. See component_decl for a comment on the
904 reduce/reduce conflict introduced by these rules. */
905 fn_def2:
906 declmods component_constructor_declarator
907 { $$ = parse_method ($2, $1.t, $1.lookups);
908 rest_of_mdef:
909 if (! $$)
910 YYERROR1;
911 if (yychar == YYEMPTY)
912 yychar = YYLEX;
913 snarf_method ($$); }
914 | component_constructor_declarator
915 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
916 goto rest_of_mdef; }
917 | typed_declspecs declarator
918 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
919 | declmods notype_declarator
920 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
921 | notype_declarator
922 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
923 goto rest_of_mdef; }
924 | declmods constructor_declarator
925 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
926 | constructor_declarator
927 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
928 goto rest_of_mdef; }
931 return_id:
932 RETURN_KEYWORD IDENTIFIER
934 $$ = $2;
938 return_init:
939 return_id maybe_init
940 { finish_named_return_value ($<ttype>$, $2); }
941 | return_id '(' nonnull_exprlist ')'
942 { finish_named_return_value ($<ttype>$, $3); }
943 | return_id LEFT_RIGHT
944 { finish_named_return_value ($<ttype>$, NULL_TREE); }
947 base_init:
948 ':' member_init_list
950 if (! DECL_CONSTRUCTOR_P (current_function_decl))
951 error ("only constructors take base initializers");
952 else if ($2.new_type_flag == 0)
953 error ("no base or member initializers given following ':'");
955 finish_mem_initializers ($2.t);
959 begin_function_body_:
960 /* empty */
962 $$ = begin_function_body ();
966 member_init_list:
967 /* empty */
969 $$.new_type_flag = 0;
970 $$.t = NULL_TREE;
972 | member_init
974 $$.new_type_flag = 1;
975 $$.t = $1;
977 | member_init_list ',' member_init
979 if ($3)
981 $$.new_type_flag = 1;
982 TREE_CHAIN ($3) = $1.t;
983 $$.t = $3;
985 else
986 $$ = $1;
988 | member_init_list error
991 member_init:
992 '(' nonnull_exprlist ')'
994 if (current_class_name)
995 pedwarn ("anachronistic old style base class initializer");
996 $$ = expand_member_init (current_class_ref, NULL_TREE, $2);
998 | LEFT_RIGHT
1000 if (current_class_name)
1001 pedwarn ("anachronistic old style base class initializer");
1002 $$ = expand_member_init (current_class_ref,
1003 NULL_TREE,
1004 void_type_node);
1006 | notype_identifier '(' nonnull_exprlist ')'
1007 { $$ = expand_member_init (current_class_ref, $1, $3); }
1008 | notype_identifier LEFT_RIGHT
1009 { $$ = expand_member_init (current_class_ref, $1,
1010 void_type_node); }
1011 | nonnested_type '(' nonnull_exprlist ')'
1012 { $$ = expand_member_init (current_class_ref, $1, $3); }
1013 | nonnested_type LEFT_RIGHT
1014 { $$ = expand_member_init (current_class_ref, $1,
1015 void_type_node); }
1016 | typename_sub '(' nonnull_exprlist ')'
1017 { $$ = expand_member_init (current_class_ref, $1, $3); }
1018 | typename_sub LEFT_RIGHT
1019 { $$ = expand_member_init (current_class_ref, $1,
1020 void_type_node); }
1021 | error
1022 { $$ = NULL_TREE; }
1025 identifier:
1026 IDENTIFIER
1027 | tTYPENAME
1028 | SELFNAME
1029 | PTYPENAME
1030 | NSNAME
1033 notype_identifier:
1034 IDENTIFIER
1035 | PTYPENAME
1036 | NSNAME %prec EMPTY
1039 identifier_defn:
1040 IDENTIFIER_DEFN
1041 | TYPENAME_DEFN
1042 | PTYPENAME_DEFN
1045 explicit_instantiation:
1046 TEMPLATE begin_explicit_instantiation typespec ';'
1047 { do_type_instantiation ($3.t, NULL_TREE, 1);
1048 yyungetc (';', 1); }
1049 end_explicit_instantiation
1050 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
1051 { tree specs = strip_attrs ($3.t);
1052 do_decl_instantiation (specs, $4, NULL_TREE); }
1053 end_explicit_instantiation
1054 | TEMPLATE begin_explicit_instantiation notype_declarator
1055 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1056 end_explicit_instantiation
1057 | TEMPLATE begin_explicit_instantiation constructor_declarator
1058 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1059 end_explicit_instantiation
1060 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
1061 { do_type_instantiation ($4.t, $1, 1);
1062 yyungetc (';', 1); }
1063 end_explicit_instantiation
1065 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
1066 declarator
1067 { tree specs = strip_attrs ($4.t);
1068 do_decl_instantiation (specs, $5, $1); }
1069 end_explicit_instantiation
1071 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
1072 { do_decl_instantiation (NULL_TREE, $4, $1); }
1073 end_explicit_instantiation
1075 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
1076 { do_decl_instantiation (NULL_TREE, $4, $1); }
1077 end_explicit_instantiation
1081 begin_explicit_instantiation:
1082 { begin_explicit_instantiation(); }
1085 end_explicit_instantiation:
1086 { end_explicit_instantiation(); }
1089 /* The TYPENAME expansions are to deal with use of a template class name as
1090 a template within the class itself, where the template decl is hidden by
1091 a type decl. Got all that? */
1093 template_type:
1094 PTYPENAME '<' template_arg_list_opt template_close_bracket
1095 finish_template_type_
1096 { $$ = $5; }
1097 | tTYPENAME '<' template_arg_list_opt template_close_bracket
1098 finish_template_type_
1099 { $$ = $5; }
1100 | self_template_type
1103 apparent_template_type:
1104 template_type
1105 | identifier '<' template_arg_list_opt '>'
1106 finish_template_type_
1107 { $$ = $5; }
1110 self_template_type:
1111 SELFNAME '<' template_arg_list_opt template_close_bracket
1112 finish_template_type_
1113 { $$ = $5; }
1116 finish_template_type_:
1118 if (yychar == YYEMPTY)
1119 yychar = YYLEX;
1121 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1122 yychar == SCOPE);
1126 template_close_bracket:
1128 | RSHIFT
1130 /* Handle `Class<Class<Type>>' without space in the `>>' */
1131 pedwarn ("`>>' should be `> >' in template class name");
1132 yyungetc ('>', 1);
1136 template_arg_list_opt:
1137 /* empty */
1138 { $$ = NULL_TREE; }
1139 | template_arg_list
1142 template_arg_list:
1143 template_arg
1144 { $$ = build_tree_list (NULL_TREE, $$); }
1145 | template_arg_list ',' template_arg
1146 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1149 template_arg:
1150 type_id
1151 { $$ = groktypename ($1.t); }
1152 | PTYPENAME
1154 $$ = lastiddecl;
1155 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1156 $$ = TREE_TYPE ($$);
1158 | global_scope PTYPENAME
1160 $$ = lastiddecl;
1161 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1162 $$ = TREE_TYPE ($$);
1164 | expr_no_comma_rangle
1165 | nested_name_specifier TEMPLATE identifier
1167 if (!processing_template_decl)
1169 error ("use of template qualifier outside template");
1170 $$ = error_mark_node;
1172 else
1173 $$ = make_unbound_class_template ($1, $3, 1);
1177 unop:
1179 { $$ = NEGATE_EXPR; }
1180 | '+'
1181 { $$ = CONVERT_EXPR; }
1182 | PLUSPLUS
1183 { $$ = PREINCREMENT_EXPR; }
1184 | MINUSMINUS
1185 { $$ = PREDECREMENT_EXPR; }
1186 | '!'
1187 { $$ = TRUTH_NOT_EXPR; }
1190 expr:
1191 nontrivial_exprlist
1192 { $$ = build_x_compound_expr ($$); }
1193 | expr_no_commas
1196 paren_expr_or_null:
1197 LEFT_RIGHT
1198 { error ("ISO C++ forbids an empty condition for `%s'",
1199 cond_stmt_keyword);
1200 $$ = integer_zero_node; }
1201 | '(' expr ')'
1202 { $$ = $2; }
1205 paren_cond_or_null:
1206 LEFT_RIGHT
1207 { error ("ISO C++ forbids an empty condition for `%s'",
1208 cond_stmt_keyword);
1209 $$ = integer_zero_node; }
1210 | '(' condition ')'
1211 { $$ = $2; }
1214 xcond:
1215 /* empty */
1216 { $$ = NULL_TREE; }
1217 | condition
1218 | error
1219 { $$ = NULL_TREE; }
1222 condition:
1223 type_specifier_seq declarator maybeasm maybe_attribute '='
1225 tree d;
1226 for (d = getdecls (); d; d = TREE_CHAIN (d))
1227 if (TREE_CODE (d) == TYPE_DECL) {
1228 tree s = TREE_TYPE (d);
1229 if (TREE_CODE (s) == RECORD_TYPE)
1230 error ("definition of class `%T' in condition", s);
1231 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1232 error ("definition of enum `%T' in condition", s);
1235 current_declspecs = $1.t;
1236 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1238 init
1240 parse_end_decl ($<ttype>6, $7, $4);
1241 $$ = convert_from_reference ($<ttype>6);
1242 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1243 error ("definition of array `%#D' in condition", $$);
1245 | expr
1248 compstmtend:
1250 | maybe_label_decls stmts '}'
1251 | maybe_label_decls stmts error '}'
1252 | maybe_label_decls error '}'
1255 nontrivial_exprlist:
1256 expr_no_commas ',' expr_no_commas
1257 { $$ = tree_cons (NULL_TREE, $$,
1258 build_tree_list (NULL_TREE, $3)); }
1259 | expr_no_commas ',' error
1260 { $$ = tree_cons (NULL_TREE, $$,
1261 build_tree_list (NULL_TREE, error_mark_node)); }
1262 | nontrivial_exprlist ',' expr_no_commas
1263 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1264 | nontrivial_exprlist ',' error
1265 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1268 nonnull_exprlist:
1269 expr_no_commas
1270 { $$ = build_tree_list (NULL_TREE, $$); }
1271 | nontrivial_exprlist
1274 unary_expr:
1275 primary %prec UNARY
1276 { $$ = $1; }
1277 /* __extension__ turns off -pedantic for following primary. */
1278 | extension cast_expr %prec UNARY
1279 { $$ = $2;
1280 pedantic = $1; }
1281 | '*' cast_expr %prec UNARY
1282 { $$ = build_x_indirect_ref ($2, "unary *"); }
1283 | '&' cast_expr %prec UNARY
1284 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1285 | '~' cast_expr
1286 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1287 | unop cast_expr %prec UNARY
1288 { $$ = finish_unary_op_expr ($1, $2); }
1289 /* Refer to the address of a label as a pointer. */
1290 | ANDAND identifier
1291 { $$ = finish_label_address_expr ($2); }
1292 | SIZEOF unary_expr %prec UNARY
1293 { $$ = finish_sizeof ($2); }
1294 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1295 { $$ = finish_sizeof (groktypename ($3.t));
1296 check_for_new_type ("sizeof", $3); }
1297 | ALIGNOF unary_expr %prec UNARY
1298 { $$ = finish_alignof ($2); }
1299 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1300 { $$ = finish_alignof (groktypename ($3.t));
1301 check_for_new_type ("alignof", $3); }
1303 /* The %prec EMPTY's here are required by the = init initializer
1304 syntax extension; see below. */
1305 | new new_type_id %prec EMPTY
1306 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1307 check_for_new_type ("new", $2); }
1308 | new new_type_id new_initializer
1309 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1310 check_for_new_type ("new", $2); }
1311 | new new_placement new_type_id %prec EMPTY
1312 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1313 check_for_new_type ("new", $3); }
1314 | new new_placement new_type_id new_initializer
1315 { $$ = build_new ($2, $3.t, $4, $1);
1316 check_for_new_type ("new", $3); }
1317 | new '(' type_id ')'
1318 %prec EMPTY
1319 { $$ = build_new (NULL_TREE, groktypename($3.t),
1320 NULL_TREE, $1);
1321 check_for_new_type ("new", $3); }
1322 | new '(' type_id ')' new_initializer
1323 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1324 check_for_new_type ("new", $3); }
1325 | new new_placement '(' type_id ')' %prec EMPTY
1326 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1327 check_for_new_type ("new", $4); }
1328 | new new_placement '(' type_id ')' new_initializer
1329 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1330 check_for_new_type ("new", $4); }
1332 | delete cast_expr %prec UNARY
1333 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1334 | delete '[' ']' cast_expr %prec UNARY
1335 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1336 if (yychar == YYEMPTY)
1337 yychar = YYLEX; }
1338 | delete '[' expr ']' cast_expr %prec UNARY
1339 { $$ = delete_sanity ($5, $3, 2, $1);
1340 if (yychar == YYEMPTY)
1341 yychar = YYLEX; }
1342 | REALPART cast_expr %prec UNARY
1343 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1344 | IMAGPART cast_expr %prec UNARY
1345 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1348 new_placement:
1349 '(' nonnull_exprlist ')'
1350 { $$ = $2; }
1351 | '{' nonnull_exprlist '}'
1352 { pedwarn ("old style placement syntax, use () instead");
1353 $$ = $2; }
1356 new_initializer:
1357 '(' nonnull_exprlist ')'
1358 { $$ = $2; }
1359 | LEFT_RIGHT
1360 { $$ = void_zero_node; }
1361 | '(' typespec ')'
1363 error ("`%T' is not a valid expression", $2.t);
1364 $$ = error_mark_node;
1366 /* GNU extension so people can use initializer lists. Note that
1367 this alters the meaning of `new int = 1', which was previously
1368 syntactically valid but semantically invalid.
1369 This feature is now deprecated and will be removed in a future
1370 release. */
1371 | '=' init
1373 if (pedantic)
1374 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1375 cp_deprecated ("new initializer lists extension");
1376 if (TREE_CODE ($2) != TREE_LIST
1377 && TREE_CODE ($2) != CONSTRUCTOR)
1378 $$ = build_tree_list (NULL_TREE, $2);
1379 else
1380 $$ = $2;
1384 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1385 regcast_or_absdcl:
1386 '(' type_id ')' %prec EMPTY
1387 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1388 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1389 check_for_new_type ("cast", $2); }
1390 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1391 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1392 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1393 check_for_new_type ("cast", $3); }
1396 cast_expr:
1397 unary_expr
1398 | regcast_or_absdcl unary_expr %prec UNARY
1399 { $$ = reparse_absdcl_as_casts ($$, $2); }
1400 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1402 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1403 nreverse ($3));
1404 if (pedantic)
1405 pedwarn ("ISO C++ forbids compound literals");
1406 /* Indicate that this was a C99 compound literal. */
1407 TREE_HAS_CONSTRUCTOR (init) = 1;
1409 $$ = reparse_absdcl_as_casts ($$, init);
1413 expr_no_commas:
1414 cast_expr
1415 /* Handle general members. */
1416 | expr_no_commas POINTSAT_STAR expr_no_commas
1417 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1418 | expr_no_commas DOT_STAR expr_no_commas
1419 { $$ = build_m_component_ref ($$, $3); }
1420 | expr_no_commas '+' expr_no_commas
1421 { $$ = build_x_binary_op ($2, $$, $3); }
1422 | expr_no_commas '-' expr_no_commas
1423 { $$ = build_x_binary_op ($2, $$, $3); }
1424 | expr_no_commas '*' expr_no_commas
1425 { $$ = build_x_binary_op ($2, $$, $3); }
1426 | expr_no_commas '/' expr_no_commas
1427 { $$ = build_x_binary_op ($2, $$, $3); }
1428 | expr_no_commas '%' expr_no_commas
1429 { $$ = build_x_binary_op ($2, $$, $3); }
1430 | expr_no_commas LSHIFT expr_no_commas
1431 { $$ = build_x_binary_op ($2, $$, $3); }
1432 | expr_no_commas RSHIFT expr_no_commas
1433 { $$ = build_x_binary_op ($2, $$, $3); }
1434 | expr_no_commas ARITHCOMPARE expr_no_commas
1435 { $$ = build_x_binary_op ($2, $$, $3); }
1436 | expr_no_commas '<' expr_no_commas
1437 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1438 | expr_no_commas '>' expr_no_commas
1439 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1440 | expr_no_commas EQCOMPARE expr_no_commas
1441 { $$ = build_x_binary_op ($2, $$, $3); }
1442 | expr_no_commas MIN_MAX expr_no_commas
1443 { $$ = build_x_binary_op ($2, $$, $3); }
1444 | expr_no_commas '&' expr_no_commas
1445 { $$ = build_x_binary_op ($2, $$, $3); }
1446 | expr_no_commas '|' expr_no_commas
1447 { $$ = build_x_binary_op ($2, $$, $3); }
1448 | expr_no_commas '^' expr_no_commas
1449 { $$ = build_x_binary_op ($2, $$, $3); }
1450 | expr_no_commas ANDAND expr_no_commas
1451 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1452 | expr_no_commas OROR expr_no_commas
1453 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1454 | expr_no_commas '?' xexpr ':' expr_no_commas
1455 { $$ = build_x_conditional_expr ($$, $3, $5); }
1456 | expr_no_commas '=' expr_no_commas
1457 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1458 if ($$ != error_mark_node)
1459 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1460 | expr_no_commas ASSIGN expr_no_commas
1461 { $$ = build_x_modify_expr ($$, $2, $3); }
1462 | THROW
1463 { $$ = build_throw (NULL_TREE); }
1464 | THROW expr_no_commas
1465 { $$ = build_throw ($2); }
1468 expr_no_comma_rangle:
1469 cast_expr
1470 /* Handle general members. */
1471 | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1472 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1473 | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1474 { $$ = build_m_component_ref ($$, $3); }
1475 | expr_no_comma_rangle '+' expr_no_comma_rangle
1476 { $$ = build_x_binary_op ($2, $$, $3); }
1477 | expr_no_comma_rangle '-' expr_no_comma_rangle
1478 { $$ = build_x_binary_op ($2, $$, $3); }
1479 | expr_no_comma_rangle '*' expr_no_comma_rangle
1480 { $$ = build_x_binary_op ($2, $$, $3); }
1481 | expr_no_comma_rangle '/' expr_no_comma_rangle
1482 { $$ = build_x_binary_op ($2, $$, $3); }
1483 | expr_no_comma_rangle '%' expr_no_comma_rangle
1484 { $$ = build_x_binary_op ($2, $$, $3); }
1485 | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1486 { $$ = build_x_binary_op ($2, $$, $3); }
1487 | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1488 { $$ = build_x_binary_op ($2, $$, $3); }
1489 | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
1490 { $$ = build_x_binary_op ($2, $$, $3); }
1491 | expr_no_comma_rangle '<' expr_no_comma_rangle
1492 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1493 | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1494 { $$ = build_x_binary_op ($2, $$, $3); }
1495 | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1496 { $$ = build_x_binary_op ($2, $$, $3); }
1497 | expr_no_comma_rangle '&' expr_no_comma_rangle
1498 { $$ = build_x_binary_op ($2, $$, $3); }
1499 | expr_no_comma_rangle '|' expr_no_comma_rangle
1500 { $$ = build_x_binary_op ($2, $$, $3); }
1501 | expr_no_comma_rangle '^' expr_no_comma_rangle
1502 { $$ = build_x_binary_op ($2, $$, $3); }
1503 | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1504 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1505 | expr_no_comma_rangle OROR expr_no_comma_rangle
1506 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1507 | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1508 { $$ = build_x_conditional_expr ($$, $3, $5); }
1509 | expr_no_comma_rangle '=' expr_no_comma_rangle
1510 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1511 if ($$ != error_mark_node)
1512 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1513 | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1514 { $$ = build_x_modify_expr ($$, $2, $3); }
1515 | THROW
1516 { $$ = build_throw (NULL_TREE); }
1517 | THROW expr_no_comma_rangle
1518 { $$ = build_throw ($2); }
1521 notype_unqualified_id:
1522 '~' see_typename identifier
1523 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1524 | '~' see_typename template_type
1525 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1526 | template_id
1527 | operator_name
1528 | IDENTIFIER
1529 | PTYPENAME
1530 | NSNAME %prec EMPTY
1533 do_id:
1535 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1536 means that we're in an expression like S::f<int>, so
1537 don't do_identifier; we only do that for unqualified
1538 identifiers. */
1539 if (!lastiddecl || TREE_CODE (lastiddecl) != TREE_LIST)
1540 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1541 else
1542 $$ = $<ttype>-1;
1546 template_id:
1547 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1548 { $$ = lookup_template_function ($3, $4); }
1549 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1550 { $$ = lookup_template_function ($3, $4); }
1553 object_template_id:
1554 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1555 { $$ = lookup_template_function ($2, $4); }
1556 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1557 { $$ = lookup_template_function ($2, $4); }
1558 | TEMPLATE operator_name '<' template_arg_list_opt
1559 template_close_bracket
1560 { $$ = lookup_template_function ($2, $4); }
1563 unqualified_id:
1564 notype_unqualified_id
1565 | tTYPENAME
1566 | SELFNAME
1569 expr_or_declarator_intern:
1570 expr_or_declarator
1571 | attributes expr_or_declarator
1573 /* Provide support for '(' attributes '*' declarator ')'
1574 etc */
1575 $$ = tree_cons ($1, $2, NULL_TREE);
1579 expr_or_declarator:
1580 notype_unqualified_id
1581 | '*' expr_or_declarator_intern %prec UNARY
1582 { $$ = build_nt (INDIRECT_REF, $2); }
1583 | '&' expr_or_declarator_intern %prec UNARY
1584 { $$ = build_nt (ADDR_EXPR, $2); }
1585 | '(' expr_or_declarator_intern ')'
1586 { $$ = $2; }
1589 notype_template_declarator:
1590 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1591 { $$ = lookup_template_function ($1, $3); }
1592 | NSNAME '<' template_arg_list template_close_bracket
1593 { $$ = lookup_template_function ($1, $3); }
1596 direct_notype_declarator:
1597 complex_direct_notype_declarator
1598 /* This precedence declaration is to prefer this reduce
1599 to the Koenig lookup shift in primary, below. I hate yacc. */
1600 | notype_unqualified_id %prec '('
1601 | notype_template_declarator
1602 | '(' expr_or_declarator_intern ')'
1603 { $$ = finish_decl_parsing ($2); }
1606 primary:
1607 notype_unqualified_id
1609 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1610 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1611 else
1612 $$ = finish_id_expr ($1);
1614 | CONSTANT
1615 | boolean_literal
1616 | STRING
1618 $$ = fix_string_type ($$);
1619 /* fix_string_type doesn't set up TYPE_MAIN_VARIANT of
1620 a const array the way we want, so fix it. */
1621 if (flag_const_strings)
1622 TREE_TYPE ($$) = build_cplus_array_type
1623 (TREE_TYPE (TREE_TYPE ($$)),
1624 TYPE_DOMAIN (TREE_TYPE ($$)));
1626 | VAR_FUNC_NAME
1627 { $$ = finish_fname ($1); }
1628 | '(' expr ')'
1629 { $$ = finish_parenthesized_expr ($2); }
1630 | '(' expr_or_declarator_intern ')'
1631 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1632 $$ = finish_parenthesized_expr ($2); }
1633 | '(' error ')'
1634 { $$ = error_mark_node; }
1635 | '('
1636 { if (!at_function_scope_p ())
1638 error ("braced-group within expression allowed only inside a function");
1639 YYERROR;
1641 if (pedantic)
1642 pedwarn ("ISO C++ forbids braced-groups within expressions");
1643 $<ttype>$ = begin_stmt_expr ();
1645 compstmt_or_stmtexpr ')'
1646 { $$ = finish_stmt_expr ($<ttype>2); }
1647 /* Koenig lookup support
1648 We could store lastiddecl in $1 to avoid another lookup,
1649 but that would result in many additional reduce/reduce conflicts. */
1650 | notype_unqualified_id '(' nonnull_exprlist ')'
1651 { $$ = finish_call_expr ($1, $3, 1); }
1652 | notype_unqualified_id LEFT_RIGHT
1653 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1654 | primary '(' nonnull_exprlist ')'
1655 { $$ = finish_call_expr ($1, $3, 0); }
1656 | primary LEFT_RIGHT
1657 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1658 | VA_ARG '(' expr_no_commas ',' type_id ')'
1659 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1660 check_for_new_type ("__builtin_va_arg", $5); }
1661 | primary '[' expr ']'
1662 { $$ = grok_array_decl ($$, $3); }
1663 | primary PLUSPLUS
1664 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1665 | primary MINUSMINUS
1666 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1667 /* C++ extensions */
1668 | THIS
1669 { $$ = finish_this_expr (); }
1670 | CV_QUALIFIER '(' nonnull_exprlist ')'
1672 /* This is a C cast in C++'s `functional' notation
1673 using the "implicit int" extension so that:
1674 `const (3)' is equivalent to `const int (3)'. */
1675 tree type;
1677 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1678 type = groktypename (build_tree_list (type, NULL_TREE));
1679 $$ = build_functional_cast (type, $3);
1681 | functional_cast
1682 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1683 { tree type = groktypename ($3.t);
1684 check_for_new_type ("dynamic_cast", $3);
1685 $$ = build_dynamic_cast (type, $6); }
1686 | STATIC_CAST '<' type_id '>' '(' expr ')'
1687 { tree type = groktypename ($3.t);
1688 check_for_new_type ("static_cast", $3);
1689 $$ = build_static_cast (type, $6); }
1690 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1691 { tree type = groktypename ($3.t);
1692 check_for_new_type ("reinterpret_cast", $3);
1693 $$ = build_reinterpret_cast (type, $6); }
1694 | CONST_CAST '<' type_id '>' '(' expr ')'
1695 { tree type = groktypename ($3.t);
1696 check_for_new_type ("const_cast", $3);
1697 $$ = build_const_cast (type, $6); }
1698 | TYPEID '(' expr ')'
1699 { $$ = build_typeid ($3); }
1700 | TYPEID '(' type_id ')'
1701 { tree type = groktypename ($3.t);
1702 check_for_new_type ("typeid", $3);
1703 $$ = get_typeid (type); }
1704 | global_scope IDENTIFIER
1705 { $$ = parse_scoped_id ($2); }
1706 | global_scope template_id
1707 { $$ = $2; }
1708 | global_scope operator_name
1710 got_scope = NULL_TREE;
1711 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1712 $$ = parse_scoped_id ($2);
1713 else
1714 $$ = $2;
1716 | overqualified_id %prec HYPERUNARY
1717 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1718 | overqualified_id '(' nonnull_exprlist ')'
1719 { $$ = finish_qualified_call_expr ($1, $3); }
1720 | overqualified_id LEFT_RIGHT
1721 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1722 | object object_template_id %prec UNARY
1724 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1726 | object object_template_id '(' nonnull_exprlist ')'
1727 { $$ = finish_object_call_expr ($2, $1, $4); }
1728 | object object_template_id LEFT_RIGHT
1729 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1730 | object unqualified_id %prec UNARY
1731 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1732 | object overqualified_id %prec UNARY
1733 { if (processing_template_decl)
1734 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1735 else
1736 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1737 | object unqualified_id '(' nonnull_exprlist ')'
1738 { $$ = finish_object_call_expr ($2, $1, $4); }
1739 | object unqualified_id LEFT_RIGHT
1740 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1741 | object overqualified_id '(' nonnull_exprlist ')'
1742 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1743 | object overqualified_id LEFT_RIGHT
1744 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1745 /* p->int::~int() is valid -- 12.4 */
1746 | object '~' TYPESPEC LEFT_RIGHT
1747 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1748 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1749 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1750 | object error
1752 $$ = error_mark_node;
1756 /* Not needed for now.
1758 primary_no_id:
1759 '(' expr ')'
1760 { $$ = $2; }
1761 | '(' error ')'
1762 { $$ = error_mark_node; }
1763 | '('
1764 { if (current_function_decl == 0)
1766 error ("braced-group within expression allowed only inside a function");
1767 YYERROR;
1769 $<ttype>$ = expand_start_stmt_expr (); }
1770 compstmt_or_stmtexpr ')'
1771 { if (pedantic)
1772 pedwarn ("ISO C++ forbids braced-groups within expressions");
1773 $$ = expand_end_stmt_expr ($<ttype>2); }
1774 | primary_no_id '(' nonnull_exprlist ')'
1775 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1776 | primary_no_id LEFT_RIGHT
1777 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1778 | primary_no_id '[' expr ']'
1779 { goto do_array; }
1780 | primary_no_id PLUSPLUS
1781 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1782 | primary_no_id MINUSMINUS
1783 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1784 | SCOPE IDENTIFIER
1785 { goto do_scoped_id; }
1786 | SCOPE operator_name
1787 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1788 goto do_scoped_id;
1789 goto do_scoped_operator;
1794 new:
1796 { $$ = 0; }
1797 | global_scope NEW
1798 { got_scope = NULL_TREE; $$ = 1; }
1801 delete:
1802 DELETE
1803 { $$ = 0; }
1804 | global_scope delete
1805 { got_scope = NULL_TREE; $$ = 1; }
1808 boolean_literal:
1809 CXX_TRUE
1810 { $$ = boolean_true_node; }
1811 | CXX_FALSE
1812 { $$ = boolean_false_node; }
1815 nodecls:
1816 /* empty */
1818 if (DECL_CONSTRUCTOR_P (current_function_decl))
1819 finish_mem_initializers (NULL_TREE);
1823 object:
1824 primary '.'
1825 { got_object = TREE_TYPE ($$); }
1826 | primary POINTSAT
1828 $$ = build_x_arrow ($$);
1829 got_object = TREE_TYPE ($$);
1833 decl:
1834 typespec initdecls ';'
1836 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1837 note_got_semicolon ($1.t);
1839 | typed_declspecs initdecls ';'
1841 note_list_got_semicolon ($1.t);
1843 | declmods notype_initdecls ';'
1845 | typed_declspecs ';'
1847 shadow_tag ($1.t);
1848 note_list_got_semicolon ($1.t);
1850 | declmods ';'
1851 { warning ("empty declaration"); }
1852 | extension decl
1853 { pedantic = $1; }
1856 /* Any kind of declarator (thus, all declarators allowed
1857 after an explicit typespec). */
1859 declarator:
1860 after_type_declarator %prec EMPTY
1861 | notype_declarator %prec EMPTY
1864 /* This is necessary to postpone reduction of `int()()()()'. */
1865 fcast_or_absdcl:
1866 LEFT_RIGHT %prec EMPTY
1867 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1868 NULL_TREE, NULL_TREE); }
1869 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1870 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1871 NULL_TREE); }
1874 /* ISO type-id (8.1) */
1875 type_id:
1876 typed_typespecs absdcl
1877 { $$.t = build_tree_list ($1.t, $2);
1878 $$.new_type_flag = $1.new_type_flag; }
1879 | nonempty_cv_qualifiers absdcl
1880 { $$.t = build_tree_list ($1.t, $2);
1881 $$.new_type_flag = $1.new_type_flag; }
1882 | typespec absdcl
1883 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1884 $2);
1885 $$.new_type_flag = $1.new_type_flag; }
1886 | typed_typespecs %prec EMPTY
1887 { $$.t = build_tree_list ($1.t, NULL_TREE);
1888 $$.new_type_flag = $1.new_type_flag; }
1889 | nonempty_cv_qualifiers %prec EMPTY
1890 { $$.t = build_tree_list ($1.t, NULL_TREE);
1891 $$.new_type_flag = $1.new_type_flag; }
1894 /* Declspecs which contain at least one type specifier or typedef name.
1895 (Just `const' or `volatile' is not enough.)
1896 A typedef'd name following these is taken as a name to be declared.
1897 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1899 typed_declspecs:
1900 typed_typespecs %prec EMPTY
1901 { $$.lookups = type_lookups; }
1902 | typed_declspecs1
1903 { $$.lookups = type_lookups; }
1906 typed_declspecs1:
1907 declmods typespec
1908 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1909 $$.new_type_flag = $2.new_type_flag; }
1910 | typespec reserved_declspecs %prec HYPERUNARY
1911 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1912 $$.new_type_flag = $1.new_type_flag; }
1913 | typespec reserved_typespecquals reserved_declspecs
1914 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1915 $$.new_type_flag = $1.new_type_flag; }
1916 | declmods typespec reserved_declspecs
1917 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1918 $$.new_type_flag = $2.new_type_flag; }
1919 | declmods typespec reserved_typespecquals
1920 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1921 $$.new_type_flag = $2.new_type_flag; }
1922 | declmods typespec reserved_typespecquals reserved_declspecs
1923 { $$.t = tree_cons (NULL_TREE, $2.t,
1924 chainon ($3, chainon ($4, $1.t)));
1925 $$.new_type_flag = $2.new_type_flag; }
1928 reserved_declspecs:
1929 SCSPEC
1930 { if (extra_warnings)
1931 warning ("`%s' is not at beginning of declaration",
1932 IDENTIFIER_POINTER ($$));
1933 $$ = build_tree_list (NULL_TREE, $$); }
1934 | reserved_declspecs typespecqual_reserved
1935 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1936 | reserved_declspecs SCSPEC
1937 { if (extra_warnings)
1938 warning ("`%s' is not at beginning of declaration",
1939 IDENTIFIER_POINTER ($2));
1940 $$ = tree_cons (NULL_TREE, $2, $$); }
1943 /* List of just storage classes and type modifiers.
1944 A declaration can start with just this, but then it cannot be used
1945 to redeclare a typedef-name.
1946 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1948 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1949 up on a persistent obstack. Otherwise, they could appear at the
1950 beginning of something like
1952 static const struct { int foo () { } } b;
1954 and would be discarded after we finish compiling foo. We don't need to
1955 worry once we see a type. */
1957 declmods:
1958 nonempty_cv_qualifiers %prec EMPTY
1959 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1960 | SCSPEC
1962 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1963 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1965 | declmods CV_QUALIFIER
1967 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1968 TREE_STATIC ($$.t) = 1;
1970 | declmods SCSPEC
1972 if (extra_warnings && TREE_STATIC ($$.t))
1973 warning ("`%s' is not at beginning of declaration",
1974 IDENTIFIER_POINTER ($2));
1975 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1976 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1978 | declmods attributes
1979 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1982 /* Used instead of declspecs where storage classes are not allowed
1983 (that is, for typenames and structure components).
1985 C++ can takes storage classes for structure components.
1986 Don't accept a typedef-name if anything but a modifier precedes it. */
1988 typed_typespecs:
1989 typespec %prec EMPTY
1990 { $$.t = build_tree_list (NULL_TREE, $1.t);
1991 $$.new_type_flag = $1.new_type_flag; }
1992 | nonempty_cv_qualifiers typespec
1993 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1994 $$.new_type_flag = $2.new_type_flag; }
1995 | typespec reserved_typespecquals
1996 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1997 $$.new_type_flag = $1.new_type_flag; }
1998 | nonempty_cv_qualifiers typespec reserved_typespecquals
1999 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
2000 $$.new_type_flag = $2.new_type_flag; }
2003 reserved_typespecquals:
2004 typespecqual_reserved
2005 { $$ = build_tree_list (NULL_TREE, $1.t); }
2006 | reserved_typespecquals typespecqual_reserved
2007 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
2008 | reserved_typespecquals attributes
2009 { $$ = tree_cons ($2, NULL_TREE, $1); }
2010 | attributes %prec EMPTY
2011 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
2014 /* A typespec (but not a type qualifier).
2015 Once we have seen one of these in a declaration,
2016 if a typedef name appears then it is being redeclared. */
2018 typespec:
2019 structsp
2020 { $$.lookups = NULL_TREE; }
2021 | TYPESPEC %prec EMPTY
2022 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2023 | complete_type_name
2024 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2025 | TYPEOF '(' expr ')'
2026 { $$.t = finish_typeof ($3);
2027 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2028 | TYPEOF '(' type_id ')'
2029 { $$.t = groktypename ($3.t);
2030 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2031 | SIGOF '(' expr ')'
2032 { tree type = TREE_TYPE ($3);
2034 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2035 if (IS_AGGR_TYPE (type))
2037 sorry ("sigof type specifier");
2038 $$.t = type;
2040 else
2042 error ("`sigof' applied to non-aggregate expression");
2043 $$.t = error_mark_node;
2046 | SIGOF '(' type_id ')'
2047 { tree type = groktypename ($3.t);
2049 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2050 if (IS_AGGR_TYPE (type))
2052 sorry ("sigof type specifier");
2053 $$.t = type;
2055 else
2057 error("`sigof' applied to non-aggregate type");
2058 $$.t = error_mark_node;
2063 /* A typespec that is a reserved word, or a type qualifier. */
2065 typespecqual_reserved:
2066 TYPESPEC
2067 { $$.t = $1; $$.new_type_flag = 0; }
2068 | CV_QUALIFIER
2069 { $$.t = $1; $$.new_type_flag = 0; }
2070 | structsp
2073 initdecls:
2074 initdcl0
2075 | initdecls ',' initdcl
2076 { check_multiple_declarators (); }
2079 notype_initdecls:
2080 notype_initdcl0
2081 | notype_initdecls ',' initdcl
2082 { check_multiple_declarators (); }
2085 nomods_initdecls:
2086 nomods_initdcl0
2087 | nomods_initdecls ',' initdcl
2088 { check_multiple_declarators (); }
2091 maybeasm:
2092 /* empty */
2093 { $$ = NULL_TREE; }
2094 | asm_keyword '(' STRING ')'
2095 { $$ = $3; }
2098 initdcl:
2099 declarator maybeasm maybe_attribute '='
2100 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2101 init
2102 /* Note how the declaration of the variable is in effect while its init is parsed! */
2103 { parse_end_decl ($<ttype>5, $6, $2); }
2104 | declarator maybeasm maybe_attribute
2106 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2107 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2111 /* This rule assumes a certain configuration of the parser stack.
2112 In particular, $0, the element directly before the beginning of
2113 this rule on the stack, must be a maybeasm. $-1 must be a
2114 declarator or notype_declarator. And $-2 must be some declmods
2115 or declspecs. We can't move the maybeasm into this rule because
2116 we need that reduce so we prefer fn.def1 when appropriate. */
2117 initdcl0_innards:
2118 maybe_attribute '='
2119 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2120 $<ftype>-2.lookups, $1, 1); }
2121 /* Note how the declaration of the variable is in effect
2122 while its init is parsed! */
2123 init
2124 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2125 | maybe_attribute
2126 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2127 $<ftype>-2.lookups, $1, 0);
2128 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2131 initdcl0:
2132 declarator maybeasm initdcl0_innards
2136 notype_initdcl0:
2137 notype_declarator maybeasm initdcl0_innards
2141 nomods_initdcl0:
2142 notype_declarator maybeasm
2143 { /* Set things up as initdcl0_innards expects. */
2144 $<ttype>$ = $2;
2145 $2 = $1;
2146 $<ftype>1.t = NULL_TREE;
2147 $<ftype>1.lookups = NULL_TREE; }
2148 initdcl0_innards
2150 | constructor_declarator maybeasm maybe_attribute
2151 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2152 parse_end_decl (d, NULL_TREE, $2); }
2155 /* the * rules are dummies to accept the Apollo extended syntax
2156 so that the header files compile. */
2157 maybe_attribute:
2158 /* empty */
2159 { $$ = NULL_TREE; }
2160 | attributes
2161 { $$ = $1; }
2164 attributes:
2165 attribute
2166 { $$ = $1; }
2167 | attributes attribute
2168 { $$ = chainon ($1, $2); }
2171 attribute:
2172 ATTRIBUTE '(' '(' attribute_list ')' ')'
2173 { $$ = $4; }
2176 attribute_list:
2177 attrib
2178 { $$ = $1; }
2179 | attribute_list ',' attrib
2180 { $$ = chainon ($1, $3); }
2183 attrib:
2184 /* empty */
2185 { $$ = NULL_TREE; }
2186 | any_word
2187 { $$ = build_tree_list ($1, NULL_TREE); }
2188 | any_word '(' IDENTIFIER ')'
2189 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2190 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2191 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2192 | any_word '(' nonnull_exprlist ')'
2193 { $$ = build_tree_list ($1, $3); }
2196 /* This still leaves out most reserved keywords,
2197 shouldn't we include them? */
2199 any_word:
2200 identifier
2201 | SCSPEC
2202 | TYPESPEC
2203 | CV_QUALIFIER
2206 /* A nonempty list of identifiers, including typenames. */
2207 identifiers_or_typenames:
2208 identifier
2209 { $$ = build_tree_list (NULL_TREE, $1); }
2210 | identifiers_or_typenames ',' identifier
2211 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2214 maybe_init:
2215 /* empty */ %prec EMPTY
2216 { $$ = NULL_TREE; }
2217 | '=' init
2218 { $$ = $2; }
2221 /* If we are processing a template, we don't want to expand this
2222 initializer yet. */
2224 init:
2225 expr_no_commas %prec '='
2226 | '{' '}'
2227 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2228 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2229 | '{' initlist '}'
2230 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2231 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2232 | '{' initlist ',' '}'
2233 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2234 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2235 | error
2236 { $$ = NULL_TREE; }
2239 /* This chain is built in reverse order,
2240 and put in forward order where initlist is used. */
2241 initlist:
2242 init
2243 { $$ = build_tree_list (NULL_TREE, $$); }
2244 | initlist ',' init
2245 { $$ = tree_cons (NULL_TREE, $3, $$); }
2246 /* These are for labeled elements. */
2247 | '[' expr_no_commas ']' init
2248 { $$ = build_tree_list ($2, $4); }
2249 | identifier ':' init
2250 { $$ = build_tree_list ($$, $3); }
2251 | initlist ',' identifier ':' init
2252 { $$ = tree_cons ($3, $5, $$); }
2255 pending_inline:
2256 PRE_PARSED_FUNCTION_DECL maybe_return_init function_body
2258 expand_body (finish_function (2));
2259 process_next_inline ($1);
2261 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2263 expand_body (finish_function (2));
2264 process_next_inline ($1);
2266 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2268 finish_function (2);
2269 process_next_inline ($1); }
2272 pending_inlines:
2273 /* empty */
2274 | pending_inlines pending_inline eat_saved_input
2277 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2278 the TREE_LIST node for the parameter in question. */
2279 defarg_again:
2280 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2281 { replace_defarg ($1, $2); }
2282 | DEFARG_MARKER error END_OF_SAVED_INPUT
2283 { replace_defarg ($1, error_mark_node); }
2286 pending_defargs:
2287 /* empty */ %prec EMPTY
2288 | pending_defargs defarg_again
2289 { do_pending_defargs (); }
2290 | pending_defargs error
2291 { do_pending_defargs (); }
2294 structsp:
2295 ENUM identifier '{'
2296 { $<ttype>$ = current_enum_type;
2297 current_enum_type = start_enum ($2); }
2298 enumlist_opt '}'
2299 { $$.t = current_enum_type;
2300 finish_enum (current_enum_type);
2301 $$.new_type_flag = 1;
2302 current_enum_type = $<ttype>4;
2303 check_for_missing_semicolon ($$.t); }
2304 | ENUM '{'
2305 { $<ttype>$ = current_enum_type;
2306 current_enum_type = start_enum (make_anon_name ()); }
2307 enumlist_opt '}'
2308 { $$.t = current_enum_type;
2309 finish_enum (current_enum_type);
2310 $$.new_type_flag = 1;
2311 current_enum_type = $<ttype>3;
2312 check_for_missing_semicolon ($$.t); }
2313 | ENUM identifier
2314 { $$.t = xref_tag (enum_type_node, $2, 1);
2315 $$.new_type_flag = 0; }
2316 | ENUM complex_type_name
2317 { $$.t = xref_tag (enum_type_node, $2, 1);
2318 $$.new_type_flag = 0; }
2319 | TYPENAME_KEYWORD typename_sub
2320 { $$.t = $2;
2321 $$.new_type_flag = 0;
2322 if (!processing_template_decl)
2323 pedwarn ("using `typename' outside of template"); }
2324 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2325 | class_head_defn maybe_base_class_list '{'
2327 if ($2 && $1.t != error_mark_node)
2329 tree type = TREE_TYPE ($1.t);
2331 if (TREE_CODE (type) == TYPENAME_TYPE)
2332 /* In a definition of a member class template,
2333 we will get here with an implicit typename,
2334 a TYPENAME_TYPE with a type. */
2335 type = TREE_TYPE (type);
2336 maybe_process_partial_specialization (type);
2337 xref_basetypes (current_aggr, $1.t, type, $2);
2339 $1.t = begin_class_definition (TREE_TYPE ($1.t));
2340 check_class_key (current_aggr, $1.t);
2341 current_aggr = NULL_TREE; }
2342 opt.component_decl_list '}' maybe_attribute
2344 int semi;
2345 tree t;
2347 if (yychar == YYEMPTY)
2348 yychar = YYLEX;
2349 semi = yychar == ';';
2351 t = finish_class_definition ($1.t, $7, semi, $1.new_type_flag);
2352 $<ttype>$ = t;
2354 /* restore current_aggr */
2355 current_aggr = TREE_CODE (t) != RECORD_TYPE
2356 ? union_type_node
2357 : CLASSTYPE_DECLARED_CLASS (t)
2358 ? class_type_node : record_type_node;
2360 pending_defargs
2362 done_pending_defargs ();
2363 begin_inline_definitions ();
2365 pending_inlines
2367 $$.t = $<ttype>8;
2368 $$.new_type_flag = 1;
2370 | class_head_decl
2372 $$.t = TREE_TYPE ($1.t);
2373 $$.new_type_flag = $1.new_type_flag;
2374 check_class_key (current_aggr, $$.t);
2378 maybecomma:
2379 /* empty */
2380 | ','
2383 maybecomma_warn:
2384 /* empty */
2385 | ','
2386 { if (pedantic && !in_system_header)
2387 pedwarn ("comma at end of enumerator list"); }
2390 aggr:
2391 AGGR
2392 | aggr SCSPEC
2393 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2394 | aggr TYPESPEC
2395 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2396 | aggr CV_QUALIFIER
2397 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2398 | aggr AGGR
2399 { error ("no body nor ';' separates two class, struct or union declarations"); }
2400 | aggr attributes
2401 { $$ = build_tree_list ($2, $1); }
2404 class_head:
2405 aggr identifier
2407 current_aggr = $1;
2408 $$ = build_tree_list (NULL_TREE, $2);
2410 | aggr nested_name_specifier identifier
2412 current_aggr = $1;
2413 $$ = build_tree_list ($2, $3);
2415 | aggr global_scope nested_name_specifier identifier
2417 current_aggr = $1;
2418 $$ = build_tree_list ($3, $4);
2420 | aggr global_scope identifier
2422 current_aggr = $1;
2423 $$ = build_tree_list (global_namespace, $3);
2427 class_head_apparent_template:
2428 aggr apparent_template_type
2430 current_aggr = $1;
2431 $$ = $2;
2433 | aggr nested_name_specifier apparent_template_type
2435 current_aggr = $1;
2436 $$ = $3;
2438 | aggr global_scope nested_name_specifier apparent_template_type
2440 current_aggr = $1;
2441 $$ = $4;
2445 class_head_decl:
2446 class_head %prec EMPTY
2448 $$.t = handle_class_head (current_aggr,
2449 TREE_PURPOSE ($1), TREE_VALUE ($1),
2450 0, &$$.new_type_flag);
2452 | aggr identifier_defn %prec EMPTY
2454 current_aggr = $1;
2455 $$.t = TYPE_MAIN_DECL (xref_tag (current_aggr, $2, 0));
2456 $$.new_type_flag = 1;
2458 | class_head_apparent_template %prec EMPTY
2460 $$.t = $1;
2461 $$.new_type_flag = 0;
2465 class_head_defn:
2466 class_head '{'
2468 yyungetc ('{', 1);
2469 $$.t = handle_class_head (current_aggr,
2470 TREE_PURPOSE ($1), TREE_VALUE ($1),
2471 1, &$$.new_type_flag);
2473 | class_head ':'
2475 yyungetc (':', 1);
2476 $$.t = handle_class_head (current_aggr,
2477 TREE_PURPOSE ($1), TREE_VALUE ($1),
2478 1, &$$.new_type_flag);
2480 | class_head_apparent_template '{'
2482 yyungetc ('{', 1);
2483 $$.t = $1;
2484 $$.new_type_flag = 0;
2485 if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2486 /* We might be specializing a template with a different
2487 class-key. */
2488 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2489 = (current_aggr == class_type_node);
2491 | class_head_apparent_template ':'
2493 yyungetc (':', 1);
2494 $$.t = $1;
2495 $$.new_type_flag = 0;
2496 if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2497 /* We might be specializing a template with a different
2498 class-key. */
2499 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2500 = (current_aggr == class_type_node);
2502 | aggr identifier_defn '{'
2504 yyungetc ('{', 1);
2505 current_aggr = $1;
2506 $$.t = handle_class_head (current_aggr,
2507 NULL_TREE, $2,
2508 1, &$$.new_type_flag);
2510 | aggr identifier_defn ':'
2512 yyungetc (':', 1);
2513 current_aggr = $1;
2514 $$.t = handle_class_head (current_aggr,
2515 NULL_TREE, $2,
2516 1, &$$.new_type_flag);
2518 | aggr '{'
2520 current_aggr = $1;
2521 $$.t = TYPE_MAIN_DECL (xref_tag ($1, make_anon_name (), 0));
2522 $$.new_type_flag = 0;
2523 yyungetc ('{', 1);
2527 maybe_base_class_list:
2528 /* empty */
2529 { $$ = NULL_TREE; }
2530 | ':' see_typename
2531 { error ("no bases given following `:'");
2532 $$ = NULL_TREE; }
2533 | ':' see_typename base_class_list
2534 { $$ = $3; }
2537 base_class_list:
2538 base_class
2539 | base_class_list ',' see_typename base_class
2540 { $$ = chainon ($$, $4); }
2543 base_class:
2544 base_class_1
2545 { $$ = finish_base_specifier (access_default_node, $1); }
2546 | base_class_access_list see_typename base_class_1
2547 { $$ = finish_base_specifier ($1, $3); }
2550 base_class_1:
2551 typename_sub
2552 { if (!TYPE_P ($$))
2553 $$ = error_mark_node; }
2554 | nonnested_type
2555 { $$ = TREE_TYPE ($$); }
2558 base_class_access_list:
2559 VISSPEC see_typename
2560 | SCSPEC see_typename
2561 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2562 error ("`%D' access", $1);
2563 $$ = access_default_virtual_node; }
2564 | base_class_access_list VISSPEC see_typename
2566 if ($1 != access_default_virtual_node)
2567 error ("multiple access specifiers");
2568 else if ($2 == access_public_node)
2569 $$ = access_public_virtual_node;
2570 else if ($2 == access_protected_node)
2571 $$ = access_protected_virtual_node;
2572 else /* $2 == access_private_node */
2573 $$ = access_private_virtual_node;
2575 | base_class_access_list SCSPEC see_typename
2576 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2577 error ("`%D' access", $2);
2578 else if ($$ == access_public_node)
2579 $$ = access_public_virtual_node;
2580 else if ($$ == access_protected_node)
2581 $$ = access_protected_virtual_node;
2582 else if ($$ == access_private_node)
2583 $$ = access_private_virtual_node;
2584 else
2585 error ("multiple `virtual' specifiers");
2589 opt.component_decl_list:
2590 | component_decl_list
2591 | opt.component_decl_list access_specifier component_decl_list
2592 | opt.component_decl_list access_specifier
2595 access_specifier:
2596 VISSPEC ':'
2598 current_access_specifier = $1;
2602 /* Note: we no longer warn about the semicolon after a component_decl_list.
2603 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2604 component_decl_list:
2605 component_decl
2607 finish_member_declaration ($1);
2608 current_aggr = NULL_TREE;
2609 reset_type_access_control ();
2611 | component_decl_list component_decl
2613 finish_member_declaration ($2);
2614 current_aggr = NULL_TREE;
2615 reset_type_access_control ();
2619 component_decl:
2620 component_decl_1 ';'
2621 | component_decl_1 '}'
2622 { error ("missing ';' before right brace");
2623 yyungetc ('}', 0); }
2624 /* C++: handle constructors, destructors and inline functions */
2625 /* note that INLINE is like a TYPESPEC */
2626 | fn_def2 ':' /* base_init compstmt */
2627 { $$ = finish_method ($$); }
2628 | fn_def2 TRY /* base_init compstmt */
2629 { $$ = finish_method ($$); }
2630 | fn_def2 RETURN_KEYWORD /* base_init compstmt */
2631 { $$ = finish_method ($$); }
2632 | fn_def2 '{' /* nodecls compstmt */
2633 { $$ = finish_method ($$); }
2634 | ';'
2635 { $$ = NULL_TREE; }
2636 | extension component_decl
2637 { $$ = $2;
2638 pedantic = $1; }
2639 | template_header component_decl
2641 if ($2)
2642 $$ = finish_member_template_decl ($2);
2643 else
2644 /* The component was already processed. */
2645 $$ = NULL_TREE;
2647 finish_template_decl ($1);
2649 | template_header typed_declspecs ';'
2651 $$ = finish_member_class_template ($2.t);
2652 finish_template_decl ($1);
2654 | bad_decl
2655 { $$ = NULL_TREE; }
2658 component_decl_1:
2659 /* Do not add a "typed_declspecs declarator" rule here for
2660 speed; we need to call grok_x_components for enums, so the
2661 speedup would be insignificant. */
2662 typed_declspecs components
2664 /* Most of the productions for component_decl only
2665 allow the creation of one new member, so we call
2666 finish_member_declaration in component_decl_list.
2667 For this rule and the next, however, there can be
2668 more than one member, e.g.:
2670 int i, j;
2672 and we need the first member to be fully
2673 registered before the second is processed.
2674 Therefore, the rules for components take care of
2675 this processing. To avoid registering the
2676 components more than once, we send NULL_TREE up
2677 here; that lets finish_member_declaration know
2678 that there is nothing to do. */
2679 if (!$2)
2680 grok_x_components ($1.t);
2681 $$ = NULL_TREE;
2683 | declmods notype_components
2685 if (!$2)
2686 grok_x_components ($1.t);
2687 $$ = NULL_TREE;
2689 | notype_declarator maybeasm maybe_attribute maybe_init
2690 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2691 | constructor_declarator maybeasm maybe_attribute maybe_init
2692 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2693 | ':' expr_no_commas
2694 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2695 | error
2696 { $$ = NULL_TREE; }
2698 /* These rules introduce a reduce/reduce conflict; in
2699 typedef int foo, bar;
2700 class A {
2701 foo (bar);
2703 should "A::foo" be declared as a function or "A::bar" as a data
2704 member? In other words, is "bar" an after_type_declarator or a
2705 parmlist? */
2706 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2707 { tree specs, attrs;
2708 split_specs_attrs ($1.t, &specs, &attrs);
2709 $$ = grokfield ($2, specs, $5, $3,
2710 chainon ($4, attrs)); }
2711 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2712 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2713 | using_decl
2714 { $$ = do_class_using_decl ($1); }
2717 /* The case of exactly one component is handled directly by component_decl. */
2718 /* ??? Huh? ^^^ */
2719 components:
2720 /* empty: possibly anonymous */
2721 { $$ = 0; }
2722 | component_declarator0
2724 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2725 $1 = finish_member_template_decl ($1);
2726 finish_member_declaration ($1);
2727 $$ = 1;
2729 | components ',' component_declarator
2731 check_multiple_declarators ();
2732 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2733 $3 = finish_member_template_decl ($3);
2734 finish_member_declaration ($3);
2735 $$ = 2;
2739 notype_components:
2740 /* empty: possibly anonymous */
2741 { $$ = 0; }
2742 | notype_component_declarator0
2744 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2745 $1 = finish_member_template_decl ($1);
2746 finish_member_declaration ($1);
2747 $$ = 1;
2749 | notype_components ',' notype_component_declarator
2751 check_multiple_declarators ();
2752 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2753 $3 = finish_member_template_decl ($3);
2754 finish_member_declaration ($3);
2755 $$ = 2;
2759 component_declarator0:
2760 after_type_component_declarator0
2761 | notype_component_declarator0
2764 component_declarator:
2765 after_type_component_declarator
2766 | notype_component_declarator
2769 after_type_component_declarator0:
2770 after_type_declarator maybeasm maybe_attribute maybe_init
2771 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2772 $3, $2, $4); }
2773 | tTYPENAME ':' expr_no_commas maybe_attribute
2774 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2775 $4, $3); }
2778 notype_component_declarator0:
2779 notype_declarator maybeasm maybe_attribute maybe_init
2780 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2781 $3, $2, $4); }
2782 | constructor_declarator maybeasm maybe_attribute maybe_init
2783 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2784 $3, $2, $4); }
2785 | IDENTIFIER ':' expr_no_commas maybe_attribute
2786 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2787 $4, $3); }
2788 | ':' expr_no_commas maybe_attribute
2789 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2790 $<ftype>0.lookups, $3, $2); }
2793 after_type_component_declarator:
2794 after_type_declarator maybeasm maybe_attribute maybe_init
2795 { $$ = parse_field ($1, $3, $2, $4); }
2796 | tTYPENAME ':' expr_no_commas maybe_attribute
2797 { $$ = parse_bitfield ($1, $4, $3); }
2800 notype_component_declarator:
2801 notype_declarator maybeasm maybe_attribute maybe_init
2802 { $$ = parse_field ($1, $3, $2, $4); }
2803 | IDENTIFIER ':' expr_no_commas maybe_attribute
2804 { $$ = parse_bitfield ($1, $4, $3); }
2805 | ':' expr_no_commas maybe_attribute
2806 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2809 enumlist_opt:
2810 enumlist maybecomma_warn
2811 | maybecomma_warn
2814 /* We chain the enumerators in reverse order.
2815 Because of the way enums are built, the order is
2816 insignificant. Take advantage of this fact. */
2818 enumlist:
2819 enumerator
2820 | enumlist ',' enumerator
2823 enumerator:
2824 identifier
2825 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2826 | identifier '=' expr_no_commas
2827 { build_enumerator ($1, $3, current_enum_type); }
2830 /* ISO new-type-id (5.3.4) */
2831 new_type_id:
2832 type_specifier_seq new_declarator
2833 { $$.t = build_tree_list ($1.t, $2);
2834 $$.new_type_flag = $1.new_type_flag; }
2835 | type_specifier_seq %prec EMPTY
2836 { $$.t = build_tree_list ($1.t, NULL_TREE);
2837 $$.new_type_flag = $1.new_type_flag; }
2838 /* GNU extension to allow arrays of arbitrary types with
2839 non-constant dimension. */
2840 | '(' type_id ')' '[' expr ']'
2842 if (pedantic)
2843 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2844 $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2845 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2846 $$.new_type_flag = $2.new_type_flag;
2850 cv_qualifiers:
2851 /* empty */ %prec EMPTY
2852 { $$ = NULL_TREE; }
2853 | cv_qualifiers CV_QUALIFIER
2854 { $$ = tree_cons (NULL_TREE, $2, $$); }
2857 nonempty_cv_qualifiers:
2858 CV_QUALIFIER
2859 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2860 $$.new_type_flag = 0; }
2861 | nonempty_cv_qualifiers CV_QUALIFIER
2862 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2863 $$.new_type_flag = $1.new_type_flag; }
2864 | attributes %prec EMPTY
2865 { $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
2866 $$.new_type_flag = 0; }
2867 | nonempty_cv_qualifiers attributes %prec EMPTY
2868 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t);
2869 $$.new_type_flag = $1.new_type_flag; }
2872 /* These rules must follow the rules for function declarations
2873 and component declarations. That way, longer rules are preferred. */
2875 /* An expression which will not live on the momentary obstack. */
2876 maybe_parmlist:
2877 '(' nonnull_exprlist ')'
2878 { $$ = $2; }
2879 | '(' parmlist ')'
2880 { $$ = $2; }
2881 | LEFT_RIGHT
2882 { $$ = empty_parms (); }
2883 | '(' error ')'
2884 { $$ = NULL_TREE; }
2887 /* A declarator that is allowed only after an explicit typespec. */
2889 after_type_declarator_intern:
2890 after_type_declarator
2891 | attributes after_type_declarator
2893 /* Provide support for '(' attributes '*' declarator ')'
2894 etc */
2895 $$ = tree_cons ($1, $2, NULL_TREE);
2899 /* may all be followed by prec '.' */
2900 after_type_declarator:
2901 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2902 { $$ = make_pointer_declarator ($2.t, $3); }
2903 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2904 { $$ = make_reference_declarator ($2.t, $3); }
2905 | '*' after_type_declarator_intern %prec UNARY
2906 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2907 | '&' after_type_declarator_intern %prec UNARY
2908 { $$ = make_reference_declarator (NULL_TREE, $2); }
2909 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2910 { tree arg = make_pointer_declarator ($2, $3);
2911 $$ = build_nt (SCOPE_REF, $1, arg);
2913 | direct_after_type_declarator
2916 direct_after_type_declarator:
2917 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2918 { $$ = make_call_declarator ($$, $2, $3, $4); }
2919 | direct_after_type_declarator '[' expr ']'
2920 { $$ = build_nt (ARRAY_REF, $$, $3); }
2921 | direct_after_type_declarator '[' ']'
2922 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2923 | '(' after_type_declarator_intern ')'
2924 { $$ = $2; }
2925 | nested_name_specifier type_name %prec EMPTY
2926 { push_nested_class ($1, 3);
2927 $$ = build_nt (SCOPE_REF, $$, $2);
2928 TREE_COMPLEXITY ($$) = current_class_depth; }
2929 | type_name %prec EMPTY
2932 nonnested_type:
2933 type_name %prec EMPTY
2935 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2937 $$ = lookup_name ($1, 1);
2938 maybe_note_name_used_in_class ($1, $$);
2940 else
2941 $$ = $1;
2943 | global_scope type_name
2945 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2946 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2947 else
2948 $$ = $2;
2949 got_scope = NULL_TREE;
2953 complete_type_name:
2954 nonnested_type
2955 | nested_type
2956 | global_scope nested_type
2957 { $$ = $2; }
2960 nested_type:
2961 nested_name_specifier type_name %prec EMPTY
2962 { $$ = get_type_decl ($2); }
2965 /* A declarator allowed whether or not there has been
2966 an explicit typespec. These cannot redeclare a typedef-name. */
2968 notype_declarator_intern:
2969 notype_declarator
2970 | attributes notype_declarator
2972 /* Provide support for '(' attributes '*' declarator ')'
2973 etc */
2974 $$ = tree_cons ($1, $2, NULL_TREE);
2978 notype_declarator:
2979 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2980 { $$ = make_pointer_declarator ($2.t, $3); }
2981 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2982 { $$ = make_reference_declarator ($2.t, $3); }
2983 | '*' notype_declarator_intern %prec UNARY
2984 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2985 | '&' notype_declarator_intern %prec UNARY
2986 { $$ = make_reference_declarator (NULL_TREE, $2); }
2987 | ptr_to_mem cv_qualifiers notype_declarator_intern
2988 { tree arg = make_pointer_declarator ($2, $3);
2989 $$ = build_nt (SCOPE_REF, $1, arg);
2991 | direct_notype_declarator
2994 complex_notype_declarator:
2995 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2996 { $$ = make_pointer_declarator ($2.t, $3); }
2997 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2998 { $$ = make_reference_declarator ($2.t, $3); }
2999 | '*' complex_notype_declarator %prec UNARY
3000 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3001 | '&' complex_notype_declarator %prec UNARY
3002 { $$ = make_reference_declarator (NULL_TREE, $2); }
3003 | ptr_to_mem cv_qualifiers notype_declarator_intern
3004 { tree arg = make_pointer_declarator ($2, $3);
3005 $$ = build_nt (SCOPE_REF, $1, arg);
3007 | complex_direct_notype_declarator
3010 complex_direct_notype_declarator:
3011 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
3012 { $$ = make_call_declarator ($$, $2, $3, $4); }
3013 | '(' complex_notype_declarator ')'
3014 { $$ = $2; }
3015 | direct_notype_declarator '[' expr ']'
3016 { $$ = build_nt (ARRAY_REF, $$, $3); }
3017 | direct_notype_declarator '[' ']'
3018 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3019 | notype_qualified_id
3020 { enter_scope_of ($1); }
3021 | global_scope notype_qualified_id
3022 { enter_scope_of ($2); $$ = $2;}
3023 | global_scope notype_unqualified_id
3024 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
3025 enter_scope_of ($$);
3027 | nested_name_specifier notype_template_declarator
3028 { got_scope = NULL_TREE;
3029 $$ = build_nt (SCOPE_REF, $1, $2);
3030 enter_scope_of ($$);
3034 qualified_id:
3035 nested_name_specifier unqualified_id
3036 { got_scope = NULL_TREE;
3037 $$ = build_nt (SCOPE_REF, $$, $2); }
3038 | nested_name_specifier object_template_id
3039 { got_scope = NULL_TREE;
3040 $$ = build_nt (SCOPE_REF, $1, $2); }
3043 notype_qualified_id:
3044 nested_name_specifier notype_unqualified_id
3045 { got_scope = NULL_TREE;
3046 $$ = build_nt (SCOPE_REF, $$, $2); }
3047 | nested_name_specifier object_template_id
3048 { got_scope = NULL_TREE;
3049 $$ = build_nt (SCOPE_REF, $1, $2); }
3052 overqualified_id:
3053 notype_qualified_id
3054 | global_scope notype_qualified_id
3055 { $$ = $2; }
3058 functional_cast:
3059 typespec '(' nonnull_exprlist ')'
3060 { $$ = build_functional_cast ($1.t, $3); }
3061 | typespec '(' expr_or_declarator_intern ')'
3062 { $$ = reparse_decl_as_expr ($1.t, $3); }
3063 | typespec fcast_or_absdcl %prec EMPTY
3064 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3067 type_name:
3068 tTYPENAME
3069 | SELFNAME
3070 | template_type %prec EMPTY
3073 nested_name_specifier:
3074 nested_name_specifier_1
3075 | nested_name_specifier nested_name_specifier_1
3076 { $$ = $2; }
3077 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3078 { got_scope = $$
3079 = make_typename_type ($1, $3, tf_error); }
3080 /* Error handling per Core 125. */
3081 | nested_name_specifier IDENTIFIER SCOPE
3082 { got_scope = $$
3083 = make_typename_type ($1, $2, tf_error); }
3084 | nested_name_specifier PTYPENAME SCOPE
3085 { got_scope = $$
3086 = make_typename_type ($1, $2, tf_error); }
3089 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3090 inline here?!? (jason) */
3091 nested_name_specifier_1:
3092 tTYPENAME SCOPE
3094 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3096 $$ = lastiddecl;
3097 maybe_note_name_used_in_class ($1, $$);
3099 got_scope = $$ =
3100 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3102 | SELFNAME SCOPE
3104 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3105 $$ = lastiddecl;
3106 got_scope = $$ = TREE_TYPE ($$);
3108 | NSNAME SCOPE
3110 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3111 $$ = lastiddecl;
3112 got_scope = $$;
3114 | template_type SCOPE
3115 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3118 typename_sub:
3119 typename_sub0
3120 | global_scope typename_sub0
3121 { $$ = $2; }
3124 typename_sub0:
3125 typename_sub1 identifier %prec EMPTY
3127 if (TYPE_P ($1))
3128 $$ = make_typename_type ($1, $2, tf_error);
3129 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3130 error ("`%T' is not a class or namespace", $2);
3131 else
3133 $$ = $2;
3134 if (TREE_CODE ($$) == TYPE_DECL)
3135 $$ = TREE_TYPE ($$);
3138 | typename_sub1 template_type %prec EMPTY
3139 { $$ = TREE_TYPE ($2); }
3140 | typename_sub1 explicit_template_type %prec EMPTY
3141 { $$ = make_typename_type ($1, $2, tf_error); }
3142 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3143 { $$ = make_typename_type ($1, $3, tf_error); }
3146 typename_sub1:
3147 typename_sub2
3149 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3150 error ("`%T' is not a class or namespace", $1);
3151 else if (TREE_CODE ($1) == TYPE_DECL)
3152 $$ = TREE_TYPE ($1);
3154 | typename_sub1 typename_sub2
3156 if (TYPE_P ($1))
3157 $$ = make_typename_type ($1, $2, tf_error);
3158 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3159 error ("`%T' is not a class or namespace", $2);
3160 else
3162 $$ = $2;
3163 if (TREE_CODE ($$) == TYPE_DECL)
3164 $$ = TREE_TYPE ($$);
3167 | typename_sub1 explicit_template_type SCOPE
3168 { got_scope = $$
3169 = make_typename_type ($1, $2, tf_error); }
3170 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3171 { got_scope = $$
3172 = make_typename_type ($1, $3, tf_error); }
3175 /* This needs to return a TYPE_DECL for simple names so that we don't
3176 forget what name was used. */
3177 typename_sub2:
3178 tTYPENAME SCOPE
3180 if (TREE_CODE ($1) != TYPE_DECL)
3181 $$ = lastiddecl;
3183 /* Retrieve the type for the identifier, which might involve
3184 some computation. */
3185 got_scope = complete_type (TREE_TYPE ($$));
3187 if ($$ == error_mark_node)
3188 error ("`%T' is not a class or namespace", $1);
3190 | SELFNAME SCOPE
3192 if (TREE_CODE ($1) != TYPE_DECL)
3193 $$ = lastiddecl;
3194 got_scope = complete_type (TREE_TYPE ($$));
3196 | template_type SCOPE
3197 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3198 | PTYPENAME SCOPE
3199 | IDENTIFIER SCOPE
3200 | NSNAME SCOPE
3202 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3203 $$ = lastiddecl;
3204 got_scope = $$;
3208 explicit_template_type:
3209 identifier '<' template_arg_list_opt template_close_bracket
3210 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3213 complex_type_name:
3214 global_scope type_name
3216 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3217 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3218 else
3219 $$ = $2;
3220 got_scope = NULL_TREE;
3222 | nested_type
3223 | global_scope nested_type
3224 { $$ = $2; }
3227 ptr_to_mem:
3228 nested_name_specifier '*'
3229 { got_scope = NULL_TREE; }
3230 | global_scope nested_name_specifier '*'
3231 { $$ = $2; got_scope = NULL_TREE; }
3234 /* All uses of explicit global scope must go through this nonterminal so
3235 that got_scope will be set before yylex is called to get the next token. */
3236 global_scope:
3237 SCOPE
3238 { got_scope = void_type_node; }
3241 /* ISO new-declarator (5.3.4) */
3242 new_declarator:
3243 '*' cv_qualifiers new_declarator
3244 { $$ = make_pointer_declarator ($2, $3); }
3245 | '*' cv_qualifiers %prec EMPTY
3246 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3247 | '&' cv_qualifiers new_declarator %prec EMPTY
3248 { $$ = make_reference_declarator ($2, $3); }
3249 | '&' cv_qualifiers %prec EMPTY
3250 { $$ = make_reference_declarator ($2, NULL_TREE); }
3251 | ptr_to_mem cv_qualifiers %prec EMPTY
3252 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3253 $$ = build_nt (SCOPE_REF, $1, arg);
3255 | ptr_to_mem cv_qualifiers new_declarator
3256 { tree arg = make_pointer_declarator ($2, $3);
3257 $$ = build_nt (SCOPE_REF, $1, arg);
3259 | direct_new_declarator %prec EMPTY
3262 /* ISO direct-new-declarator (5.3.4) */
3263 direct_new_declarator:
3264 '[' expr ']'
3265 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3266 | direct_new_declarator '[' expr ']'
3267 { $$ = build_nt (ARRAY_REF, $$, $3); }
3270 absdcl_intern:
3271 absdcl
3272 | attributes absdcl
3274 /* Provide support for '(' attributes '*' declarator ')'
3275 etc */
3276 $$ = tree_cons ($1, $2, NULL_TREE);
3280 /* ISO abstract-declarator (8.1) */
3281 absdcl:
3282 '*' nonempty_cv_qualifiers absdcl_intern
3283 { $$ = make_pointer_declarator ($2.t, $3); }
3284 | '*' absdcl_intern
3285 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3286 | '*' nonempty_cv_qualifiers %prec EMPTY
3287 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3288 | '*' %prec EMPTY
3289 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3290 | '&' nonempty_cv_qualifiers absdcl_intern
3291 { $$ = make_reference_declarator ($2.t, $3); }
3292 | '&' absdcl_intern
3293 { $$ = make_reference_declarator (NULL_TREE, $2); }
3294 | '&' nonempty_cv_qualifiers %prec EMPTY
3295 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3296 | '&' %prec EMPTY
3297 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3298 | ptr_to_mem cv_qualifiers %prec EMPTY
3299 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3300 $$ = build_nt (SCOPE_REF, $1, arg);
3302 | ptr_to_mem cv_qualifiers absdcl_intern
3303 { tree arg = make_pointer_declarator ($2, $3);
3304 $$ = build_nt (SCOPE_REF, $1, arg);
3306 | direct_abstract_declarator %prec EMPTY
3309 /* ISO direct-abstract-declarator (8.1) */
3310 direct_abstract_declarator:
3311 '(' absdcl_intern ')'
3312 { $$ = $2; }
3313 /* `(typedef)1' is `int'. */
3314 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3315 { $$ = make_call_declarator ($$, $3, $5, $6); }
3316 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3317 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3318 | direct_abstract_declarator '[' expr ']' %prec '.'
3319 { $$ = build_nt (ARRAY_REF, $$, $3); }
3320 | direct_abstract_declarator '[' ']' %prec '.'
3321 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3322 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3323 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3324 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3325 { set_quals_and_spec ($$, $2, $3); }
3326 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3327 { set_quals_and_spec ($$, $2, $3); }
3328 | '[' expr ']' %prec '.'
3329 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3330 | '[' ']' %prec '.'
3331 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3334 /* For C++, decls and stmts can be intermixed, so we don't need to
3335 have a special rule that won't start parsing the stmt section
3336 until we have a stmt that parses without errors. */
3338 stmts:
3339 stmt
3340 | errstmt
3341 | stmts stmt
3342 | stmts errstmt
3345 errstmt:
3346 error ';'
3349 /* Read zero or more forward-declarations for labels
3350 that nested functions can jump to. */
3351 maybe_label_decls:
3352 /* empty */
3353 | label_decls
3354 { if (pedantic)
3355 pedwarn ("ISO C++ forbids label declarations"); }
3358 label_decls:
3359 label_decl
3360 | label_decls label_decl
3363 label_decl:
3364 LABEL identifiers_or_typenames ';'
3366 while ($2)
3368 finish_label_decl (TREE_VALUE ($2));
3369 $2 = TREE_CHAIN ($2);
3374 compstmt_or_stmtexpr:
3375 save_lineno '{'
3376 { $<ttype>$ = begin_compound_stmt (0); }
3377 compstmtend
3378 { STMT_LINENO ($<ttype>3) = $1;
3379 finish_compound_stmt (0, $<ttype>3); }
3382 compstmt:
3383 compstmt_or_stmtexpr
3384 { last_expr_type = NULL_TREE; }
3387 simple_if:
3389 { $<ttype>$ = begin_if_stmt ();
3390 cond_stmt_keyword = "if"; }
3391 paren_cond_or_null
3392 { finish_if_stmt_cond ($3, $<ttype>2); }
3393 implicitly_scoped_stmt
3394 { $$ = $<ttype>2;
3395 finish_then_clause ($<ttype>2); }
3398 implicitly_scoped_stmt:
3399 compstmt
3401 { $<ttype>$ = begin_compound_stmt (0); }
3402 save_lineno simple_stmt
3403 { STMT_LINENO ($<ttype>1) = $2;
3404 if ($3) STMT_LINENO ($3) = $2;
3405 finish_compound_stmt (0, $<ttype>1); }
3408 stmt:
3409 compstmt
3410 | save_lineno simple_stmt
3411 { if ($2) STMT_LINENO ($2) = $1; }
3414 simple_stmt:
3415 decl
3416 { finish_stmt ();
3417 $$ = NULL_TREE; }
3418 | expr ';'
3419 { $$ = finish_expr_stmt ($1); }
3420 | simple_if ELSE
3421 { begin_else_clause (); }
3422 implicitly_scoped_stmt
3424 $$ = $1;
3425 finish_else_clause ($1);
3426 finish_if_stmt ();
3428 | simple_if %prec IF
3429 { $$ = $1;
3430 finish_if_stmt (); }
3431 | WHILE
3433 $<ttype>$ = begin_while_stmt ();
3434 cond_stmt_keyword = "while";
3436 paren_cond_or_null
3437 { finish_while_stmt_cond ($3, $<ttype>2); }
3438 implicitly_scoped_stmt
3439 { $$ = $<ttype>2;
3440 finish_while_stmt ($<ttype>2); }
3441 | DO
3442 { $<ttype>$ = begin_do_stmt (); }
3443 implicitly_scoped_stmt WHILE
3445 finish_do_body ($<ttype>2);
3446 cond_stmt_keyword = "do";
3448 paren_expr_or_null ';'
3449 { $$ = $<ttype>2;
3450 finish_do_stmt ($6, $<ttype>2); }
3451 | FOR
3452 { $<ttype>$ = begin_for_stmt (); }
3453 '(' for.init.statement
3454 { finish_for_init_stmt ($<ttype>2); }
3455 xcond ';'
3456 { finish_for_cond ($6, $<ttype>2); }
3457 xexpr ')'
3458 { finish_for_expr ($9, $<ttype>2); }
3459 implicitly_scoped_stmt
3460 { $$ = $<ttype>2;
3461 finish_for_stmt ($<ttype>2); }
3462 | SWITCH
3463 { $<ttype>$ = begin_switch_stmt (); }
3464 '(' condition ')'
3465 { finish_switch_cond ($4, $<ttype>2); }
3466 implicitly_scoped_stmt
3467 { $$ = $<ttype>2;
3468 finish_switch_stmt ($<ttype>2); }
3469 | CASE expr_no_commas ':'
3470 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3471 stmt
3472 { $$ = $<ttype>4; }
3473 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3474 { $<ttype>$ = finish_case_label ($2, $4); }
3475 stmt
3476 { $$ = $<ttype>6; }
3477 | DEFAULT ':'
3478 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3479 stmt
3480 { $$ = $<ttype>3; }
3481 | BREAK ';'
3482 { $$ = finish_break_stmt (); }
3483 | CONTINUE ';'
3484 { $$ = finish_continue_stmt (); }
3485 | RETURN_KEYWORD ';'
3486 { $$ = finish_return_stmt (NULL_TREE); }
3487 | RETURN_KEYWORD expr ';'
3488 { $$ = finish_return_stmt ($2); }
3489 | asm_keyword maybe_cv_qualifier '(' STRING ')' ';'
3490 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3491 NULL_TREE);
3492 ASM_INPUT_P ($$) = 1; }
3493 /* This is the case with just output operands. */
3494 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ')' ';'
3495 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3496 /* This is the case with input operands as well. */
3497 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3498 asm_operands ')' ';'
3499 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3500 | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ')' ';'
3501 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3502 /* This is the case with clobbered registers as well. */
3503 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3504 asm_operands ':' asm_clobbers ')' ';'
3505 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3506 | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ':'
3507 asm_clobbers ')' ';'
3508 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3509 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands SCOPE
3510 asm_clobbers ')' ';'
3511 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3512 | GOTO '*' expr ';'
3514 if (pedantic)
3515 pedwarn ("ISO C++ forbids computed gotos");
3516 $$ = finish_goto_stmt ($3);
3518 | GOTO identifier ';'
3519 { $$ = finish_goto_stmt ($2); }
3520 | label_colon stmt
3521 { $$ = NULL_TREE; }
3522 | label_colon '}'
3523 { error ("label must be followed by statement");
3524 yyungetc ('}', 0);
3525 $$ = NULL_TREE; }
3526 | ';'
3527 { finish_stmt ();
3528 $$ = NULL_TREE; }
3529 | try_block
3530 { $$ = NULL_TREE; }
3531 | using_directive
3532 { $$ = NULL_TREE; }
3533 | namespace_using_decl
3534 { do_local_using_decl ($1);
3535 $$ = NULL_TREE; }
3536 | namespace_alias
3537 { $$ = NULL_TREE; }
3540 function_try_block:
3542 { $<ttype>$ = begin_function_try_block (); }
3543 function_body
3544 { finish_function_try_block ($<ttype>2); }
3545 handler_seq
3546 { finish_function_handler_sequence ($<ttype>2); }
3549 try_block:
3551 { $<ttype>$ = begin_try_block (); }
3552 compstmt
3553 { finish_try_block ($<ttype>2); }
3554 handler_seq
3555 { finish_handler_sequence ($<ttype>2); }
3558 handler_seq:
3559 handler
3560 | handler_seq handler
3561 | /* empty */
3562 { /* Generate a fake handler block to avoid later aborts. */
3563 tree fake_handler = begin_handler ();
3564 finish_handler_parms (NULL_TREE, fake_handler);
3565 finish_handler (fake_handler);
3566 $<ttype>$ = fake_handler;
3568 error ("must have at least one catch per try block");
3572 handler:
3573 CATCH
3574 { $<ttype>$ = begin_handler (); }
3575 handler_args
3576 { finish_handler_parms ($3, $<ttype>2); }
3577 compstmt
3578 { finish_handler ($<ttype>2); }
3581 type_specifier_seq:
3582 typed_typespecs %prec EMPTY
3583 | nonempty_cv_qualifiers %prec EMPTY
3586 handler_args:
3587 '(' ELLIPSIS ')'
3588 { $$ = NULL_TREE; }
3589 /* This doesn't allow reference parameters, the below does.
3590 | '(' type_specifier_seq absdcl ')'
3591 { check_for_new_type ("inside exception declarations", $2);
3592 expand_start_catch_block ($2.t, $3); }
3593 | '(' type_specifier_seq ')'
3594 { check_for_new_type ("inside exception declarations", $2);
3595 expand_start_catch_block ($2.t, NULL_TREE); }
3596 | '(' type_specifier_seq notype_declarator ')'
3597 { check_for_new_type ("inside exception declarations", $2);
3598 expand_start_catch_block ($2.t, $3); }
3599 | '(' typed_typespecs after_type_declarator ')'
3600 { check_for_new_type ("inside exception declarations", $2);
3601 expand_start_catch_block ($2.t, $3); }
3602 This allows reference parameters... */
3603 | '(' parm ')'
3605 check_for_new_type ("inside exception declarations", $2);
3606 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3607 TREE_VALUE ($2.t));
3611 label_colon:
3612 IDENTIFIER ':'
3613 { finish_label_stmt ($1); }
3614 | PTYPENAME ':'
3615 { finish_label_stmt ($1); }
3616 | tTYPENAME ':'
3617 { finish_label_stmt ($1); }
3618 | SELFNAME ':'
3619 { finish_label_stmt ($1); }
3622 for.init.statement:
3623 xexpr ';'
3624 { finish_expr_stmt ($1); }
3625 | decl
3626 | '{' compstmtend
3627 { if (pedantic)
3628 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3632 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3634 maybe_cv_qualifier:
3635 /* empty */
3636 { $$ = NULL_TREE; }
3637 | CV_QUALIFIER
3640 xexpr:
3641 /* empty */
3642 { $$ = NULL_TREE; }
3643 | expr
3644 | error
3645 { $$ = NULL_TREE; }
3648 /* These are the operands other than the first string and colon
3649 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3650 asm_operands:
3651 /* empty */
3652 { $$ = NULL_TREE; }
3653 | nonnull_asm_operands
3656 nonnull_asm_operands:
3657 asm_operand
3658 | nonnull_asm_operands ',' asm_operand
3659 { $$ = chainon ($$, $3); }
3662 asm_operand:
3663 STRING '(' expr ')'
3664 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3665 | '[' identifier ']' STRING '(' expr ')'
3666 { $2 = build_string (IDENTIFIER_LENGTH ($2),
3667 IDENTIFIER_POINTER ($2));
3668 $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3671 asm_clobbers:
3672 STRING
3673 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);}
3674 | asm_clobbers ',' STRING
3675 { $$ = tree_cons (NULL_TREE, $3, $1); }
3678 /* This is what appears inside the parens in a function declarator.
3679 Its value is represented in the format that grokdeclarator expects.
3681 In C++, declaring a function with no parameters
3682 means that that function takes *no* parameters. */
3684 parmlist:
3685 /* empty */
3687 $$ = empty_parms();
3689 | complex_parmlist
3690 | type_id
3691 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3692 check_for_new_type ("inside parameter list", $1); }
3695 /* This nonterminal does not include the common sequence '(' type_id ')',
3696 as it is ambiguous and must be disambiguated elsewhere. */
3697 complex_parmlist:
3698 parms
3699 { $$ = finish_parmlist ($$, 0); }
3700 | parms_comma ELLIPSIS
3701 { $$ = finish_parmlist ($1, 1); }
3702 /* C++ allows an ellipsis without a separating ',' */
3703 | parms ELLIPSIS
3704 { $$ = finish_parmlist ($1, 1); }
3705 | type_id ELLIPSIS
3706 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3707 $1.t), 1); }
3708 | ELLIPSIS
3709 { $$ = finish_parmlist (NULL_TREE, 1); }
3710 | parms ':'
3712 /* This helps us recover from really nasty
3713 parse errors, for example, a missing right
3714 parenthesis. */
3715 yyerror ("possibly missing ')'");
3716 $$ = finish_parmlist ($1, 0);
3717 yyungetc (':', 0);
3718 yychar = ')';
3720 | type_id ':'
3722 /* This helps us recover from really nasty
3723 parse errors, for example, a missing right
3724 parenthesis. */
3725 yyerror ("possibly missing ')'");
3726 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3727 $1.t), 0);
3728 yyungetc (':', 0);
3729 yychar = ')';
3733 /* A default argument to a */
3734 defarg:
3736 { maybe_snarf_defarg (); }
3737 defarg1
3738 { $$ = $3; }
3741 defarg1:
3742 DEFARG
3743 | init
3746 /* A nonempty list of parameter declarations or type names. */
3747 parms:
3748 named_parm
3749 { check_for_new_type ("in a parameter list", $1);
3750 $$ = build_tree_list (NULL_TREE, $1.t); }
3751 | parm defarg
3752 { check_for_new_type ("in a parameter list", $1);
3753 $$ = build_tree_list ($2, $1.t); }
3754 | parms_comma full_parm
3755 { check_for_new_type ("in a parameter list", $2);
3756 $$ = chainon ($$, $2.t); }
3757 | parms_comma bad_parm
3758 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3759 | parms_comma bad_parm '=' init
3760 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3763 parms_comma:
3764 parms ','
3765 | type_id ','
3766 { check_for_new_type ("in a parameter list", $1);
3767 $$ = build_tree_list (NULL_TREE, $1.t); }
3770 /* A single parameter declaration or parameter type name,
3771 as found in a parmlist. */
3772 named_parm:
3773 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3774 TYPESPEC IDENTIFIER. */
3775 typed_declspecs1 declarator
3776 { $$.new_type_flag = $1.new_type_flag;
3777 $$.t = build_tree_list ($1.t, $2); }
3778 | typed_typespecs declarator
3779 { $$.t = build_tree_list ($1.t, $2);
3780 $$.new_type_flag = $1.new_type_flag; }
3781 | typespec declarator
3782 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3783 $2);
3784 $$.new_type_flag = $1.new_type_flag; }
3785 | typed_declspecs1 absdcl
3786 { $$.t = build_tree_list ($1.t, $2);
3787 $$.new_type_flag = $1.new_type_flag; }
3788 | typed_declspecs1 %prec EMPTY
3789 { $$.t = build_tree_list ($1.t, NULL_TREE);
3790 $$.new_type_flag = $1.new_type_flag; }
3791 | declmods notype_declarator
3792 { $$.t = build_tree_list ($1.t, $2);
3793 $$.new_type_flag = 0; }
3796 full_parm:
3797 parm
3798 { $$.t = build_tree_list (NULL_TREE, $1.t);
3799 $$.new_type_flag = $1.new_type_flag; }
3800 | parm defarg
3801 { $$.t = build_tree_list ($2, $1.t);
3802 $$.new_type_flag = $1.new_type_flag; }
3805 parm:
3806 named_parm
3807 | type_id
3810 see_typename:
3811 /* empty */ %prec EMPTY
3812 { see_typename (); }
3815 bad_parm:
3816 /* empty */ %prec EMPTY
3818 error ("type specifier omitted for parameter");
3819 $$ = build_tree_list (integer_type_node, NULL_TREE);
3821 | notype_declarator
3823 if (TREE_CODE ($$) == SCOPE_REF)
3825 if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3826 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
3827 error ("`%E' is not a type, use `typename %E' to make it one", $$);
3828 else
3829 error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
3831 else
3832 error ("type specifier omitted for parameter `%E'", $$);
3833 $$ = build_tree_list (integer_type_node, $$);
3837 bad_decl:
3838 IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3840 error("'%D' is used as a type, but is not defined as a type.", $1);
3841 $3 = error_mark_node;
3845 template_arg_list_ignore:
3846 '<' template_arg_list_opt template_close_bracket
3848 | /* empty */
3851 arg_list_ignore:
3852 '(' nonnull_exprlist ')'
3854 | /* empty */
3857 exception_specification_opt:
3858 /* empty */ %prec EMPTY
3859 { $$ = NULL_TREE; }
3860 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3861 { $$ = $3; }
3862 | THROW LEFT_RIGHT %prec EMPTY
3863 { $$ = empty_except_spec; }
3866 ansi_raise_identifier:
3867 type_id
3869 check_for_new_type ("exception specifier", $1);
3870 $$ = groktypename ($1.t);
3872 | error
3873 { $$ = error_mark_node; }
3876 ansi_raise_identifiers:
3877 ansi_raise_identifier
3878 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3879 | ansi_raise_identifiers ',' ansi_raise_identifier
3880 { $$ = add_exception_specifier ($1, $3, 1); }
3883 conversion_declarator:
3884 /* empty */ %prec EMPTY
3885 { $$ = NULL_TREE; }
3886 | '*' cv_qualifiers conversion_declarator
3887 { $$ = make_pointer_declarator ($2, $3); }
3888 | '&' cv_qualifiers conversion_declarator
3889 { $$ = make_reference_declarator ($2, $3); }
3890 | ptr_to_mem cv_qualifiers conversion_declarator
3891 { tree arg = make_pointer_declarator ($2, $3);
3892 $$ = build_nt (SCOPE_REF, $1, arg);
3896 operator:
3897 OPERATOR
3899 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3900 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3901 /* We look for conversion-type-id's in both the class and current
3902 scopes, just as for ID in 'ptr->ID::'. */
3903 looking_for_typename = 1;
3904 got_object = got_scope;
3905 got_scope = NULL_TREE;
3909 unoperator:
3910 { got_scope = TREE_PURPOSE (saved_scopes);
3911 got_object = TREE_VALUE (saved_scopes);
3912 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3913 saved_scopes = TREE_CHAIN (saved_scopes);
3917 operator_name:
3918 operator '*' unoperator
3919 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3920 | operator '/' unoperator
3921 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3922 | operator '%' unoperator
3923 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3924 | operator '+' unoperator
3925 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3926 | operator '-' unoperator
3927 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3928 | operator '&' unoperator
3929 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3930 | operator '|' unoperator
3931 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3932 | operator '^' unoperator
3933 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3934 | operator '~' unoperator
3935 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3936 | operator ',' unoperator
3937 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3938 | operator ARITHCOMPARE unoperator
3939 { $$ = frob_opname (ansi_opname ($2)); }
3940 | operator '<' unoperator
3941 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3942 | operator '>' unoperator
3943 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3944 | operator EQCOMPARE unoperator
3945 { $$ = frob_opname (ansi_opname ($2)); }
3946 | operator ASSIGN unoperator
3947 { $$ = frob_opname (ansi_assopname ($2)); }
3948 | operator '=' unoperator
3949 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3950 | operator LSHIFT unoperator
3951 { $$ = frob_opname (ansi_opname ($2)); }
3952 | operator RSHIFT unoperator
3953 { $$ = frob_opname (ansi_opname ($2)); }
3954 | operator PLUSPLUS unoperator
3955 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3956 | operator MINUSMINUS unoperator
3957 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3958 | operator ANDAND unoperator
3959 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3960 | operator OROR unoperator
3961 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3962 | operator '!' unoperator
3963 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3964 | operator '?' ':' unoperator
3965 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3966 | operator MIN_MAX unoperator
3967 { $$ = frob_opname (ansi_opname ($2)); }
3968 | operator POINTSAT unoperator %prec EMPTY
3969 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3970 | operator POINTSAT_STAR unoperator %prec EMPTY
3971 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3972 | operator LEFT_RIGHT unoperator
3973 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3974 | operator '[' ']' unoperator
3975 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3976 | operator NEW unoperator %prec EMPTY
3977 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3978 | operator DELETE unoperator %prec EMPTY
3979 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3980 | operator NEW '[' ']' unoperator
3981 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3982 | operator DELETE '[' ']' unoperator
3983 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
3984 | operator type_specifier_seq conversion_declarator unoperator
3985 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
3986 | operator error unoperator
3987 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
3990 /* The forced readahead in here is because we might be at the end of a
3991 line, and lineno won't be bumped until yylex absorbs the first token
3992 on the next line. */
3993 save_lineno:
3994 { if (yychar == YYEMPTY)
3995 yychar = YYLEX;
3996 $$ = lineno; }
4000 #ifdef SPEW_DEBUG
4001 const char *
4002 debug_yytranslate (value)
4003 int value;
4005 return yytname[YYTRANSLATE (value)];
4007 #endif
4009 /* Free malloced parser stacks if necessary. */
4011 void
4012 free_parser_stacks ()
4014 if (malloced_yyss)
4016 free (malloced_yyss);
4017 free (malloced_yyvs);
4021 /* Return the value corresponding to TOKEN in the global scope. */
4023 static tree
4024 parse_scoped_id (token)
4025 tree token;
4027 tree id;
4029 id = make_node (CPLUS_BINDING);
4030 if (!qualified_lookup_using_namespace (token, global_namespace, id, 0))
4031 id = NULL_TREE;
4032 else
4033 id = BINDING_VALUE (id);
4034 if (yychar == YYEMPTY)
4035 yychar = yylex();
4037 return do_scoped_id (token, id);
4040 #include "gt-cp-parse.h"