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