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