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