Remove some compile time warnings about duplicate definitions.
[official-gcc.git] / gcc / cp / parse.y
blob449ea9830d0ccb9ed6dddcec365bb43f144016b7
1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
4 Hacked by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 /* This grammar is based on the GNU CC grammar. */
26 /* Note: Bison automatically applies a default action of "$$ = $1" for
27 all derivations; this is applied before the explicit action, if one
28 is given. Keep this in mind when reading the actions. */
31 /* Cause the `yydebug' variable to be defined. */
32 #define YYDEBUG 1
34 #include "config.h"
36 #include "system.h"
38 #include "tree.h"
39 #include "input.h"
40 #include "flags.h"
41 #include "cp-tree.h"
42 #include "lex.h"
43 #include "output.h"
44 #include "except.h"
45 #include "toplev.h"
46 #include "ggc.h"
48 extern struct obstack permanent_obstack;
50 /* Like YYERROR but do call yyerror. */
51 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
53 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
54 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
56 /* Contains the statement keyword (if/while/do) to include in an
57 error message if the user supplies an empty conditional expression. */
58 static const char *cond_stmt_keyword;
60 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
61 int have_extern_spec;
62 int used_extern_spec;
64 /* List of types and structure classes of the current declaration. */
65 static tree current_declspecs;
67 /* List of prefix attributes in effect.
68 Prefix attributes are parsed by the reserved_declspecs and declmods
69 rules. They create a list that contains *both* declspecs and attrs. */
70 /* ??? It is not clear yet that all cases where an attribute can now appear in
71 a declspec list have been updated. */
72 static tree prefix_attributes;
74 /* When defining an enumeration, this is the type of the enumeration. */
75 static tree current_enum_type;
77 /* When parsing a conversion operator name, this is the scope of the
78 operator itself. */
79 static tree saved_scopes;
81 static tree empty_parms PARAMS ((void));
82 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
83 static tree parse_decl PARAMS ((tree, tree, int));
84 static void parse_end_decl PARAMS ((tree, tree, tree));
85 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
86 static tree parse_field PARAMS ((tree, tree, tree, tree));
87 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
88 static tree parse_bitfield PARAMS ((tree, tree, tree));
89 static tree parse_method PARAMS ((tree, tree, tree));
90 static void frob_specs PARAMS ((tree, tree));
92 /* Cons up an empty parameter list. */
93 static inline tree
94 empty_parms ()
96 tree parms;
98 #ifndef NO_IMPLICIT_EXTERN_C
99 if (in_system_header && current_class_type == NULL
100 && current_lang_name == lang_name_c)
101 parms = NULL_TREE;
102 else
103 #endif
104 parms = void_list_node;
105 return parms;
108 /* Record the decl-specifiers, attributes and type lookups from the
109 decl-specifier-seq in a declaration. */
111 static void
112 frob_specs (specs_attrs, lookups)
113 tree specs_attrs, lookups;
115 save_type_access_control (lookups);
116 split_specs_attrs (specs_attrs, &current_declspecs, &prefix_attributes);
117 if (current_declspecs
118 && TREE_CODE (current_declspecs) != TREE_LIST)
119 current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
120 if (have_extern_spec && !used_extern_spec)
122 current_declspecs = tree_cons (NULL_TREE,
123 get_identifier ("extern"),
124 current_declspecs);
125 used_extern_spec = 1;
129 static tree
130 parse_decl (declarator, attributes, initialized)
131 tree declarator, attributes;
132 int initialized;
134 return start_decl (declarator, current_declspecs, initialized,
135 attributes, prefix_attributes);
138 static tree
139 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
140 tree declarator, specs_attrs, lookups, attributes;
141 int initialized;
143 frob_specs (specs_attrs, lookups);
144 return parse_decl (declarator, attributes, initialized);
147 static void
148 parse_end_decl (decl, init, asmspec)
149 tree decl, init, asmspec;
151 /* If decl is NULL_TREE, then this was a variable declaration using
152 () syntax for the initializer, so we handled it in grokdeclarator. */
153 if (decl)
154 decl_type_access_control (decl);
155 cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
158 static tree
159 parse_field (declarator, attributes, asmspec, init)
160 tree declarator, attributes, asmspec, init;
162 tree d = grokfield (declarator, current_declspecs, init, asmspec,
163 chainon (attributes, prefix_attributes));
164 decl_type_access_control (d);
165 return d;
168 static tree
169 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
170 tree declarator, specs_attrs, lookups, attributes, asmspec, init;
172 frob_specs (specs_attrs, lookups);
173 return parse_field (declarator, attributes, asmspec, init);
176 static tree
177 parse_bitfield (declarator, attributes, width)
178 tree declarator, attributes, width;
180 tree d = grokbitfield (declarator, current_declspecs, width);
181 cplus_decl_attributes (&d, chainon (attributes, prefix_attributes), 0);
182 decl_type_access_control (d);
183 return d;
186 static tree
187 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
188 tree declarator, specs_attrs, lookups, attributes, width;
190 frob_specs (specs_attrs, lookups);
191 return parse_bitfield (declarator, attributes, width);
194 static tree
195 parse_method (declarator, specs_attrs, lookups)
196 tree declarator, specs_attrs, lookups;
198 tree d;
199 frob_specs (specs_attrs, lookups);
200 d = start_method (current_declspecs, declarator, prefix_attributes);
201 decl_type_access_control (d);
202 return d;
205 void
206 cp_parse_init ()
208 ggc_add_tree_root (&current_declspecs, 1);
209 ggc_add_tree_root (&prefix_attributes, 1);
210 ggc_add_tree_root (&current_enum_type, 1);
211 ggc_add_tree_root (&saved_scopes, 1);
214 /* Rename the "yyparse" function so that we can override it elsewhere. */
215 #define yyparse yyparse_1
218 %start program
220 %union {
221 long itype;
222 tree ttype;
223 char *strtype;
224 enum tree_code code;
225 flagged_type_tree ftype;
226 struct unparsed_text *pi;
229 /* All identifiers that are not reserved words
230 and are not declared typedefs in the current block */
231 %token IDENTIFIER
233 /* All identifiers that are declared typedefs in the current block.
234 In some contexts, they are treated just like IDENTIFIER,
235 but they can also serve as typespecs in declarations. */
236 %token TYPENAME
237 %token SELFNAME
239 /* A template function. */
240 %token PFUNCNAME
242 /* Reserved words that specify storage class.
243 yylval contains an IDENTIFIER_NODE which indicates which one. */
244 %token SCSPEC
246 /* Reserved words that specify type.
247 yylval contains an IDENTIFIER_NODE which indicates which one. */
248 %token TYPESPEC
250 /* Reserved words that qualify type: "const" or "volatile".
251 yylval contains an IDENTIFIER_NODE which indicates which one. */
252 %token CV_QUALIFIER
254 /* Character or numeric constants.
255 yylval is the node for the constant. */
256 %token CONSTANT
258 /* __func__, __FUNCTION__ or __PRETTY_FUNCTION__.
259 yylval contains an IDENTIFIER_NODE which indicates which one. */
260 %token VAR_FUNC_NAME
262 /* String constants in raw form.
263 yylval is a STRING_CST node. */
264 %token STRING
266 /* "...", used for functions with variable arglists. */
267 %token ELLIPSIS
269 /* the reserved words */
270 /* SCO include files test "ASM", so use something else. */
271 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
272 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
273 %token SIGOF
274 %token ATTRIBUTE EXTENSION LABEL
275 %token REALPART IMAGPART VA_ARG
277 /* the reserved words... C++ extensions */
278 %token <ttype> AGGR
279 %token <ttype> VISSPEC
280 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
281 %token NAMESPACE TYPENAME_KEYWORD USING
282 %token LEFT_RIGHT TEMPLATE
283 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
284 %token SCOPE EXPORT
286 /* Define the operator tokens and their precedences.
287 The value is an integer because, if used, it is the tree code
288 to use in the expression made from the operator. */
290 %left EMPTY /* used to resolve s/r with epsilon */
292 %left error
294 /* Add precedence rules to solve dangling else s/r conflict */
295 %nonassoc IF
296 %nonassoc ELSE
298 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
300 %left '{' ',' ';'
302 %nonassoc THROW
303 %right <code> ':'
304 %right <code> ASSIGN '='
305 %right <code> '?'
306 %left <code> OROR
307 %left <code> ANDAND
308 %left <code> '|'
309 %left <code> '^'
310 %left <code> '&'
311 %left <code> MIN_MAX
312 %left <code> EQCOMPARE
313 %left <code> ARITHCOMPARE '<' '>'
314 %left <code> LSHIFT RSHIFT
315 %left <code> '+' '-'
316 %left <code> '*' '/' '%'
317 %left <code> POINTSAT_STAR DOT_STAR
318 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
319 %left HYPERUNARY
320 %left <ttype> LEFT_RIGHT
321 %left <code> POINTSAT '.' '(' '['
323 %right SCOPE /* C++ extension */
324 %nonassoc NEW DELETE TRY CATCH
326 %type <code> unop
328 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
329 %type <ttype> PFUNCNAME maybe_identifier
330 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
331 %type <ttype> expr_no_commas expr_no_comma_rangle
332 %type <ttype> cast_expr unary_expr primary string STRING
333 %type <ttype> reserved_declspecs boolean.literal
334 %type <ttype> reserved_typespecquals
335 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
336 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
337 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
338 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
339 %type <ttype> any_word
341 %type <itype> save_lineno
342 %type <ttype> simple_stmt simple_if
344 %type <ttype> declarator notype_declarator after_type_declarator
345 %type <ttype> notype_declarator_intern absdcl_intern
346 %type <ttype> after_type_declarator_intern
347 %type <ttype> direct_notype_declarator direct_after_type_declarator
348 %type <itype> components notype_components
349 %type <ttype> component_decl component_decl_1
350 %type <ttype> component_declarator component_declarator0
351 %type <ttype> notype_component_declarator notype_component_declarator0
352 %type <ttype> after_type_component_declarator after_type_component_declarator0
353 %type <ttype> absdcl cv_qualifiers
354 %type <ttype> direct_abstract_declarator conversion_declarator
355 %type <ttype> new_declarator direct_new_declarator
356 %type <ttype> xexpr parmlist parms bad_parm
357 %type <ttype> identifiers_or_typenames
358 %type <ttype> fcast_or_absdcl regcast_or_absdcl
359 %type <ttype> expr_or_declarator expr_or_declarator_intern
360 %type <ttype> complex_notype_declarator
361 %type <ttype> notype_unqualified_id unqualified_id qualified_id
362 %type <ttype> template_id do_id object_template_id notype_template_declarator
363 %type <ttype> overqualified_id notype_qualified_id any_id
364 %type <ttype> complex_direct_notype_declarator functional_cast
365 %type <ttype> complex_parmlist parms_comma
366 %type <ttype> namespace_qualifier namespace_using_decl
368 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
369 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
370 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
371 %type <ftype> declmods
373 %type <itype> extension
375 /* C++ extensions */
376 %token <ttype> PTYPENAME
377 %token <ttype> EXTERN_LANG_STRING ALL
378 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
379 %token <pi> PRE_PARSED_FUNCTION_DECL
380 %type <ttype> component_constructor_declarator
381 %type <ttype> fn.def2 return_id constructor_declarator
382 %type <itype> ctor_initializer_opt function_try_block
383 %type <ttype> named_class_head_sans_basetype
384 %type <ftype> class_head named_class_head
385 %type <ftype> named_complex_class_head_sans_basetype
386 %type <ttype> unnamed_class_head
387 %type <ttype> base_class_list
388 %type <ttype> base_class_access_list
389 %type <ttype> base_class maybe_base_class_list base_class.1
390 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
391 %type <ttype> operator_name
392 %type <ttype> object aggr
393 %type <itype> new delete
394 /* %type <ttype> primary_no_id */
395 %type <ttype> maybe_parmlist
396 %type <ttype> member_init
397 %type <ftype> member_init_list
398 %type <ttype> template_parm_header template_spec_header template_header
399 %type <ttype> template_parm_list template_parm
400 %type <ttype> template_type_parm template_template_parm
401 %type <code> template_close_bracket
402 %type <ttype> apparent_template_type
403 %type <ttype> template_type template_arg_list template_arg_list_opt
404 %type <ttype> template_arg
405 %type <ttype> condition xcond paren_cond_or_null
406 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
407 %type <ttype> complete_type_name notype_identifier nonnested_type
408 %type <ttype> complex_type_name nested_name_specifier_1
409 %type <ttype> new_initializer new_placement
410 %type <ttype> using_decl
411 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
412 %type <ttype> explicit_template_type
413 /* in order to recognize aggr tags as defining and thus shadowing. */
414 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
415 %type <ttype> named_class_head_sans_basetype_defn
416 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
417 %type <ttype> handler_args
418 %type <ttype> self_template_type .finish_template_type
420 %token NSNAME
421 %type <ttype> NSNAME
423 /* Used in lex.c for parsing pragmas. */
424 %token END_OF_LINE
426 /* lex.c and pt.c depend on this being the last token. Define
427 any new tokens before this one! */
428 %token END_OF_SAVED_INPUT
431 /* Tell yyparse how to print a token's value, if yydebug is set. */
432 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
433 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
437 program:
438 /* empty */
439 { finish_translation_unit (); }
440 | extdefs
441 { finish_translation_unit (); }
444 /* the reason for the strange actions in this rule
445 is so that notype_initdecls when reached via datadef
446 can find a valid list of type and sc specs in $0. */
448 extdefs:
449 { $<ttype>$ = NULL_TREE; }
450 lang_extdef
451 { $<ttype>$ = NULL_TREE; ggc_collect (); }
452 | extdefs lang_extdef
453 { $<ttype>$ = NULL_TREE; ggc_collect (); }
456 extdefs_opt:
457 extdefs
458 | /* empty */
461 .hush_warning:
462 { have_extern_spec = 1;
463 used_extern_spec = 0;
464 $<ttype>$ = NULL_TREE; }
466 .warning_ok:
467 { have_extern_spec = 0; }
470 extension:
471 EXTENSION
472 { $$ = pedantic;
473 pedantic = 0; }
476 asm_keyword:
477 ASM_KEYWORD
480 lang_extdef:
481 { if (pending_lang_change) do_pending_lang_change();
482 type_lookups = NULL_TREE; }
483 extdef
484 { if (! toplevel_bindings_p ())
485 pop_everything (); }
488 extdef:
489 fndef eat_saved_input
490 { do_pending_inlines (); }
491 | datadef
492 { do_pending_inlines (); }
494 | EXPORT
495 { cp_warning ("keyword `export' not implemented, and will be ignored"); }
496 template_def
497 { do_pending_inlines (); }
498 | template_def
499 { do_pending_inlines (); }
500 | asm_keyword '(' string ')' ';'
501 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
502 assemble_asm ($3); }
503 | extern_lang_string '{' extdefs_opt '}'
504 { pop_lang_context (); }
505 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
506 { do_pending_inlines (); pop_lang_context (); }
507 | extern_lang_string .hush_warning datadef .warning_ok
508 { do_pending_inlines (); pop_lang_context (); }
509 | NAMESPACE identifier '{'
510 { push_namespace ($2); }
511 extdefs_opt '}'
512 { pop_namespace (); }
513 | NAMESPACE '{'
514 { push_namespace (NULL_TREE); }
515 extdefs_opt '}'
516 { pop_namespace (); }
517 | namespace_alias
518 | using_decl ';'
519 { do_toplevel_using_decl ($1); }
520 | using_directive
521 | extension extdef
522 { pedantic = $1; }
525 namespace_alias:
526 NAMESPACE identifier '='
527 { begin_only_namespace_names (); }
528 any_id ';'
530 end_only_namespace_names ();
531 if (lastiddecl)
532 $5 = lastiddecl;
533 do_namespace_alias ($2, $5);
537 using_decl:
538 USING qualified_id
539 { $$ = $2; }
540 | USING global_scope qualified_id
541 { $$ = $3; }
542 | USING global_scope unqualified_id
543 { $$ = $3; }
546 namespace_using_decl:
547 USING namespace_qualifier identifier
548 { $$ = build_nt (SCOPE_REF, $2, $3); }
549 | USING global_scope identifier
550 { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
551 | USING global_scope namespace_qualifier identifier
552 { $$ = build_nt (SCOPE_REF, $3, $4); }
555 using_directive:
556 USING NAMESPACE
557 { begin_only_namespace_names (); }
558 any_id ';'
560 end_only_namespace_names ();
561 /* If no declaration was found, the using-directive is
562 invalid. Since that was not reported, we need the
563 identifier for the error message. */
564 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
565 $4 = lastiddecl;
566 do_using_directive ($4);
570 namespace_qualifier:
571 NSNAME SCOPE
573 if (TREE_CODE ($$) == IDENTIFIER_NODE)
574 $$ = lastiddecl;
575 got_scope = $$;
577 | namespace_qualifier NSNAME SCOPE
579 $$ = $2;
580 if (TREE_CODE ($$) == IDENTIFIER_NODE)
581 $$ = lastiddecl;
582 got_scope = $$;
585 any_id:
586 unqualified_id
587 | qualified_id
588 | global_scope qualified_id
589 { $$ = $2; }
590 | global_scope unqualified_id
591 { $$ = $2; }
594 extern_lang_string:
595 EXTERN_LANG_STRING
596 { push_lang_context ($1); }
597 | extern_lang_string EXTERN_LANG_STRING
598 { if (current_lang_name != $2)
599 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
600 pop_lang_context (); push_lang_context ($2); }
603 template_parm_header:
604 TEMPLATE '<'
605 { begin_template_parm_list (); }
606 template_parm_list '>'
607 { $$ = end_template_parm_list ($4); }
610 template_spec_header:
611 TEMPLATE '<' '>'
612 { begin_specialization();
613 $$ = NULL_TREE; }
616 template_header:
617 template_parm_header
618 | template_spec_header
621 template_parm_list:
622 template_parm
623 { $$ = process_template_parm (NULL_TREE, $1); }
624 | template_parm_list ',' template_parm
625 { $$ = process_template_parm ($1, $3); }
628 maybe_identifier:
629 identifier
630 { $$ = $1; }
631 | /* empty */
632 { $$ = NULL_TREE; }
634 template_type_parm:
635 aggr maybe_identifier
636 { $$ = finish_template_type_parm ($1, $2); }
637 | TYPENAME_KEYWORD maybe_identifier
638 { $$ = finish_template_type_parm (class_type_node, $2); }
641 template_template_parm:
642 template_parm_header aggr maybe_identifier
643 { $$ = finish_template_template_parm ($2, $3); }
646 template_parm:
647 /* The following rules introduce a new reduce/reduce
648 conflict on the ',' and '>' input tokens: they are valid
649 prefixes for a `structsp', which means they could match a
650 nameless parameter. See 14.6, paragraph 3.
651 By putting them before the `parm' rule, we get
652 their match before considering them nameless parameter
653 declarations. */
654 template_type_parm
655 { $$ = build_tree_list (NULL_TREE, $1); }
656 | template_type_parm '=' type_id
657 { $$ = build_tree_list (groktypename ($3.t), $1); }
658 | parm
659 { $$ = build_tree_list (NULL_TREE, $1.t); }
660 | parm '=' expr_no_comma_rangle
661 { $$ = build_tree_list ($3, $1.t); }
662 | template_template_parm
663 { $$ = build_tree_list (NULL_TREE, $1); }
664 | template_template_parm '=' template_arg
666 if (TREE_CODE ($3) != TEMPLATE_DECL
667 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
668 && TREE_CODE ($3) != TYPE_DECL
669 && TREE_CODE ($3) != UNBOUND_CLASS_TEMPLATE)
671 error ("invalid default template argument");
672 $3 = error_mark_node;
674 $$ = build_tree_list ($3, $1);
678 template_def:
679 template_header template_extdef
680 { finish_template_decl ($1); }
681 | template_header error %prec EMPTY
682 { finish_template_decl ($1); }
685 template_extdef:
686 fndef eat_saved_input
687 { do_pending_inlines (); }
688 | template_datadef
689 { do_pending_inlines (); }
690 | template_def
691 { do_pending_inlines (); }
692 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
693 { do_pending_inlines ();
694 pop_lang_context (); }
695 | extern_lang_string .hush_warning template_datadef .warning_ok
696 { do_pending_inlines ();
697 pop_lang_context (); }
698 | extension template_extdef
699 { pedantic = $1; }
702 template_datadef:
703 nomods_initdecls ';'
704 | declmods notype_initdecls ';'
706 | typed_declspecs initdecls ';'
707 { note_list_got_semicolon ($1.t); }
708 | structsp ';'
710 if ($1.t != error_mark_node)
712 maybe_process_partial_specialization ($1.t);
713 note_got_semicolon ($1.t);
718 datadef:
719 nomods_initdecls ';'
720 | declmods notype_initdecls ';'
722 | typed_declspecs initdecls ';'
723 { note_list_got_semicolon ($1.t); }
724 | declmods ';'
725 { pedwarn ("empty declaration"); }
726 | explicit_instantiation ';'
727 | typed_declspecs ';'
729 tree t, attrs;
730 split_specs_attrs ($1.t, &t, &attrs);
731 shadow_tag (t);
732 note_list_got_semicolon ($1.t);
734 | error ';'
735 | error '}'
736 | error END_OF_SAVED_INPUT
737 { end_input (); }
738 | ';'
739 | bad_decl
742 ctor_initializer_opt:
743 nodecls
744 { $$ = 0; }
745 | base_init
746 { $$ = 1; }
749 maybe_return_init:
750 /* empty */
751 | return_init
752 | return_init ';'
755 eat_saved_input:
756 /* empty */
757 | END_OF_SAVED_INPUT
760 fndef:
761 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
762 { expand_body (finish_function ((int)$3)); }
763 | fn.def1 maybe_return_init function_try_block
764 { expand_body (finish_function ((int)$3)); }
765 | fn.def1 maybe_return_init error
769 constructor_declarator:
770 nested_name_specifier SELFNAME '('
771 { $$ = begin_constructor_declarator ($1, $2); }
772 parmlist ')' cv_qualifiers exception_specification_opt
773 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
774 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
775 { $$ = begin_constructor_declarator ($1, $2);
776 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
778 | global_scope nested_name_specifier SELFNAME '('
779 { $$ = begin_constructor_declarator ($2, $3); }
780 parmlist ')' cv_qualifiers exception_specification_opt
781 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
782 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
783 { $$ = begin_constructor_declarator ($2, $3);
784 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
786 | nested_name_specifier self_template_type '('
787 { $$ = begin_constructor_declarator ($1, $2); }
788 parmlist ')' cv_qualifiers exception_specification_opt
789 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
790 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
791 { $$ = begin_constructor_declarator ($1, $2);
792 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
794 | global_scope nested_name_specifier self_template_type '('
795 { $$ = begin_constructor_declarator ($2, $3); }
796 parmlist ')' cv_qualifiers exception_specification_opt
797 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
798 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
799 { $$ = begin_constructor_declarator ($2, $3);
800 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
804 fn.def1:
805 typed_declspecs declarator
806 { check_for_new_type ("return type", $1);
807 if (!begin_function_definition ($1.t, $2))
808 YYERROR1; }
809 | declmods notype_declarator
810 { if (!begin_function_definition ($1.t, $2))
811 YYERROR1; }
812 | notype_declarator
813 { if (!begin_function_definition (NULL_TREE, $1))
814 YYERROR1; }
815 | declmods constructor_declarator
816 { if (!begin_function_definition ($1.t, $2))
817 YYERROR1; }
818 | constructor_declarator
819 { if (!begin_function_definition (NULL_TREE, $1))
820 YYERROR1; }
823 /* ANSI allows optional parentheses around constructor class names.
824 See ISO/IEC 14882:1998(E) 12.1. */
826 component_constructor_declarator:
827 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
828 { $$ = make_call_declarator ($1, $3, $5, $6); }
829 | '(' SELFNAME ')' '(' parmlist ')' cv_qualifiers
830 exception_specification_opt
831 { $$ = make_call_declarator ($2, $5, $7, $8); }
832 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
833 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
834 | '(' SELFNAME ')' LEFT_RIGHT cv_qualifiers exception_specification_opt
835 { $$ = make_call_declarator ($2, empty_parms (), $5, $6); }
836 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
837 { $$ = make_call_declarator ($1, $3, $5, $6); }
838 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
839 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
842 /* more C++ complexity. See component_decl for a comment on the
843 reduce/reduce conflict introduced by these rules. */
844 fn.def2:
845 declmods component_constructor_declarator
846 { $$ = parse_method ($2, $1.t, $1.lookups);
847 rest_of_mdef:
848 if (! $$)
849 YYERROR1;
850 if (yychar == YYEMPTY)
851 yychar = YYLEX;
852 snarf_method ($$); }
853 | component_constructor_declarator
854 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
855 goto rest_of_mdef; }
856 | typed_declspecs declarator
857 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
858 | declmods notype_declarator
859 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
860 | notype_declarator
861 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
862 goto rest_of_mdef; }
863 | declmods constructor_declarator
864 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
865 | constructor_declarator
866 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
867 goto rest_of_mdef; }
870 return_id:
871 RETURN_KEYWORD IDENTIFIER
873 $$ = $2;
877 return_init:
878 return_id maybe_init
879 { finish_named_return_value ($<ttype>$, $2); }
880 | return_id '(' nonnull_exprlist ')'
881 { finish_named_return_value ($<ttype>$, $3); }
882 | return_id LEFT_RIGHT
883 { finish_named_return_value ($<ttype>$, NULL_TREE); }
886 base_init:
887 ':' .set_base_init member_init_list
889 if ($3.new_type_flag == 0)
890 error ("no base or member initializers given following ':'");
892 finish_mem_initializers ($3.t);
896 .set_base_init:
897 /* empty */
899 if (DECL_CONSTRUCTOR_P (current_function_decl))
900 /* Make a contour for the initializer list. */
901 do_pushlevel ();
902 else if (current_class_type == NULL_TREE)
903 error ("base initializers not allowed for non-member functions");
904 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
905 error ("only constructors take base initializers");
909 member_init_list:
910 /* empty */
912 $$.new_type_flag = 0;
913 $$.t = NULL_TREE;
915 | member_init
917 $$.new_type_flag = 1;
918 $$.t = $1;
920 | member_init_list ',' member_init
922 if ($3)
924 $$.new_type_flag = 1;
925 TREE_CHAIN ($3) = $1.t;
926 $$.t = $3;
928 else
929 $$ = $1;
931 | member_init_list error
934 member_init:
935 '(' nonnull_exprlist ')'
937 if (current_class_name)
938 pedwarn ("anachronistic old style base class initializer");
939 $$ = expand_member_init (current_class_ref, NULL_TREE, $2);
941 | LEFT_RIGHT
943 if (current_class_name)
944 pedwarn ("anachronistic old style base class initializer");
945 $$ = expand_member_init (current_class_ref,
946 NULL_TREE,
947 void_type_node);
949 | notype_identifier '(' nonnull_exprlist ')'
950 { $$ = expand_member_init (current_class_ref, $1, $3); }
951 | notype_identifier LEFT_RIGHT
952 { $$ = expand_member_init (current_class_ref, $1,
953 void_type_node); }
954 | nonnested_type '(' nonnull_exprlist ')'
955 { $$ = expand_member_init (current_class_ref, $1, $3); }
956 | nonnested_type LEFT_RIGHT
957 { $$ = expand_member_init (current_class_ref, $1,
958 void_type_node); }
959 | typename_sub '(' nonnull_exprlist ')'
960 { $$ = expand_member_init (current_class_ref, $1, $3); }
961 | typename_sub LEFT_RIGHT
962 { $$ = expand_member_init (current_class_ref, $1,
963 void_type_node); }
964 | error
965 { $$ = NULL_TREE; }
968 identifier:
969 IDENTIFIER
970 | TYPENAME
971 | SELFNAME
972 | PTYPENAME
973 | NSNAME
976 notype_identifier:
977 IDENTIFIER
978 | PTYPENAME
979 | NSNAME %prec EMPTY
982 identifier_defn:
983 IDENTIFIER_DEFN
984 | TYPENAME_DEFN
985 | PTYPENAME_DEFN
988 explicit_instantiation:
989 TEMPLATE begin_explicit_instantiation typespec ';'
990 { do_type_instantiation ($3.t, NULL_TREE, 1);
991 yyungetc (';', 1); }
992 end_explicit_instantiation
993 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
994 { tree specs = strip_attrs ($3.t);
995 do_decl_instantiation (specs, $4, NULL_TREE); }
996 end_explicit_instantiation
997 | TEMPLATE begin_explicit_instantiation notype_declarator
998 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
999 end_explicit_instantiation
1000 | TEMPLATE begin_explicit_instantiation constructor_declarator
1001 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1002 end_explicit_instantiation
1003 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
1004 { do_type_instantiation ($4.t, $1, 1);
1005 yyungetc (';', 1); }
1006 end_explicit_instantiation
1007 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
1008 declarator
1009 { tree specs = strip_attrs ($4.t);
1010 do_decl_instantiation (specs, $5, $1); }
1011 end_explicit_instantiation
1012 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
1013 { do_decl_instantiation (NULL_TREE, $4, $1); }
1014 end_explicit_instantiation
1015 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
1016 { do_decl_instantiation (NULL_TREE, $4, $1); }
1017 end_explicit_instantiation
1020 begin_explicit_instantiation:
1021 { begin_explicit_instantiation(); }
1023 end_explicit_instantiation:
1024 { end_explicit_instantiation(); }
1026 /* The TYPENAME expansions are to deal with use of a template class name as
1027 a template within the class itself, where the template decl is hidden by
1028 a type decl. Got all that? */
1030 template_type:
1031 PTYPENAME '<' template_arg_list_opt template_close_bracket
1032 .finish_template_type
1033 { $$ = $5; }
1034 | TYPENAME '<' template_arg_list_opt template_close_bracket
1035 .finish_template_type
1036 { $$ = $5; }
1037 | self_template_type
1040 apparent_template_type:
1041 template_type
1042 | identifier '<' template_arg_list_opt '>'
1043 .finish_template_type
1044 { $$ = $5; }
1046 self_template_type:
1047 SELFNAME '<' template_arg_list_opt template_close_bracket
1048 .finish_template_type
1049 { $$ = $5; }
1052 .finish_template_type:
1054 if (yychar == YYEMPTY)
1055 yychar = YYLEX;
1057 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1058 yychar == SCOPE);
1061 template_close_bracket:
1063 | RSHIFT
1065 /* Handle `Class<Class<Type>>' without space in the `>>' */
1066 pedwarn ("`>>' should be `> >' in template class name");
1067 yyungetc ('>', 1);
1071 template_arg_list_opt:
1072 /* empty */
1073 { $$ = NULL_TREE; }
1074 | template_arg_list
1077 template_arg_list:
1078 template_arg
1079 { $$ = build_tree_list (NULL_TREE, $$); }
1080 | template_arg_list ',' template_arg
1081 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1084 template_arg:
1085 type_id
1086 { $$ = groktypename ($1.t); }
1087 | PTYPENAME
1089 $$ = lastiddecl;
1090 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1091 $$ = TREE_TYPE ($$);
1093 | global_scope PTYPENAME
1095 $$ = lastiddecl;
1096 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1097 $$ = TREE_TYPE ($$);
1099 | expr_no_comma_rangle
1100 | nested_name_specifier TEMPLATE identifier
1102 if (!processing_template_decl)
1104 cp_error ("use of template qualifier outside template");
1105 $$ = error_mark_node;
1107 else
1108 $$ = make_unbound_class_template ($1, $3, 1);
1112 unop:
1114 { $$ = NEGATE_EXPR; }
1115 | '+'
1116 { $$ = CONVERT_EXPR; }
1117 | PLUSPLUS
1118 { $$ = PREINCREMENT_EXPR; }
1119 | MINUSMINUS
1120 { $$ = PREDECREMENT_EXPR; }
1121 | '!'
1122 { $$ = TRUTH_NOT_EXPR; }
1125 expr:
1126 nontrivial_exprlist
1127 { $$ = build_x_compound_expr ($$); }
1128 | expr_no_commas
1131 paren_expr_or_null:
1132 LEFT_RIGHT
1133 { error ("ISO C++ forbids an empty condition for `%s'",
1134 cond_stmt_keyword);
1135 $$ = integer_zero_node; }
1136 | '(' expr ')'
1137 { $$ = $2; }
1140 paren_cond_or_null:
1141 LEFT_RIGHT
1142 { error ("ISO C++ forbids an empty condition for `%s'",
1143 cond_stmt_keyword);
1144 $$ = integer_zero_node; }
1145 | '(' condition ')'
1146 { $$ = $2; }
1149 xcond:
1150 /* empty */
1151 { $$ = NULL_TREE; }
1152 | condition
1153 | error
1154 { $$ = NULL_TREE; }
1157 condition:
1158 type_specifier_seq declarator maybeasm maybe_attribute '='
1160 tree d;
1161 for (d = getdecls (); d; d = TREE_CHAIN (d))
1162 if (TREE_CODE (d) == TYPE_DECL) {
1163 tree s = TREE_TYPE (d);
1164 if (TREE_CODE (s) == RECORD_TYPE)
1165 cp_error ("definition of class `%T' in condition", s);
1166 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1167 cp_error ("definition of enum `%T' in condition", s);
1170 current_declspecs = $1.t;
1171 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1173 init
1175 parse_end_decl ($<ttype>6, $7, $4);
1176 $$ = convert_from_reference ($<ttype>6);
1177 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1178 cp_error ("definition of array `%#D' in condition", $$);
1180 | expr
1183 compstmtend:
1185 | maybe_label_decls stmts '}'
1186 | maybe_label_decls stmts error '}'
1187 | maybe_label_decls error '}'
1190 nontrivial_exprlist:
1191 expr_no_commas ',' expr_no_commas
1192 { $$ = tree_cons (NULL_TREE, $$,
1193 build_tree_list (NULL_TREE, $3)); }
1194 | expr_no_commas ',' error
1195 { $$ = tree_cons (NULL_TREE, $$,
1196 build_tree_list (NULL_TREE, error_mark_node)); }
1197 | nontrivial_exprlist ',' expr_no_commas
1198 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1199 | nontrivial_exprlist ',' error
1200 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1203 nonnull_exprlist:
1204 expr_no_commas
1205 { $$ = build_tree_list (NULL_TREE, $$); }
1206 | nontrivial_exprlist
1209 unary_expr:
1210 primary %prec UNARY
1211 { $$ = $1; }
1212 /* __extension__ turns off -pedantic for following primary. */
1213 | extension cast_expr %prec UNARY
1214 { $$ = $2;
1215 pedantic = $1; }
1216 | '*' cast_expr %prec UNARY
1217 { $$ = build_x_indirect_ref ($2, "unary *"); }
1218 | '&' cast_expr %prec UNARY
1219 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1220 | '~' cast_expr
1221 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1222 | unop cast_expr %prec UNARY
1223 { $$ = finish_unary_op_expr ($1, $2); }
1224 /* Refer to the address of a label as a pointer. */
1225 | ANDAND identifier
1226 { $$ = finish_label_address_expr ($2); }
1227 | SIZEOF unary_expr %prec UNARY
1228 { $$ = finish_sizeof ($2); }
1229 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1230 { $$ = finish_sizeof (groktypename ($3.t));
1231 check_for_new_type ("sizeof", $3); }
1232 | ALIGNOF unary_expr %prec UNARY
1233 { $$ = finish_alignof ($2); }
1234 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1235 { $$ = finish_alignof (groktypename ($3.t));
1236 check_for_new_type ("alignof", $3); }
1238 /* The %prec EMPTY's here are required by the = init initializer
1239 syntax extension; see below. */
1240 | new new_type_id %prec EMPTY
1241 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1242 check_for_new_type ("new", $2); }
1243 | new new_type_id new_initializer
1244 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1245 check_for_new_type ("new", $2); }
1246 | new new_placement new_type_id %prec EMPTY
1247 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1248 check_for_new_type ("new", $3); }
1249 | new new_placement new_type_id new_initializer
1250 { $$ = build_new ($2, $3.t, $4, $1);
1251 check_for_new_type ("new", $3); }
1252 | new '(' type_id ')'
1253 %prec EMPTY
1254 { $$ = build_new (NULL_TREE, groktypename($3.t),
1255 NULL_TREE, $1);
1256 check_for_new_type ("new", $3); }
1257 | new '(' type_id ')' new_initializer
1258 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1259 check_for_new_type ("new", $3); }
1260 | new new_placement '(' type_id ')' %prec EMPTY
1261 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1262 check_for_new_type ("new", $4); }
1263 | new new_placement '(' type_id ')' new_initializer
1264 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1265 check_for_new_type ("new", $4); }
1267 | delete cast_expr %prec UNARY
1268 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1269 | delete '[' ']' cast_expr %prec UNARY
1270 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1271 if (yychar == YYEMPTY)
1272 yychar = YYLEX; }
1273 | delete '[' expr ']' cast_expr %prec UNARY
1274 { $$ = delete_sanity ($5, $3, 2, $1);
1275 if (yychar == YYEMPTY)
1276 yychar = YYLEX; }
1277 | REALPART cast_expr %prec UNARY
1278 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1279 | IMAGPART cast_expr %prec UNARY
1280 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1283 new_placement:
1284 '(' nonnull_exprlist ')'
1285 { $$ = $2; }
1286 | '{' nonnull_exprlist '}'
1287 { cp_pedwarn ("old style placement syntax, use () instead");
1288 $$ = $2; }
1291 new_initializer:
1292 '(' nonnull_exprlist ')'
1293 { $$ = $2; }
1294 | LEFT_RIGHT
1295 { $$ = void_zero_node; }
1296 | '(' typespec ')'
1298 cp_error ("`%T' is not a valid expression", $2.t);
1299 $$ = error_mark_node;
1301 /* GNU extension so people can use initializer lists. Note that
1302 this alters the meaning of `new int = 1', which was previously
1303 syntactically valid but semantically invalid.
1304 This feature is now deprecated and will be removed in a future
1305 release. */
1306 | '=' init
1308 if (pedantic)
1309 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1310 cp_deprecated ("new initializer lists extension");
1311 if (TREE_CODE ($2) != TREE_LIST
1312 && TREE_CODE ($2) != CONSTRUCTOR)
1313 $$ = build_tree_list (NULL_TREE, $2);
1314 else
1315 $$ = $2;
1319 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1320 regcast_or_absdcl:
1321 '(' type_id ')' %prec EMPTY
1322 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1323 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1324 check_for_new_type ("cast", $2); }
1325 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1326 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1327 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1328 check_for_new_type ("cast", $3); }
1331 cast_expr:
1332 unary_expr
1333 | regcast_or_absdcl unary_expr %prec UNARY
1334 { $$ = reparse_absdcl_as_casts ($$, $2); }
1335 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1337 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1338 nreverse ($3));
1339 if (pedantic)
1340 pedwarn ("ISO C++ forbids compound literals");
1341 /* Indicate that this was a C99 compound literal. */
1342 TREE_HAS_CONSTRUCTOR (init) = 1;
1344 $$ = reparse_absdcl_as_casts ($$, init);
1348 expr_no_commas:
1349 cast_expr
1350 /* Handle general members. */
1351 | expr_no_commas POINTSAT_STAR expr_no_commas
1352 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1353 | expr_no_commas DOT_STAR expr_no_commas
1354 { $$ = build_m_component_ref ($$, $3); }
1355 | expr_no_commas '+' expr_no_commas
1356 { $$ = build_x_binary_op ($2, $$, $3); }
1357 | expr_no_commas '-' expr_no_commas
1358 { $$ = build_x_binary_op ($2, $$, $3); }
1359 | expr_no_commas '*' expr_no_commas
1360 { $$ = build_x_binary_op ($2, $$, $3); }
1361 | expr_no_commas '/' expr_no_commas
1362 { $$ = build_x_binary_op ($2, $$, $3); }
1363 | expr_no_commas '%' expr_no_commas
1364 { $$ = build_x_binary_op ($2, $$, $3); }
1365 | expr_no_commas LSHIFT expr_no_commas
1366 { $$ = build_x_binary_op ($2, $$, $3); }
1367 | expr_no_commas RSHIFT expr_no_commas
1368 { $$ = build_x_binary_op ($2, $$, $3); }
1369 | expr_no_commas ARITHCOMPARE expr_no_commas
1370 { $$ = build_x_binary_op ($2, $$, $3); }
1371 | expr_no_commas '<' expr_no_commas
1372 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1373 | expr_no_commas '>' expr_no_commas
1374 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1375 | expr_no_commas EQCOMPARE expr_no_commas
1376 { $$ = build_x_binary_op ($2, $$, $3); }
1377 | expr_no_commas MIN_MAX expr_no_commas
1378 { $$ = build_x_binary_op ($2, $$, $3); }
1379 | expr_no_commas '&' expr_no_commas
1380 { $$ = build_x_binary_op ($2, $$, $3); }
1381 | expr_no_commas '|' expr_no_commas
1382 { $$ = build_x_binary_op ($2, $$, $3); }
1383 | expr_no_commas '^' expr_no_commas
1384 { $$ = build_x_binary_op ($2, $$, $3); }
1385 | expr_no_commas ANDAND expr_no_commas
1386 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1387 | expr_no_commas OROR expr_no_commas
1388 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1389 | expr_no_commas '?' xexpr ':' expr_no_commas
1390 { $$ = build_x_conditional_expr ($$, $3, $5); }
1391 | expr_no_commas '=' expr_no_commas
1392 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1393 if ($$ != error_mark_node)
1394 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1395 | expr_no_commas ASSIGN expr_no_commas
1396 { $$ = build_x_modify_expr ($$, $2, $3); }
1397 | THROW
1398 { $$ = build_throw (NULL_TREE); }
1399 | THROW expr_no_commas
1400 { $$ = build_throw ($2); }
1403 expr_no_comma_rangle:
1404 cast_expr
1405 /* Handle general members. */
1406 | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1407 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1408 | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1409 { $$ = build_m_component_ref ($$, $3); }
1410 | expr_no_comma_rangle '+' expr_no_comma_rangle
1411 { $$ = build_x_binary_op ($2, $$, $3); }
1412 | expr_no_comma_rangle '-' expr_no_comma_rangle
1413 { $$ = build_x_binary_op ($2, $$, $3); }
1414 | expr_no_comma_rangle '*' expr_no_comma_rangle
1415 { $$ = build_x_binary_op ($2, $$, $3); }
1416 | expr_no_comma_rangle '/' expr_no_comma_rangle
1417 { $$ = build_x_binary_op ($2, $$, $3); }
1418 | expr_no_comma_rangle '%' expr_no_comma_rangle
1419 { $$ = build_x_binary_op ($2, $$, $3); }
1420 | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1421 { $$ = build_x_binary_op ($2, $$, $3); }
1422 | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1423 { $$ = build_x_binary_op ($2, $$, $3); }
1424 | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
1425 { $$ = build_x_binary_op ($2, $$, $3); }
1426 | expr_no_comma_rangle '<' expr_no_comma_rangle
1427 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1428 | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1429 { $$ = build_x_binary_op ($2, $$, $3); }
1430 | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1431 { $$ = build_x_binary_op ($2, $$, $3); }
1432 | expr_no_comma_rangle '&' expr_no_comma_rangle
1433 { $$ = build_x_binary_op ($2, $$, $3); }
1434 | expr_no_comma_rangle '|' expr_no_comma_rangle
1435 { $$ = build_x_binary_op ($2, $$, $3); }
1436 | expr_no_comma_rangle '^' expr_no_comma_rangle
1437 { $$ = build_x_binary_op ($2, $$, $3); }
1438 | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1439 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1440 | expr_no_comma_rangle OROR expr_no_comma_rangle
1441 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1442 | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1443 { $$ = build_x_conditional_expr ($$, $3, $5); }
1444 | expr_no_comma_rangle '=' expr_no_comma_rangle
1445 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1446 if ($$ != error_mark_node)
1447 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1448 | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1449 { $$ = build_x_modify_expr ($$, $2, $3); }
1450 | THROW
1451 { $$ = build_throw (NULL_TREE); }
1452 | THROW expr_no_comma_rangle
1453 { $$ = build_throw ($2); }
1456 notype_unqualified_id:
1457 '~' see_typename identifier
1458 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1459 | '~' see_typename template_type
1460 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1461 | template_id
1462 | operator_name
1463 | IDENTIFIER
1464 | PTYPENAME
1465 | NSNAME %prec EMPTY
1468 do_id:
1470 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1471 means that we're in an expression like S::f<int>, so
1472 don't do_identifier; we only do that for unqualified
1473 identifiers. */
1474 if (!lastiddecl || TREE_CODE (lastiddecl) != TREE_LIST)
1475 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1476 else
1477 $$ = $<ttype>-1;
1480 template_id:
1481 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1482 { $$ = lookup_template_function ($3, $4); }
1483 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1484 { $$ = lookup_template_function ($3, $4); }
1487 object_template_id:
1488 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1489 { $$ = lookup_template_function ($2, $4); }
1490 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1491 { $$ = lookup_template_function ($2, $4); }
1492 | TEMPLATE operator_name '<' template_arg_list_opt
1493 template_close_bracket
1494 { $$ = lookup_template_function ($2, $4); }
1497 unqualified_id:
1498 notype_unqualified_id
1499 | TYPENAME
1500 | SELFNAME
1503 expr_or_declarator_intern:
1504 expr_or_declarator
1505 | attributes expr_or_declarator
1507 /* Provide support for '(' attributes '*' declarator ')'
1508 etc */
1509 $$ = tree_cons ($1, $2, NULL_TREE);
1513 expr_or_declarator:
1514 notype_unqualified_id
1515 | '*' expr_or_declarator_intern %prec UNARY
1516 { $$ = build_nt (INDIRECT_REF, $2); }
1517 | '&' expr_or_declarator_intern %prec UNARY
1518 { $$ = build_nt (ADDR_EXPR, $2); }
1519 | '(' expr_or_declarator_intern ')'
1520 { $$ = $2; }
1523 notype_template_declarator:
1524 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1525 { $$ = lookup_template_function ($1, $3); }
1526 | NSNAME '<' template_arg_list template_close_bracket
1527 { $$ = lookup_template_function ($1, $3); }
1530 direct_notype_declarator:
1531 complex_direct_notype_declarator
1532 /* This precedence declaration is to prefer this reduce
1533 to the Koenig lookup shift in primary, below. I hate yacc. */
1534 | notype_unqualified_id %prec '('
1535 | notype_template_declarator
1536 | '(' expr_or_declarator_intern ')'
1537 { $$ = finish_decl_parsing ($2); }
1540 primary:
1541 notype_unqualified_id
1543 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1544 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1545 else
1546 $$ = finish_id_expr ($1);
1548 | CONSTANT
1549 | boolean.literal
1550 | string
1552 $$ = combine_strings ($$);
1553 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1554 a const array the way we want, so fix it. */
1555 if (flag_const_strings)
1556 TREE_TYPE ($$) = build_cplus_array_type
1557 (TREE_TYPE (TREE_TYPE ($$)),
1558 TYPE_DOMAIN (TREE_TYPE ($$)));
1560 | VAR_FUNC_NAME
1562 $$ = fname_decl (C_RID_CODE ($$), $$);
1563 if (processing_template_decl)
1564 $$ = build_min_nt (LOOKUP_EXPR, DECL_NAME ($$));
1566 | '(' expr ')'
1567 { $$ = finish_parenthesized_expr ($2); }
1568 | '(' expr_or_declarator_intern ')'
1569 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1570 $$ = finish_parenthesized_expr ($2); }
1571 | '(' error ')'
1572 { $$ = error_mark_node; }
1573 | '('
1574 { tree scope = current_scope ();
1575 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1577 error ("braced-group within expression allowed only inside a function");
1578 YYERROR;
1580 if (pedantic)
1581 pedwarn ("ISO C++ forbids braced-groups within expressions");
1582 $<ttype>$ = begin_stmt_expr ();
1584 compstmt ')'
1585 { $$ = finish_stmt_expr ($<ttype>2); }
1586 /* Koenig lookup support
1587 We could store lastiddecl in $1 to avoid another lookup,
1588 but that would result in many additional reduce/reduce conflicts. */
1589 | notype_unqualified_id '(' nonnull_exprlist ')'
1590 { $$ = finish_call_expr ($1, $3, 1); }
1591 | notype_unqualified_id LEFT_RIGHT
1592 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1593 | primary '(' nonnull_exprlist ')'
1594 { $$ = finish_call_expr ($1, $3, 0); }
1595 | primary LEFT_RIGHT
1596 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1597 | VA_ARG '(' expr_no_commas ',' type_id ')'
1598 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1599 check_for_new_type ("__builtin_va_arg", $5); }
1600 | primary '[' expr ']'
1601 { $$ = grok_array_decl ($$, $3); }
1602 | primary PLUSPLUS
1603 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1604 | primary MINUSMINUS
1605 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1606 /* C++ extensions */
1607 | THIS
1608 { $$ = finish_this_expr (); }
1609 | CV_QUALIFIER '(' nonnull_exprlist ')'
1611 /* This is a C cast in C++'s `functional' notation
1612 using the "implicit int" extension so that:
1613 `const (3)' is equivalent to `const int (3)'. */
1614 tree type;
1616 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1617 type = groktypename (build_tree_list (type, NULL_TREE));
1618 $$ = build_functional_cast (type, $3);
1620 | functional_cast
1621 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1622 { tree type = groktypename ($3.t);
1623 check_for_new_type ("dynamic_cast", $3);
1624 $$ = build_dynamic_cast (type, $6); }
1625 | STATIC_CAST '<' type_id '>' '(' expr ')'
1626 { tree type = groktypename ($3.t);
1627 check_for_new_type ("static_cast", $3);
1628 $$ = build_static_cast (type, $6); }
1629 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1630 { tree type = groktypename ($3.t);
1631 check_for_new_type ("reinterpret_cast", $3);
1632 $$ = build_reinterpret_cast (type, $6); }
1633 | CONST_CAST '<' type_id '>' '(' expr ')'
1634 { tree type = groktypename ($3.t);
1635 check_for_new_type ("const_cast", $3);
1636 $$ = build_const_cast (type, $6); }
1637 | TYPEID '(' expr ')'
1638 { $$ = build_typeid ($3); }
1639 | TYPEID '(' type_id ')'
1640 { tree type = groktypename ($3.t);
1641 check_for_new_type ("typeid", $3);
1642 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1643 | global_scope IDENTIFIER
1644 { $$ = do_scoped_id ($2, 1); }
1645 | global_scope template_id
1646 { $$ = $2; }
1647 | global_scope operator_name
1649 got_scope = NULL_TREE;
1650 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1651 $$ = do_scoped_id ($2, 1);
1652 else
1653 $$ = $2;
1655 | overqualified_id %prec HYPERUNARY
1656 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1657 | overqualified_id '(' nonnull_exprlist ')'
1658 { $$ = finish_qualified_call_expr ($1, $3); }
1659 | overqualified_id LEFT_RIGHT
1660 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1661 | object object_template_id %prec UNARY
1663 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1665 | object object_template_id '(' nonnull_exprlist ')'
1666 { $$ = finish_object_call_expr ($2, $1, $4); }
1667 | object object_template_id LEFT_RIGHT
1668 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1669 | object unqualified_id %prec UNARY
1670 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1671 | object overqualified_id %prec UNARY
1672 { if (processing_template_decl)
1673 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1674 else
1675 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1676 | object unqualified_id '(' nonnull_exprlist ')'
1677 { $$ = finish_object_call_expr ($2, $1, $4); }
1678 | object unqualified_id LEFT_RIGHT
1679 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1680 | object overqualified_id '(' nonnull_exprlist ')'
1681 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1682 | object overqualified_id LEFT_RIGHT
1683 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1684 /* p->int::~int() is valid -- 12.4 */
1685 | object '~' TYPESPEC LEFT_RIGHT
1686 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1687 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1688 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1689 | object error
1691 $$ = error_mark_node;
1695 /* Not needed for now.
1697 primary_no_id:
1698 '(' expr ')'
1699 { $$ = $2; }
1700 | '(' error ')'
1701 { $$ = error_mark_node; }
1702 | '('
1703 { if (current_function_decl == 0)
1705 error ("braced-group within expression allowed only inside a function");
1706 YYERROR;
1708 $<ttype>$ = expand_start_stmt_expr (); }
1709 compstmt ')'
1710 { if (pedantic)
1711 pedwarn ("ISO C++ forbids braced-groups within expressions");
1712 $$ = expand_end_stmt_expr ($<ttype>2); }
1713 | primary_no_id '(' nonnull_exprlist ')'
1714 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1715 | primary_no_id LEFT_RIGHT
1716 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1717 | primary_no_id '[' expr ']'
1718 { goto do_array; }
1719 | primary_no_id PLUSPLUS
1720 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1721 | primary_no_id MINUSMINUS
1722 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1723 | SCOPE IDENTIFIER
1724 { goto do_scoped_id; }
1725 | SCOPE operator_name
1726 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1727 goto do_scoped_id;
1728 goto do_scoped_operator;
1733 new:
1735 { $$ = 0; }
1736 | global_scope NEW
1737 { got_scope = NULL_TREE; $$ = 1; }
1740 delete:
1741 DELETE
1742 { $$ = 0; }
1743 | global_scope delete
1744 { got_scope = NULL_TREE; $$ = 1; }
1747 boolean.literal:
1748 CXX_TRUE
1749 { $$ = boolean_true_node; }
1750 | CXX_FALSE
1751 { $$ = boolean_false_node; }
1754 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1755 string:
1756 STRING
1757 | string STRING
1758 { $$ = chainon ($$, $2); }
1761 nodecls:
1762 /* empty */
1764 setup_vtbl_ptr (NULL_TREE, NULL_TREE);
1768 object:
1769 primary '.'
1770 { got_object = TREE_TYPE ($$); }
1771 | primary POINTSAT
1773 $$ = build_x_arrow ($$);
1774 got_object = TREE_TYPE ($$);
1778 decl:
1779 typespec initdecls ';'
1781 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1782 note_got_semicolon ($1.t);
1784 | typed_declspecs initdecls ';'
1786 note_list_got_semicolon ($1.t);
1788 | declmods notype_initdecls ';'
1790 | typed_declspecs ';'
1792 shadow_tag ($1.t);
1793 note_list_got_semicolon ($1.t);
1795 | declmods ';'
1796 { warning ("empty declaration"); }
1797 | extension decl
1798 { pedantic = $1; }
1801 /* Any kind of declarator (thus, all declarators allowed
1802 after an explicit typespec). */
1804 declarator:
1805 after_type_declarator %prec EMPTY
1806 | notype_declarator %prec EMPTY
1809 /* This is necessary to postpone reduction of `int()()()()'. */
1810 fcast_or_absdcl:
1811 LEFT_RIGHT %prec EMPTY
1812 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1813 NULL_TREE, NULL_TREE); }
1814 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1815 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1816 NULL_TREE); }
1819 /* ISO type-id (8.1) */
1820 type_id:
1821 typed_typespecs absdcl
1822 { $$.t = build_tree_list ($1.t, $2);
1823 $$.new_type_flag = $1.new_type_flag; }
1824 | nonempty_cv_qualifiers absdcl
1825 { $$.t = build_tree_list ($1.t, $2);
1826 $$.new_type_flag = $1.new_type_flag; }
1827 | typespec absdcl
1828 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1829 $2);
1830 $$.new_type_flag = $1.new_type_flag; }
1831 | typed_typespecs %prec EMPTY
1832 { $$.t = build_tree_list ($1.t, NULL_TREE);
1833 $$.new_type_flag = $1.new_type_flag; }
1834 | nonempty_cv_qualifiers %prec EMPTY
1835 { $$.t = build_tree_list ($1.t, NULL_TREE);
1836 $$.new_type_flag = $1.new_type_flag; }
1839 /* Declspecs which contain at least one type specifier or typedef name.
1840 (Just `const' or `volatile' is not enough.)
1841 A typedef'd name following these is taken as a name to be declared.
1842 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1844 typed_declspecs:
1845 typed_typespecs %prec EMPTY
1846 { $$.lookups = type_lookups; }
1847 | typed_declspecs1
1848 { $$.lookups = type_lookups; }
1851 typed_declspecs1:
1852 declmods typespec
1853 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1854 $$.new_type_flag = $2.new_type_flag; }
1855 | typespec reserved_declspecs %prec HYPERUNARY
1856 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1857 $$.new_type_flag = $1.new_type_flag; }
1858 | typespec reserved_typespecquals reserved_declspecs
1859 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1860 $$.new_type_flag = $1.new_type_flag; }
1861 | declmods typespec reserved_declspecs
1862 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1863 $$.new_type_flag = $2.new_type_flag; }
1864 | declmods typespec reserved_typespecquals
1865 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1866 $$.new_type_flag = $2.new_type_flag; }
1867 | declmods typespec reserved_typespecquals reserved_declspecs
1868 { $$.t = tree_cons (NULL_TREE, $2.t,
1869 chainon ($3, chainon ($4, $1.t)));
1870 $$.new_type_flag = $2.new_type_flag; }
1873 reserved_declspecs:
1874 SCSPEC
1875 { if (extra_warnings)
1876 warning ("`%s' is not at beginning of declaration",
1877 IDENTIFIER_POINTER ($$));
1878 $$ = build_tree_list (NULL_TREE, $$); }
1879 | reserved_declspecs typespecqual_reserved
1880 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1881 | reserved_declspecs SCSPEC
1882 { if (extra_warnings)
1883 warning ("`%s' is not at beginning of declaration",
1884 IDENTIFIER_POINTER ($2));
1885 $$ = tree_cons (NULL_TREE, $2, $$); }
1886 | reserved_declspecs attributes
1887 { $$ = tree_cons ($2, NULL_TREE, $1); }
1888 | attributes
1889 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1892 /* List of just storage classes and type modifiers.
1893 A declaration can start with just this, but then it cannot be used
1894 to redeclare a typedef-name.
1895 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1897 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1898 up on a persistent obstack. Otherwise, they could appear at the
1899 beginning of something like
1901 static const struct { int foo () { } } b;
1903 and would be discarded after we finish compiling foo. We don't need to
1904 worry once we see a type. */
1906 declmods:
1907 nonempty_cv_qualifiers %prec EMPTY
1908 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1909 | SCSPEC
1911 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1912 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1914 | declmods CV_QUALIFIER
1916 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1917 TREE_STATIC ($$.t) = 1;
1919 | declmods SCSPEC
1921 if (extra_warnings && TREE_STATIC ($$.t))
1922 warning ("`%s' is not at beginning of declaration",
1923 IDENTIFIER_POINTER ($2));
1924 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1925 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1927 | declmods attributes
1928 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1929 | attributes %prec EMPTY
1931 $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
1932 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1936 /* Used instead of declspecs where storage classes are not allowed
1937 (that is, for typenames and structure components).
1939 C++ can takes storage classes for structure components.
1940 Don't accept a typedef-name if anything but a modifier precedes it. */
1942 typed_typespecs:
1943 typespec %prec EMPTY
1944 { $$.t = build_tree_list (NULL_TREE, $1.t);
1945 $$.new_type_flag = $1.new_type_flag; }
1946 | nonempty_cv_qualifiers typespec
1947 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1948 $$.new_type_flag = $2.new_type_flag; }
1949 | typespec reserved_typespecquals
1950 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1951 $$.new_type_flag = $1.new_type_flag; }
1952 | nonempty_cv_qualifiers typespec reserved_typespecquals
1953 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1954 $$.new_type_flag = $2.new_type_flag; }
1957 reserved_typespecquals:
1958 typespecqual_reserved
1959 { $$ = build_tree_list (NULL_TREE, $1.t); }
1960 | reserved_typespecquals typespecqual_reserved
1961 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
1964 /* A typespec (but not a type qualifier).
1965 Once we have seen one of these in a declaration,
1966 if a typedef name appears then it is being redeclared. */
1968 typespec:
1969 structsp
1970 { $$.lookups = NULL_TREE; }
1971 | TYPESPEC %prec EMPTY
1972 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1973 | complete_type_name
1974 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1975 | TYPEOF '(' expr ')'
1976 { $$.t = finish_typeof ($3);
1977 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1978 | TYPEOF '(' type_id ')'
1979 { $$.t = groktypename ($3.t);
1980 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1981 | SIGOF '(' expr ')'
1982 { tree type = TREE_TYPE ($3);
1984 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1985 if (IS_AGGR_TYPE (type))
1987 sorry ("sigof type specifier");
1988 $$.t = type;
1990 else
1992 error ("`sigof' applied to non-aggregate expression");
1993 $$.t = error_mark_node;
1996 | SIGOF '(' type_id ')'
1997 { tree type = groktypename ($3.t);
1999 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2000 if (IS_AGGR_TYPE (type))
2002 sorry ("sigof type specifier");
2003 $$.t = type;
2005 else
2007 error("`sigof' applied to non-aggregate type");
2008 $$.t = error_mark_node;
2013 /* A typespec that is a reserved word, or a type qualifier. */
2015 typespecqual_reserved:
2016 TYPESPEC
2017 { $$.t = $1; $$.new_type_flag = 0; }
2018 | CV_QUALIFIER
2019 { $$.t = $1; $$.new_type_flag = 0; }
2020 | structsp
2023 initdecls:
2024 initdcl0
2025 | initdecls ',' initdcl
2026 { check_multiple_declarators (); }
2029 notype_initdecls:
2030 notype_initdcl0
2031 | notype_initdecls ',' initdcl
2032 { check_multiple_declarators (); }
2035 nomods_initdecls:
2036 nomods_initdcl0
2037 | nomods_initdecls ',' initdcl
2038 { check_multiple_declarators (); }
2041 maybeasm:
2042 /* empty */
2043 { $$ = NULL_TREE; }
2044 | asm_keyword '(' string ')'
2045 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
2048 initdcl:
2049 declarator maybeasm maybe_attribute '='
2050 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2051 init
2052 /* Note how the declaration of the variable is in effect while its init is parsed! */
2053 { parse_end_decl ($<ttype>5, $6, $2); }
2054 | declarator maybeasm maybe_attribute
2056 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2057 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2061 /* This rule assumes a certain configuration of the parser stack.
2062 In particular, $0, the element directly before the beginning of
2063 this rule on the stack, must be a maybeasm. $-1 must be a
2064 declarator or notype_declarator. And $-2 must be some declmods
2065 or declspecs. We can't move the maybeasm into this rule because
2066 we need that reduce so we prefer fn.def1 when appropriate. */
2067 initdcl0_innards:
2068 maybe_attribute '='
2069 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2070 $<ftype>-2.lookups, $1, 1); }
2071 /* Note how the declaration of the variable is in effect
2072 while its init is parsed! */
2073 init
2074 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2075 | maybe_attribute
2076 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2077 $<ftype>-2.lookups, $1, 0);
2078 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2081 initdcl0:
2082 declarator maybeasm initdcl0_innards
2086 notype_initdcl0:
2087 notype_declarator maybeasm initdcl0_innards
2091 nomods_initdcl0:
2092 notype_declarator maybeasm
2093 { /* Set things up as initdcl0_innards expects. */
2094 $<ttype>3 = $2;
2095 $2 = $1;
2096 $<ftype>1.t = NULL_TREE;
2097 $<ftype>1.lookups = NULL_TREE; }
2098 initdcl0_innards
2100 | constructor_declarator maybeasm maybe_attribute
2101 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2102 parse_end_decl (d, NULL_TREE, $2); }
2105 /* the * rules are dummies to accept the Apollo extended syntax
2106 so that the header files compile. */
2107 maybe_attribute:
2108 /* empty */
2109 { $$ = NULL_TREE; }
2110 | attributes
2111 { $$ = $1; }
2114 attributes:
2115 attribute
2116 { $$ = $1; }
2117 | attributes attribute
2118 { $$ = chainon ($1, $2); }
2121 attribute:
2122 ATTRIBUTE '(' '(' attribute_list ')' ')'
2123 { $$ = $4; }
2126 attribute_list:
2127 attrib
2128 { $$ = $1; }
2129 | attribute_list ',' attrib
2130 { $$ = chainon ($1, $3); }
2133 attrib:
2134 /* empty */
2135 { $$ = NULL_TREE; }
2136 | any_word
2137 { $$ = build_tree_list ($1, NULL_TREE); }
2138 | any_word '(' IDENTIFIER ')'
2139 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2140 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2141 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2142 | any_word '(' nonnull_exprlist ')'
2143 { $$ = build_tree_list ($1, $3); }
2146 /* This still leaves out most reserved keywords,
2147 shouldn't we include them? */
2149 any_word:
2150 identifier
2151 | SCSPEC
2152 | TYPESPEC
2153 | CV_QUALIFIER
2156 /* A nonempty list of identifiers, including typenames. */
2157 identifiers_or_typenames:
2158 identifier
2159 { $$ = build_tree_list (NULL_TREE, $1); }
2160 | identifiers_or_typenames ',' identifier
2161 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2164 maybe_init:
2165 /* empty */ %prec EMPTY
2166 { $$ = NULL_TREE; }
2167 | '=' init
2168 { $$ = $2; }
2170 /* If we are processing a template, we don't want to expand this
2171 initializer yet. */
2173 init:
2174 expr_no_commas %prec '='
2175 | '{' '}'
2176 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2177 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2178 | '{' initlist '}'
2179 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2180 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2181 | '{' initlist ',' '}'
2182 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2183 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2184 | error
2185 { $$ = NULL_TREE; }
2188 /* This chain is built in reverse order,
2189 and put in forward order where initlist is used. */
2190 initlist:
2191 init
2192 { $$ = build_tree_list (NULL_TREE, $$); }
2193 | initlist ',' init
2194 { $$ = tree_cons (NULL_TREE, $3, $$); }
2195 /* These are for labeled elements. */
2196 | '[' expr_no_commas ']' init
2197 { $$ = build_tree_list ($2, $4); }
2198 | identifier ':' init
2199 { $$ = build_tree_list ($$, $3); }
2200 | initlist ',' identifier ':' init
2201 { $$ = tree_cons ($3, $5, $$); }
2204 pending_inline:
2205 PRE_PARSED_FUNCTION_DECL maybe_return_init ctor_initializer_opt compstmt_or_error
2207 expand_body (finish_function ((int)$3 | 2));
2208 process_next_inline ($1);
2210 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2212 expand_body (finish_function ((int)$3 | 2));
2213 process_next_inline ($1);
2215 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2217 finish_function (2);
2218 process_next_inline ($1); }
2221 pending_inlines:
2222 /* empty */
2223 | pending_inlines pending_inline eat_saved_input
2226 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2227 the TREE_LIST node for the parameter in question. */
2228 defarg_again:
2229 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2230 { replace_defarg ($1, $2); }
2231 | DEFARG_MARKER error END_OF_SAVED_INPUT
2232 { replace_defarg ($1, error_mark_node); }
2234 pending_defargs:
2235 /* empty */ %prec EMPTY
2236 | pending_defargs defarg_again
2237 { do_pending_defargs (); }
2238 | pending_defargs error
2239 { do_pending_defargs (); }
2242 structsp:
2243 ENUM identifier '{'
2244 { $<ttype>$ = current_enum_type;
2245 current_enum_type = start_enum ($2); }
2246 enumlist_opt '}'
2247 { $$.t = current_enum_type;
2248 finish_enum (current_enum_type);
2249 $$.new_type_flag = 1;
2250 current_enum_type = $<ttype>4;
2251 check_for_missing_semicolon ($$.t); }
2252 | ENUM '{'
2253 { $<ttype>$ = current_enum_type;
2254 current_enum_type = start_enum (make_anon_name ()); }
2255 enumlist_opt '}'
2256 { $$.t = current_enum_type;
2257 finish_enum (current_enum_type);
2258 $$.new_type_flag = 1;
2259 current_enum_type = $<ttype>3;
2260 check_for_missing_semicolon ($$.t); }
2261 | ENUM identifier
2262 { $$.t = xref_tag (enum_type_node, $2, 1);
2263 $$.new_type_flag = 0; }
2264 | ENUM complex_type_name
2265 { $$.t = xref_tag (enum_type_node, $2, 1);
2266 $$.new_type_flag = 0; }
2267 | TYPENAME_KEYWORD typename_sub
2268 { $$.t = $2;
2269 $$.new_type_flag = 0;
2270 if (!processing_template_decl)
2271 cp_pedwarn ("using `typename' outside of template"); }
2272 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2273 | class_head '{'
2274 { $1.t = begin_class_definition ($1.t);
2275 current_aggr = NULL_TREE; }
2276 opt.component_decl_list '}' maybe_attribute
2278 int semi;
2279 tree t;
2281 if (yychar == YYEMPTY)
2282 yychar = YYLEX;
2283 semi = yychar == ';';
2285 t = finish_class_definition ($1.t, $6, semi,
2286 $1.new_type_flag);
2287 $<ttype>$ = t;
2289 /* restore current_aggr */
2290 current_aggr = TREE_CODE (t) != RECORD_TYPE
2291 ? union_type_node
2292 : CLASSTYPE_DECLARED_CLASS (t)
2293 ? class_type_node : record_type_node;
2295 pending_defargs
2297 done_pending_defargs ();
2298 begin_inline_definitions ();
2300 pending_inlines
2302 finish_inline_definitions ();
2303 $$.t = $<ttype>7;
2304 $$.new_type_flag = 1;
2306 | class_head %prec EMPTY
2308 if ($1.new_type_flag && $1.t != error_mark_node)
2309 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2310 $$.new_type_flag = 0;
2311 if ($1.t == error_mark_node)
2312 $$.t = $1.t;
2313 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2315 cp_error ("%T is not a class type", $1.t);
2316 $$.t = error_mark_node;
2318 else
2320 $$.t = $1.t;
2321 /* struct B: public A; is not accepted by the standard grammar. */
2322 if (CLASS_TYPE_P ($$.t)
2323 && TYPE_BINFO_BASETYPES ($$.t)
2324 && !COMPLETE_TYPE_P ($$.t)
2325 && ! TYPE_BEING_DEFINED ($$.t))
2326 cp_error ("base clause without member specification for `%#T'",
2327 $$.t);
2332 maybecomma:
2333 /* empty */
2334 | ','
2337 maybecomma_warn:
2338 /* empty */
2339 | ','
2340 { if (pedantic && !in_system_header)
2341 pedwarn ("comma at end of enumerator list"); }
2344 aggr:
2345 AGGR
2346 | aggr SCSPEC
2347 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2348 | aggr TYPESPEC
2349 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2350 | aggr CV_QUALIFIER
2351 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2352 | aggr AGGR
2353 { error ("no body nor ';' separates two class, struct or union declarations"); }
2354 | aggr attributes
2355 { $$ = build_tree_list ($2, $1); }
2358 named_class_head_sans_basetype:
2359 aggr identifier
2361 current_aggr = $1;
2362 $$ = $2;
2366 named_class_head_sans_basetype_defn:
2367 aggr identifier_defn %prec EMPTY
2368 { current_aggr = $$; $$ = $2; }
2369 | named_class_head_sans_basetype '{'
2370 { yyungetc ('{', 1); }
2371 | named_class_head_sans_basetype ':'
2372 { yyungetc (':', 1); }
2375 named_complex_class_head_sans_basetype:
2376 aggr nested_name_specifier identifier
2378 current_aggr = $1;
2379 $$.t = handle_class_head ($1, $2, $3);
2380 $$.new_type_flag = 1;
2382 | aggr global_scope nested_name_specifier identifier
2384 current_aggr = $1;
2385 $$.t = handle_class_head ($1, $3, $4);
2386 $$.new_type_flag = 1;
2388 | aggr global_scope identifier
2390 current_aggr = $1;
2391 $$.t = handle_class_head ($1, NULL_TREE, $3);
2392 $$.new_type_flag = 1;
2394 | aggr apparent_template_type
2396 current_aggr = $1;
2397 $$.t = $2;
2398 $$.new_type_flag = 0;
2400 | aggr nested_name_specifier apparent_template_type
2402 current_aggr = $1;
2403 $$.t = $3;
2404 push_scope (CP_DECL_CONTEXT ($$.t));
2405 $$.new_type_flag = 1;
2409 named_class_head:
2410 named_class_head_sans_basetype %prec EMPTY
2412 $$.t = xref_tag (current_aggr, $1, 1);
2413 $$.new_type_flag = 0;
2415 | named_class_head_sans_basetype_defn
2416 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2417 /* Class name is unqualified, so we look for base classes
2418 in the current scope. */
2419 maybe_base_class_list %prec EMPTY
2421 $$.t = $<ttype>2;
2422 $$.new_type_flag = 0;
2423 if ($3)
2424 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2426 | named_complex_class_head_sans_basetype
2427 maybe_base_class_list
2429 if ($1.t != error_mark_node)
2431 tree type = TREE_TYPE ($1.t);
2433 $$.t = type;
2434 $$.new_type_flag = $1.new_type_flag;
2435 if ((current_aggr == union_type_node)
2436 != (TREE_CODE (type) == UNION_TYPE))
2437 cp_pedwarn (current_aggr == union_type_node
2438 ? "`union' tag used in declaring `%#T'"
2439 : "non-`union' tag used in declaring `%#T'",
2440 type);
2441 else if (TREE_CODE (type) == RECORD_TYPE)
2442 /* We might be specializing a template with a different
2443 class-key; deal. */
2444 CLASSTYPE_DECLARED_CLASS (type)
2445 = (current_aggr == class_type_node);
2446 if ($2)
2448 if (TREE_CODE (type) == TYPENAME_TYPE)
2449 /* In a definition of a member class template, we
2450 will get here with an implicit typename, a
2451 TYPENAME_TYPE with a type. */
2452 type = TREE_TYPE (type);
2453 maybe_process_partial_specialization (type);
2454 xref_basetypes (current_aggr, $1.t, type, $2);
2460 unnamed_class_head:
2461 aggr '{'
2462 { $$ = xref_tag ($$, make_anon_name (), 0);
2463 yyungetc ('{', 1); }
2466 /* The tree output of this nonterminal a declarationf or the type
2467 named. If NEW_TYPE_FLAG is set, then the name used in this
2468 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2469 already called push_scope for X. */
2470 class_head:
2471 unnamed_class_head
2473 $$.t = $1;
2474 $$.new_type_flag = 0;
2476 | named_class_head
2479 maybe_base_class_list:
2480 /* empty */ %prec EMPTY
2481 { $$ = NULL_TREE; }
2482 | ':' see_typename %prec EMPTY
2483 { yyungetc(':', 1); $$ = NULL_TREE; }
2484 | ':' see_typename base_class_list %prec EMPTY
2485 { $$ = $3; }
2488 base_class_list:
2489 base_class
2490 | base_class_list ',' see_typename base_class
2491 { $$ = chainon ($$, $4); }
2494 base_class:
2495 base_class.1
2496 { $$ = finish_base_specifier (access_default_node, $1); }
2497 | base_class_access_list see_typename base_class.1
2498 { $$ = finish_base_specifier ($1, $3); }
2501 base_class.1:
2502 typename_sub
2503 { if (!TYPE_P ($$))
2504 $$ = error_mark_node; }
2505 | nonnested_type
2506 { $$ = TREE_TYPE ($$); }
2509 base_class_access_list:
2510 VISSPEC see_typename
2511 | SCSPEC see_typename
2512 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2513 cp_error ("`%D' access", $1);
2514 $$ = access_default_virtual_node; }
2515 | base_class_access_list VISSPEC see_typename
2517 if ($1 != access_default_virtual_node)
2518 error ("multiple access specifiers");
2519 else if ($2 == access_public_node)
2520 $$ = access_public_virtual_node;
2521 else if ($2 == access_protected_node)
2522 $$ = access_protected_virtual_node;
2523 else /* $2 == access_private_node */
2524 $$ = access_private_virtual_node;
2526 | base_class_access_list SCSPEC see_typename
2527 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2528 cp_error ("`%D' access", $2);
2529 else if ($$ == access_public_node)
2530 $$ = access_public_virtual_node;
2531 else if ($$ == access_protected_node)
2532 $$ = access_protected_virtual_node;
2533 else if ($$ == access_private_node)
2534 $$ = access_private_virtual_node;
2535 else
2536 error ("multiple `virtual' specifiers");
2540 opt.component_decl_list:
2541 | component_decl_list
2542 | opt.component_decl_list access_specifier component_decl_list
2543 | opt.component_decl_list access_specifier
2546 access_specifier:
2547 VISSPEC ':'
2549 current_access_specifier = $1;
2553 /* Note: we no longer warn about the semicolon after a component_decl_list.
2554 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2555 component_decl_list:
2556 component_decl
2558 finish_member_declaration ($1);
2559 current_aggr = NULL_TREE;
2560 reset_type_access_control ();
2562 | component_decl_list component_decl
2564 finish_member_declaration ($2);
2565 current_aggr = NULL_TREE;
2566 reset_type_access_control ();
2570 component_decl:
2571 component_decl_1 ';'
2572 | component_decl_1 '}'
2573 { error ("missing ';' before right brace");
2574 yyungetc ('}', 0); }
2575 /* C++: handle constructors, destructors and inline functions */
2576 /* note that INLINE is like a TYPESPEC */
2577 | fn.def2 ':' /* base_init compstmt */
2578 { $$ = finish_method ($$); }
2579 | fn.def2 TRY /* base_init compstmt */
2580 { $$ = finish_method ($$); }
2581 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2582 { $$ = finish_method ($$); }
2583 | fn.def2 '{' /* nodecls compstmt */
2584 { $$ = finish_method ($$); }
2585 | ';'
2586 { $$ = NULL_TREE; }
2587 | extension component_decl
2588 { $$ = $2;
2589 pedantic = $1; }
2590 | template_header component_decl
2592 if ($2)
2593 $$ = finish_member_template_decl ($2);
2594 else
2595 /* The component was already processed. */
2596 $$ = NULL_TREE;
2598 finish_template_decl ($1);
2600 | template_header typed_declspecs ';'
2602 $$ = finish_member_class_template ($2.t);
2603 finish_template_decl ($1);
2605 | bad_decl
2606 { $$ = NULL_TREE; }
2609 component_decl_1:
2610 /* Do not add a "typed_declspecs declarator" rule here for
2611 speed; we need to call grok_x_components for enums, so the
2612 speedup would be insignificant. */
2613 typed_declspecs components
2615 /* Most of the productions for component_decl only
2616 allow the creation of one new member, so we call
2617 finish_member_declaration in component_decl_list.
2618 For this rule and the next, however, there can be
2619 more than one member, e.g.:
2621 int i, j;
2623 and we need the first member to be fully
2624 registered before the second is processed.
2625 Therefore, the rules for components take care of
2626 this processing. To avoid registering the
2627 components more than once, we send NULL_TREE up
2628 here; that lets finish_member_declaration know
2629 that there is nothing to do. */
2630 if (!$2)
2631 grok_x_components ($1.t);
2632 $$ = NULL_TREE;
2634 | declmods notype_components
2636 if (!$2)
2637 grok_x_components ($1.t);
2638 $$ = NULL_TREE;
2640 | notype_declarator maybeasm maybe_attribute maybe_init
2641 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2642 | constructor_declarator maybeasm maybe_attribute maybe_init
2643 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2644 | ':' expr_no_commas
2645 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2646 | error
2647 { $$ = NULL_TREE; }
2649 /* These rules introduce a reduce/reduce conflict; in
2650 typedef int foo, bar;
2651 class A {
2652 foo (bar);
2654 should "A::foo" be declared as a function or "A::bar" as a data
2655 member? In other words, is "bar" an after_type_declarator or a
2656 parmlist? */
2657 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2658 { tree specs, attrs;
2659 split_specs_attrs ($1.t, &specs, &attrs);
2660 $$ = grokfield ($2, specs, $5, $3,
2661 chainon ($4, attrs)); }
2662 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2663 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2664 | using_decl
2665 { $$ = do_class_using_decl ($1); }
2667 /* The case of exactly one component is handled directly by component_decl. */
2668 /* ??? Huh? ^^^ */
2669 components:
2670 /* empty: possibly anonymous */
2671 { $$ = 0; }
2672 | component_declarator0
2674 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2675 $1 = finish_member_template_decl ($1);
2676 finish_member_declaration ($1);
2677 $$ = 1;
2679 | components ',' component_declarator
2681 check_multiple_declarators ();
2682 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2683 $3 = finish_member_template_decl ($3);
2684 finish_member_declaration ($3);
2685 $$ = 2;
2689 notype_components:
2690 /* empty: possibly anonymous */
2691 { $$ = 0; }
2692 | notype_component_declarator0
2694 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2695 $1 = finish_member_template_decl ($1);
2696 finish_member_declaration ($1);
2697 $$ = 1;
2699 | notype_components ',' notype_component_declarator
2701 check_multiple_declarators ();
2702 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2703 $3 = finish_member_template_decl ($3);
2704 finish_member_declaration ($3);
2705 $$ = 2;
2709 component_declarator0:
2710 after_type_component_declarator0
2711 | notype_component_declarator0
2714 component_declarator:
2715 after_type_component_declarator
2716 | notype_component_declarator
2719 after_type_component_declarator0:
2720 after_type_declarator maybeasm maybe_attribute maybe_init
2721 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2722 $3, $2, $4); }
2723 | TYPENAME ':' expr_no_commas maybe_attribute
2724 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2725 $4, $3); }
2728 notype_component_declarator0:
2729 notype_declarator maybeasm maybe_attribute maybe_init
2730 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2731 $3, $2, $4); }
2732 | constructor_declarator maybeasm maybe_attribute maybe_init
2733 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2734 $3, $2, $4); }
2735 | IDENTIFIER ':' expr_no_commas maybe_attribute
2736 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2737 $4, $3); }
2738 | ':' expr_no_commas maybe_attribute
2739 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2740 $<ftype>0.lookups, $3, $2); }
2743 after_type_component_declarator:
2744 after_type_declarator maybeasm maybe_attribute maybe_init
2745 { $$ = parse_field ($1, $3, $2, $4); }
2746 | TYPENAME ':' expr_no_commas maybe_attribute
2747 { $$ = parse_bitfield ($1, $4, $3); }
2750 notype_component_declarator:
2751 notype_declarator maybeasm maybe_attribute maybe_init
2752 { $$ = parse_field ($1, $3, $2, $4); }
2753 | IDENTIFIER ':' expr_no_commas maybe_attribute
2754 { $$ = parse_bitfield ($1, $4, $3); }
2755 | ':' expr_no_commas maybe_attribute
2756 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2759 enumlist_opt:
2760 enumlist maybecomma_warn
2761 | maybecomma_warn
2764 /* We chain the enumerators in reverse order.
2765 Because of the way enums are built, the order is
2766 insignificant. Take advantage of this fact. */
2768 enumlist:
2769 enumerator
2770 | enumlist ',' enumerator
2773 enumerator:
2774 identifier
2775 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2776 | identifier '=' expr_no_commas
2777 { build_enumerator ($1, $3, current_enum_type); }
2780 /* ISO new-type-id (5.3.4) */
2781 new_type_id:
2782 type_specifier_seq new_declarator
2783 { $$.t = build_tree_list ($1.t, $2);
2784 $$.new_type_flag = $1.new_type_flag; }
2785 | type_specifier_seq %prec EMPTY
2786 { $$.t = build_tree_list ($1.t, NULL_TREE);
2787 $$.new_type_flag = $1.new_type_flag; }
2788 /* GNU extension to allow arrays of arbitrary types with
2789 non-constant dimension. */
2790 | '(' type_id ')' '[' expr ']'
2792 if (pedantic)
2793 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2794 $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2795 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2796 $$.new_type_flag = $2.new_type_flag;
2800 cv_qualifiers:
2801 /* empty */ %prec EMPTY
2802 { $$ = NULL_TREE; }
2803 | cv_qualifiers CV_QUALIFIER
2804 { $$ = tree_cons (NULL_TREE, $2, $$); }
2807 nonempty_cv_qualifiers:
2808 CV_QUALIFIER
2809 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2810 $$.new_type_flag = 0; }
2811 | nonempty_cv_qualifiers CV_QUALIFIER
2812 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2813 $$.new_type_flag = $1.new_type_flag; }
2816 /* These rules must follow the rules for function declarations
2817 and component declarations. That way, longer rules are preferred. */
2819 /* An expression which will not live on the momentary obstack. */
2820 maybe_parmlist:
2821 '(' nonnull_exprlist ')'
2822 { $$ = $2; }
2823 | '(' parmlist ')'
2824 { $$ = $2; }
2825 | LEFT_RIGHT
2826 { $$ = empty_parms (); }
2827 | '(' error ')'
2828 { $$ = NULL_TREE; }
2831 /* A declarator that is allowed only after an explicit typespec. */
2833 after_type_declarator_intern:
2834 after_type_declarator
2835 | attributes after_type_declarator
2837 /* Provide support for '(' attributes '*' declarator ')'
2838 etc */
2839 $$ = tree_cons ($1, $2, NULL_TREE);
2843 /* may all be followed by prec '.' */
2844 after_type_declarator:
2845 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2846 { $$ = make_pointer_declarator ($2.t, $3); }
2847 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2848 { $$ = make_reference_declarator ($2.t, $3); }
2849 | '*' after_type_declarator_intern %prec UNARY
2850 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2851 | '&' after_type_declarator_intern %prec UNARY
2852 { $$ = make_reference_declarator (NULL_TREE, $2); }
2853 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2854 { tree arg = make_pointer_declarator ($2, $3);
2855 $$ = build_nt (SCOPE_REF, $1, arg);
2857 | direct_after_type_declarator
2860 direct_after_type_declarator:
2861 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2862 { $$ = make_call_declarator ($$, $2, $3, $4); }
2863 | direct_after_type_declarator '[' expr ']'
2864 { $$ = build_nt (ARRAY_REF, $$, $3); }
2865 | direct_after_type_declarator '[' ']'
2866 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2867 | '(' after_type_declarator_intern ')'
2868 { $$ = $2; }
2869 | nested_name_specifier type_name %prec EMPTY
2870 { push_nested_class ($1, 3);
2871 $$ = build_nt (SCOPE_REF, $$, $2);
2872 TREE_COMPLEXITY ($$) = current_class_depth; }
2873 | type_name %prec EMPTY
2876 nonnested_type:
2877 type_name %prec EMPTY
2879 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2881 $$ = lookup_name ($1, 1);
2882 maybe_note_name_used_in_class ($1, $$);
2884 else
2885 $$ = $1;
2887 | global_scope type_name
2889 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2890 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2891 else
2892 $$ = $2;
2893 got_scope = NULL_TREE;
2897 complete_type_name:
2898 nonnested_type
2899 | nested_type
2900 | global_scope nested_type
2901 { $$ = $2; }
2904 nested_type:
2905 nested_name_specifier type_name %prec EMPTY
2906 { $$ = get_type_decl ($2); }
2909 /* A declarator allowed whether or not there has been
2910 an explicit typespec. These cannot redeclare a typedef-name. */
2912 notype_declarator_intern:
2913 notype_declarator
2914 | attributes notype_declarator
2916 /* Provide support for '(' attributes '*' declarator ')'
2917 etc */
2918 $$ = tree_cons ($1, $2, NULL_TREE);
2922 notype_declarator:
2923 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2924 { $$ = make_pointer_declarator ($2.t, $3); }
2925 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2926 { $$ = make_reference_declarator ($2.t, $3); }
2927 | '*' notype_declarator_intern %prec UNARY
2928 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2929 | '&' notype_declarator_intern %prec UNARY
2930 { $$ = make_reference_declarator (NULL_TREE, $2); }
2931 | ptr_to_mem cv_qualifiers notype_declarator_intern
2932 { tree arg = make_pointer_declarator ($2, $3);
2933 $$ = build_nt (SCOPE_REF, $1, arg);
2935 | direct_notype_declarator
2938 complex_notype_declarator:
2939 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2940 { $$ = make_pointer_declarator ($2.t, $3); }
2941 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2942 { $$ = make_reference_declarator ($2.t, $3); }
2943 | '*' complex_notype_declarator %prec UNARY
2944 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2945 | '&' complex_notype_declarator %prec UNARY
2946 { $$ = make_reference_declarator (NULL_TREE, $2); }
2947 | ptr_to_mem cv_qualifiers notype_declarator_intern
2948 { tree arg = make_pointer_declarator ($2, $3);
2949 $$ = build_nt (SCOPE_REF, $1, arg);
2951 | complex_direct_notype_declarator
2954 complex_direct_notype_declarator:
2955 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2956 { $$ = make_call_declarator ($$, $2, $3, $4); }
2957 | '(' complex_notype_declarator ')'
2958 { $$ = $2; }
2959 | direct_notype_declarator '[' expr ']'
2960 { $$ = build_nt (ARRAY_REF, $$, $3); }
2961 | direct_notype_declarator '[' ']'
2962 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2963 | notype_qualified_id
2964 { enter_scope_of ($1); }
2965 | global_scope notype_qualified_id
2966 { enter_scope_of ($2); $$ = $2;}
2967 | global_scope notype_unqualified_id
2968 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
2969 enter_scope_of ($$);
2971 | nested_name_specifier notype_template_declarator
2972 { got_scope = NULL_TREE;
2973 $$ = build_nt (SCOPE_REF, $1, $2);
2974 enter_scope_of ($$);
2978 qualified_id:
2979 nested_name_specifier unqualified_id
2980 { got_scope = NULL_TREE;
2981 $$ = build_nt (SCOPE_REF, $$, $2); }
2982 | nested_name_specifier object_template_id
2983 { got_scope = NULL_TREE;
2984 $$ = build_nt (SCOPE_REF, $1, $2); }
2987 notype_qualified_id:
2988 nested_name_specifier notype_unqualified_id
2989 { got_scope = NULL_TREE;
2990 $$ = build_nt (SCOPE_REF, $$, $2); }
2991 | nested_name_specifier object_template_id
2992 { got_scope = NULL_TREE;
2993 $$ = build_nt (SCOPE_REF, $1, $2); }
2996 overqualified_id:
2997 notype_qualified_id
2998 | global_scope notype_qualified_id
2999 { $$ = $2; }
3002 functional_cast:
3003 typespec '(' nonnull_exprlist ')'
3004 { $$ = build_functional_cast ($1.t, $3); }
3005 | typespec '(' expr_or_declarator_intern ')'
3006 { $$ = reparse_decl_as_expr ($1.t, $3); }
3007 | typespec fcast_or_absdcl %prec EMPTY
3008 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3011 type_name:
3012 TYPENAME
3013 | SELFNAME
3014 | template_type %prec EMPTY
3017 nested_name_specifier:
3018 nested_name_specifier_1
3019 | nested_name_specifier nested_name_specifier_1
3020 { $$ = $2; }
3021 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3022 { got_scope = $$
3023 = make_typename_type ($1, $3, /*complain=*/1); }
3024 /* Error handling per Core 125. */
3025 | nested_name_specifier IDENTIFIER SCOPE
3026 { got_scope = $$
3027 = make_typename_type ($1, $2, /*complain=*/1); }
3028 | nested_name_specifier PTYPENAME SCOPE
3029 { got_scope = $$
3030 = make_typename_type ($1, $2, /*complain=*/1); }
3033 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3034 inline here?!? (jason) */
3035 nested_name_specifier_1:
3036 TYPENAME SCOPE
3038 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3040 $$ = lastiddecl;
3041 maybe_note_name_used_in_class ($1, $$);
3043 got_scope = $$ =
3044 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3046 | SELFNAME SCOPE
3048 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3049 $$ = lastiddecl;
3050 got_scope = $$ = TREE_TYPE ($$);
3052 | NSNAME SCOPE
3054 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3055 $$ = lastiddecl;
3056 got_scope = $$;
3058 | template_type SCOPE
3059 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3062 typename_sub:
3063 typename_sub0
3064 | global_scope typename_sub0
3065 { $$ = $2; }
3068 typename_sub0:
3069 typename_sub1 identifier %prec EMPTY
3071 if (TYPE_P ($1))
3072 $$ = make_typename_type ($1, $2, /*complain=*/1);
3073 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3074 cp_error ("`%T' is not a class or namespace", $2);
3075 else
3077 $$ = $2;
3078 if (TREE_CODE ($$) == TYPE_DECL)
3079 $$ = TREE_TYPE ($$);
3082 | typename_sub1 template_type %prec EMPTY
3083 { $$ = TREE_TYPE ($2); }
3084 | typename_sub1 explicit_template_type %prec EMPTY
3085 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
3086 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3087 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
3090 typename_sub1:
3091 typename_sub2
3093 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3094 cp_error ("`%T' is not a class or namespace", $1);
3095 else if (TREE_CODE ($1) == TYPE_DECL)
3096 $$ = TREE_TYPE ($1);
3098 | typename_sub1 typename_sub2
3100 if (TYPE_P ($1))
3101 $$ = make_typename_type ($1, $2, /*complain=*/1);
3102 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3103 cp_error ("`%T' is not a class or namespace", $2);
3104 else
3106 $$ = $2;
3107 if (TREE_CODE ($$) == TYPE_DECL)
3108 $$ = TREE_TYPE ($$);
3111 | typename_sub1 explicit_template_type SCOPE
3112 { got_scope = $$
3113 = make_typename_type ($1, $2, /*complain=*/1); }
3114 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3115 { got_scope = $$
3116 = make_typename_type ($1, $3, /*complain=*/1); }
3119 /* This needs to return a TYPE_DECL for simple names so that we don't
3120 forget what name was used. */
3121 typename_sub2:
3122 TYPENAME SCOPE
3124 if (TREE_CODE ($1) != TYPE_DECL)
3125 $$ = lastiddecl;
3127 /* Retrieve the type for the identifier, which might involve
3128 some computation. */
3129 got_scope = complete_type (TREE_TYPE ($$));
3131 if ($$ == error_mark_node)
3132 cp_error ("`%T' is not a class or namespace", $1);
3134 | SELFNAME SCOPE
3136 if (TREE_CODE ($1) != TYPE_DECL)
3137 $$ = lastiddecl;
3138 got_scope = complete_type (TREE_TYPE ($$));
3140 | template_type SCOPE
3141 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3142 | PTYPENAME SCOPE
3143 | IDENTIFIER SCOPE
3144 | NSNAME SCOPE
3146 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3147 $$ = lastiddecl;
3148 got_scope = $$;
3152 explicit_template_type:
3153 identifier '<' template_arg_list_opt template_close_bracket
3154 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3157 complex_type_name:
3158 global_scope type_name
3160 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3161 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3162 else
3163 $$ = $2;
3164 got_scope = NULL_TREE;
3166 | nested_type
3167 | global_scope nested_type
3168 { $$ = $2; }
3171 ptr_to_mem:
3172 nested_name_specifier '*'
3173 { got_scope = NULL_TREE; }
3174 | global_scope nested_name_specifier '*'
3175 { $$ = $2; got_scope = NULL_TREE; }
3178 /* All uses of explicit global scope must go through this nonterminal so
3179 that got_scope will be set before yylex is called to get the next token. */
3180 global_scope:
3181 SCOPE
3182 { got_scope = void_type_node; }
3185 /* ISO new-declarator (5.3.4) */
3186 new_declarator:
3187 '*' cv_qualifiers new_declarator
3188 { $$ = make_pointer_declarator ($2, $3); }
3189 | '*' cv_qualifiers %prec EMPTY
3190 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3191 | '&' cv_qualifiers new_declarator %prec EMPTY
3192 { $$ = make_reference_declarator ($2, $3); }
3193 | '&' cv_qualifiers %prec EMPTY
3194 { $$ = make_reference_declarator ($2, NULL_TREE); }
3195 | ptr_to_mem cv_qualifiers %prec EMPTY
3196 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3197 $$ = build_nt (SCOPE_REF, $1, arg);
3199 | ptr_to_mem cv_qualifiers new_declarator
3200 { tree arg = make_pointer_declarator ($2, $3);
3201 $$ = build_nt (SCOPE_REF, $1, arg);
3203 | direct_new_declarator %prec EMPTY
3206 /* ISO direct-new-declarator (5.3.4) */
3207 direct_new_declarator:
3208 '[' expr ']'
3209 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3210 | direct_new_declarator '[' expr ']'
3211 { $$ = build_nt (ARRAY_REF, $$, $3); }
3214 absdcl_intern:
3215 absdcl
3216 | attributes absdcl
3218 /* Provide support for '(' attributes '*' declarator ')'
3219 etc */
3220 $$ = tree_cons ($1, $2, NULL_TREE);
3224 /* ISO abstract-declarator (8.1) */
3225 absdcl:
3226 '*' nonempty_cv_qualifiers absdcl_intern
3227 { $$ = make_pointer_declarator ($2.t, $3); }
3228 | '*' absdcl_intern
3229 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3230 | '*' nonempty_cv_qualifiers %prec EMPTY
3231 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3232 | '*' %prec EMPTY
3233 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3234 | '&' nonempty_cv_qualifiers absdcl_intern
3235 { $$ = make_reference_declarator ($2.t, $3); }
3236 | '&' absdcl_intern
3237 { $$ = make_reference_declarator (NULL_TREE, $2); }
3238 | '&' nonempty_cv_qualifiers %prec EMPTY
3239 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3240 | '&' %prec EMPTY
3241 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3242 | ptr_to_mem cv_qualifiers %prec EMPTY
3243 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3244 $$ = build_nt (SCOPE_REF, $1, arg);
3246 | ptr_to_mem cv_qualifiers absdcl_intern
3247 { tree arg = make_pointer_declarator ($2, $3);
3248 $$ = build_nt (SCOPE_REF, $1, arg);
3250 | direct_abstract_declarator %prec EMPTY
3253 /* ISO direct-abstract-declarator (8.1) */
3254 direct_abstract_declarator:
3255 '(' absdcl_intern ')'
3256 { $$ = $2; }
3257 /* `(typedef)1' is `int'. */
3258 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3259 { $$ = make_call_declarator ($$, $3, $5, $6); }
3260 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3261 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3262 | direct_abstract_declarator '[' expr ']' %prec '.'
3263 { $$ = build_nt (ARRAY_REF, $$, $3); }
3264 | direct_abstract_declarator '[' ']' %prec '.'
3265 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3266 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3267 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3268 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3269 { set_quals_and_spec ($$, $2, $3); }
3270 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3271 { set_quals_and_spec ($$, $2, $3); }
3272 | '[' expr ']' %prec '.'
3273 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3274 | '[' ']' %prec '.'
3275 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3278 /* For C++, decls and stmts can be intermixed, so we don't need to
3279 have a special rule that won't start parsing the stmt section
3280 until we have a stmt that parses without errors. */
3282 stmts:
3283 stmt
3284 | errstmt
3285 | stmts stmt
3286 | stmts errstmt
3289 errstmt:
3290 error ';'
3293 /* Read zero or more forward-declarations for labels
3294 that nested functions can jump to. */
3295 maybe_label_decls:
3296 /* empty */
3297 | label_decls
3298 { if (pedantic)
3299 pedwarn ("ISO C++ forbids label declarations"); }
3302 label_decls:
3303 label_decl
3304 | label_decls label_decl
3307 label_decl:
3308 LABEL identifiers_or_typenames ';'
3310 while ($2)
3312 finish_label_decl (TREE_VALUE ($2));
3313 $2 = TREE_CHAIN ($2);
3318 /* This is the body of a function definition.
3319 It causes syntax errors to ignore to the next openbrace. */
3320 compstmt_or_error:
3321 compstmt
3322 | error compstmt
3325 compstmt:
3326 save_lineno '{'
3327 { $<ttype>$ = begin_compound_stmt (0); }
3328 compstmtend
3329 { STMT_LINENO ($<ttype>3) = $1;
3330 finish_compound_stmt (0, $<ttype>3); }
3333 simple_if:
3335 { $<ttype>$ = begin_if_stmt ();
3336 cond_stmt_keyword = "if"; }
3337 paren_cond_or_null
3338 { finish_if_stmt_cond ($3, $<ttype>2); }
3339 implicitly_scoped_stmt
3340 { $$ = $<ttype>2;
3341 finish_then_clause ($<ttype>2); }
3344 implicitly_scoped_stmt:
3345 compstmt
3347 { $<ttype>$ = begin_compound_stmt (0); }
3348 save_lineno simple_stmt
3349 { STMT_LINENO ($<ttype>1) = $2;
3350 if ($3) STMT_LINENO ($3) = $2;
3351 finish_compound_stmt (0, $<ttype>1); }
3354 stmt:
3355 compstmt
3356 | save_lineno simple_stmt
3357 { if ($2) STMT_LINENO ($2) = $1; }
3360 simple_stmt:
3361 decl
3362 { finish_stmt ();
3363 $$ = NULL_TREE; }
3364 | expr ';'
3365 { $$ = finish_expr_stmt ($1); }
3366 | simple_if ELSE
3367 { begin_else_clause (); }
3368 implicitly_scoped_stmt
3370 $$ = $1;
3371 finish_else_clause ($1);
3372 finish_if_stmt ();
3374 | simple_if %prec IF
3375 { $$ = $1;
3376 finish_if_stmt (); }
3377 | WHILE
3379 $<ttype>$ = begin_while_stmt ();
3380 cond_stmt_keyword = "while";
3382 paren_cond_or_null
3383 { finish_while_stmt_cond ($3, $<ttype>2); }
3384 implicitly_scoped_stmt
3385 { $$ = $<ttype>2;
3386 finish_while_stmt ($<ttype>2); }
3387 | DO
3388 { $<ttype>$ = begin_do_stmt (); }
3389 implicitly_scoped_stmt WHILE
3391 finish_do_body ($<ttype>2);
3392 cond_stmt_keyword = "do";
3394 paren_expr_or_null ';'
3395 { $$ = $<ttype>2;
3396 finish_do_stmt ($6, $<ttype>2); }
3397 | FOR
3398 { $<ttype>$ = begin_for_stmt (); }
3399 '(' for.init.statement
3400 { finish_for_init_stmt ($<ttype>2); }
3401 xcond ';'
3402 { finish_for_cond ($6, $<ttype>2); }
3403 xexpr ')'
3404 { finish_for_expr ($9, $<ttype>2); }
3405 implicitly_scoped_stmt
3406 { $$ = $<ttype>2;
3407 finish_for_stmt ($<ttype>2); }
3408 | SWITCH
3409 { $<ttype>$ = begin_switch_stmt (); }
3410 '(' condition ')'
3411 { finish_switch_cond ($4, $<ttype>2); }
3412 implicitly_scoped_stmt
3413 { $$ = $<ttype>2;
3414 finish_switch_stmt ($<ttype>2); }
3415 | CASE expr_no_commas ':'
3416 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3417 stmt
3418 { $$ = $<ttype>4; }
3419 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3420 { $<ttype>$ = finish_case_label ($2, $4); }
3421 stmt
3422 { $$ = $<ttype>6; }
3423 | DEFAULT ':'
3424 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3425 stmt
3426 { $$ = $<ttype>3; }
3427 | BREAK ';'
3428 { $$ = finish_break_stmt (); }
3429 | CONTINUE ';'
3430 { $$ = finish_continue_stmt (); }
3431 | RETURN_KEYWORD ';'
3432 { $$ = finish_return_stmt (NULL_TREE); }
3433 | RETURN_KEYWORD expr ';'
3434 { $$ = finish_return_stmt ($2); }
3435 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3436 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3437 NULL_TREE);
3438 ASM_INPUT_P ($$) = 1; }
3439 /* This is the case with just output operands. */
3440 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3441 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3442 /* This is the case with input operands as well. */
3443 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3444 asm_operands ')' ';'
3445 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3446 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ')' ';'
3447 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3448 /* This is the case with clobbered registers as well. */
3449 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3450 asm_operands ':' asm_clobbers ')' ';'
3451 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3452 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ':'
3453 asm_clobbers ')' ';'
3454 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3455 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands SCOPE
3456 asm_clobbers ')' ';'
3457 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3458 | GOTO '*' expr ';'
3460 if (pedantic)
3461 pedwarn ("ISO C++ forbids computed gotos");
3462 $$ = finish_goto_stmt ($3);
3464 | GOTO identifier ';'
3465 { $$ = finish_goto_stmt ($2); }
3466 | label_colon stmt
3467 { $$ = NULL_TREE; }
3468 | label_colon '}'
3469 { error ("label must be followed by statement");
3470 yyungetc ('}', 0);
3471 $$ = NULL_TREE; }
3472 | ';'
3473 { finish_stmt ();
3474 $$ = NULL_TREE; }
3475 | try_block
3476 { $$ = NULL_TREE; }
3477 | using_directive
3478 { $$ = NULL_TREE; }
3479 | namespace_using_decl
3480 { do_local_using_decl ($1);
3481 $$ = NULL_TREE; }
3482 | namespace_alias
3483 { $$ = NULL_TREE; }
3486 function_try_block:
3488 { $<ttype>$ = begin_function_try_block (); }
3489 ctor_initializer_opt compstmt
3490 { finish_function_try_block ($<ttype>2); }
3491 handler_seq
3493 finish_function_handler_sequence ($<ttype>2);
3494 $$ = $3;
3498 try_block:
3500 { $<ttype>$ = begin_try_block (); }
3501 compstmt
3502 { finish_try_block ($<ttype>2); }
3503 handler_seq
3504 { finish_handler_sequence ($<ttype>2); }
3507 handler_seq:
3508 handler
3509 | handler_seq handler
3512 handler:
3513 CATCH
3514 { $<ttype>$ = begin_handler (); }
3515 handler_args
3516 { finish_handler_parms ($3, $<ttype>2); }
3517 compstmt
3518 { finish_handler ($<ttype>2); }
3521 type_specifier_seq:
3522 typed_typespecs %prec EMPTY
3523 | nonempty_cv_qualifiers %prec EMPTY
3526 handler_args:
3527 '(' ELLIPSIS ')'
3528 { $$ = NULL_TREE; }
3529 /* This doesn't allow reference parameters, the below does.
3530 | '(' type_specifier_seq absdcl ')'
3531 { check_for_new_type ("inside exception declarations", $2);
3532 expand_start_catch_block ($2.t, $3); }
3533 | '(' type_specifier_seq ')'
3534 { check_for_new_type ("inside exception declarations", $2);
3535 expand_start_catch_block ($2.t, NULL_TREE); }
3536 | '(' type_specifier_seq notype_declarator ')'
3537 { check_for_new_type ("inside exception declarations", $2);
3538 expand_start_catch_block ($2.t, $3); }
3539 | '(' typed_typespecs after_type_declarator ')'
3540 { check_for_new_type ("inside exception declarations", $2);
3541 expand_start_catch_block ($2.t, $3); }
3542 This allows reference parameters... */
3543 | '(' parm ')'
3545 check_for_new_type ("inside exception declarations", $2);
3546 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3547 TREE_VALUE ($2.t));
3551 label_colon:
3552 IDENTIFIER ':'
3553 { finish_label_stmt ($1); }
3554 | PTYPENAME ':'
3555 { finish_label_stmt ($1); }
3556 | TYPENAME ':'
3557 { finish_label_stmt ($1); }
3558 | SELFNAME ':'
3559 { finish_label_stmt ($1); }
3562 for.init.statement:
3563 xexpr ';'
3564 { finish_expr_stmt ($1); }
3565 | decl
3566 | '{' compstmtend
3567 { if (pedantic)
3568 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3572 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3574 maybe_cv_qualifier:
3575 /* empty */
3576 { $$ = NULL_TREE; }
3577 | CV_QUALIFIER
3580 xexpr:
3581 /* empty */
3582 { $$ = NULL_TREE; }
3583 | expr
3584 | error
3585 { $$ = NULL_TREE; }
3588 /* These are the operands other than the first string and colon
3589 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3590 asm_operands:
3591 /* empty */
3592 { $$ = NULL_TREE; }
3593 | nonnull_asm_operands
3596 nonnull_asm_operands:
3597 asm_operand
3598 | nonnull_asm_operands ',' asm_operand
3599 { $$ = chainon ($$, $3); }
3602 asm_operand:
3603 STRING '(' expr ')'
3604 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3605 | '[' identifier ']' STRING '(' expr ')'
3606 { $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3609 asm_clobbers:
3610 string
3611 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE);}
3612 | asm_clobbers ',' string
3613 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
3616 /* This is what appears inside the parens in a function declarator.
3617 Its value is represented in the format that grokdeclarator expects.
3619 In C++, declaring a function with no parameters
3620 means that that function takes *no* parameters. */
3622 parmlist:
3623 /* empty */
3625 $$ = empty_parms();
3627 | complex_parmlist
3628 | type_id
3629 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3630 check_for_new_type ("inside parameter list", $1); }
3633 /* This nonterminal does not include the common sequence '(' type_id ')',
3634 as it is ambiguous and must be disambiguated elsewhere. */
3635 complex_parmlist:
3636 parms
3637 { $$ = finish_parmlist ($$, 0); }
3638 | parms_comma ELLIPSIS
3639 { $$ = finish_parmlist ($1, 1); }
3640 /* C++ allows an ellipsis without a separating ',' */
3641 | parms ELLIPSIS
3642 { $$ = finish_parmlist ($1, 1); }
3643 | type_id ELLIPSIS
3644 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3645 $1.t), 1); }
3646 | ELLIPSIS
3647 { $$ = finish_parmlist (NULL_TREE, 1); }
3648 | parms ':'
3650 /* This helps us recover from really nasty
3651 parse errors, for example, a missing right
3652 parenthesis. */
3653 yyerror ("possibly missing ')'");
3654 $$ = finish_parmlist ($1, 0);
3655 yyungetc (':', 0);
3656 yychar = ')';
3658 | type_id ':'
3660 /* This helps us recover from really nasty
3661 parse errors, for example, a missing right
3662 parenthesis. */
3663 yyerror ("possibly missing ')'");
3664 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3665 $1.t), 0);
3666 yyungetc (':', 0);
3667 yychar = ')';
3671 /* A default argument to a */
3672 defarg:
3674 { maybe_snarf_defarg (); }
3675 defarg1
3676 { $$ = $3; }
3679 defarg1:
3680 DEFARG
3681 | init
3684 /* A nonempty list of parameter declarations or type names. */
3685 parms:
3686 named_parm
3687 { check_for_new_type ("in a parameter list", $1);
3688 $$ = build_tree_list (NULL_TREE, $1.t); }
3689 | parm defarg
3690 { check_for_new_type ("in a parameter list", $1);
3691 $$ = build_tree_list ($2, $1.t); }
3692 | parms_comma full_parm
3693 { check_for_new_type ("in a parameter list", $2);
3694 $$ = chainon ($$, $2.t); }
3695 | parms_comma bad_parm
3696 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3697 | parms_comma bad_parm '=' init
3698 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3701 parms_comma:
3702 parms ','
3703 | type_id ','
3704 { check_for_new_type ("in a parameter list", $1);
3705 $$ = build_tree_list (NULL_TREE, $1.t); }
3708 /* A single parameter declaration or parameter type name,
3709 as found in a parmlist. */
3710 named_parm:
3711 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3712 TYPESPEC IDENTIFIER. */
3713 typed_declspecs1 declarator
3714 { tree specs = strip_attrs ($1.t);
3715 $$.new_type_flag = $1.new_type_flag;
3716 $$.t = build_tree_list (specs, $2); }
3717 | typed_typespecs declarator
3718 { $$.t = build_tree_list ($1.t, $2);
3719 $$.new_type_flag = $1.new_type_flag; }
3720 | typespec declarator
3721 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3722 $2);
3723 $$.new_type_flag = $1.new_type_flag; }
3724 | typed_declspecs1 absdcl
3725 { tree specs = strip_attrs ($1.t);
3726 $$.t = build_tree_list (specs, $2);
3727 $$.new_type_flag = $1.new_type_flag; }
3728 | typed_declspecs1 %prec EMPTY
3729 { tree specs = strip_attrs ($1.t);
3730 $$.t = build_tree_list (specs, NULL_TREE);
3731 $$.new_type_flag = $1.new_type_flag; }
3732 | declmods notype_declarator
3733 { tree specs = strip_attrs ($1.t);
3734 $$.t = build_tree_list (specs, $2);
3735 $$.new_type_flag = 0; }
3738 full_parm:
3739 parm
3740 { $$.t = build_tree_list (NULL_TREE, $1.t);
3741 $$.new_type_flag = $1.new_type_flag; }
3742 | parm defarg
3743 { $$.t = build_tree_list ($2, $1.t);
3744 $$.new_type_flag = $1.new_type_flag; }
3747 parm:
3748 named_parm
3749 | type_id
3752 see_typename:
3753 /* empty */ %prec EMPTY
3754 { see_typename (); }
3757 bad_parm:
3758 /* empty */ %prec EMPTY
3760 error ("type specifier omitted for parameter");
3761 $$ = build_tree_list (integer_type_node, NULL_TREE);
3763 | notype_declarator
3765 error ("type specifier omitted for parameter");
3766 if (TREE_CODE ($$) == SCOPE_REF
3767 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3768 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM))
3769 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3770 $$ = build_tree_list (integer_type_node, $$);
3774 bad_decl:
3775 IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3777 cp_error("'%D' is used as a type, but is not defined as a type.", $1);
3778 $3 = error_mark_node;
3782 template_arg_list_ignore:
3783 '<' template_arg_list_opt template_close_bracket
3785 | /* empty */
3788 arg_list_ignore:
3789 '(' nonnull_exprlist ')'
3791 | /* empty */
3794 exception_specification_opt:
3795 /* empty */ %prec EMPTY
3796 { $$ = NULL_TREE; }
3797 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3798 { $$ = $3; }
3799 | THROW LEFT_RIGHT %prec EMPTY
3800 { $$ = empty_except_spec; }
3803 ansi_raise_identifier:
3804 type_id
3806 check_for_new_type ("exception specifier", $1);
3807 $$ = groktypename ($1.t);
3811 ansi_raise_identifiers:
3812 ansi_raise_identifier
3813 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3814 | ansi_raise_identifiers ',' ansi_raise_identifier
3815 { $$ = add_exception_specifier ($1, $3, 1); }
3818 conversion_declarator:
3819 /* empty */ %prec EMPTY
3820 { $$ = NULL_TREE; }
3821 | '*' cv_qualifiers conversion_declarator
3822 { $$ = make_pointer_declarator ($2, $3); }
3823 | '&' cv_qualifiers conversion_declarator
3824 { $$ = make_reference_declarator ($2, $3); }
3825 | ptr_to_mem cv_qualifiers conversion_declarator
3826 { tree arg = make_pointer_declarator ($2, $3);
3827 $$ = build_nt (SCOPE_REF, $1, arg);
3831 operator:
3832 OPERATOR
3834 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3835 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3836 /* We look for conversion-type-id's in both the class and current
3837 scopes, just as for ID in 'ptr->ID::'. */
3838 looking_for_typename = 1;
3839 got_object = got_scope;
3840 got_scope = NULL_TREE;
3844 unoperator:
3845 { got_scope = TREE_PURPOSE (saved_scopes);
3846 got_object = TREE_VALUE (saved_scopes);
3847 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3848 saved_scopes = TREE_CHAIN (saved_scopes);
3852 operator_name:
3853 operator '*' unoperator
3854 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3855 | operator '/' unoperator
3856 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3857 | operator '%' unoperator
3858 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3859 | operator '+' unoperator
3860 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3861 | operator '-' unoperator
3862 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3863 | operator '&' unoperator
3864 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3865 | operator '|' unoperator
3866 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3867 | operator '^' unoperator
3868 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3869 | operator '~' unoperator
3870 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3871 | operator ',' unoperator
3872 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3873 | operator ARITHCOMPARE unoperator
3874 { $$ = frob_opname (ansi_opname ($2)); }
3875 | operator '<' unoperator
3876 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3877 | operator '>' unoperator
3878 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3879 | operator EQCOMPARE unoperator
3880 { $$ = frob_opname (ansi_opname ($2)); }
3881 | operator ASSIGN unoperator
3882 { $$ = frob_opname (ansi_assopname ($2)); }
3883 | operator '=' unoperator
3884 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3885 | operator LSHIFT unoperator
3886 { $$ = frob_opname (ansi_opname ($2)); }
3887 | operator RSHIFT unoperator
3888 { $$ = frob_opname (ansi_opname ($2)); }
3889 | operator PLUSPLUS unoperator
3890 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3891 | operator MINUSMINUS unoperator
3892 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3893 | operator ANDAND unoperator
3894 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3895 | operator OROR unoperator
3896 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3897 | operator '!' unoperator
3898 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3899 | operator '?' ':' unoperator
3900 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3901 | operator MIN_MAX unoperator
3902 { $$ = frob_opname (ansi_opname ($2)); }
3903 | operator POINTSAT unoperator %prec EMPTY
3904 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3905 | operator POINTSAT_STAR unoperator %prec EMPTY
3906 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3907 | operator LEFT_RIGHT unoperator
3908 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3909 | operator '[' ']' unoperator
3910 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3911 | operator NEW unoperator %prec EMPTY
3912 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3913 | operator DELETE unoperator %prec EMPTY
3914 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3915 | operator NEW '[' ']' unoperator
3916 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3917 | operator DELETE '[' ']' unoperator
3918 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
3919 | operator type_specifier_seq conversion_declarator unoperator
3920 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
3921 | operator error unoperator
3922 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
3925 /* The forced readahead in here is because we might be at the end of a
3926 line, and lineno won't be bumped until yylex absorbs the first token
3927 on the next line. */
3928 save_lineno:
3929 { if (yychar == YYEMPTY)
3930 yychar = YYLEX;
3931 $$ = lineno; }
3935 #ifdef SPEW_DEBUG
3936 const char *
3937 debug_yytranslate (value)
3938 int value;
3940 return yytname[YYTRANSLATE (value)];
3943 #endif