/osprey/kg++fe/gnu/parse.y
Happy | 4998 lines | 4537 code | 461 blank | 0 comment | 0 complexity | 0526240d65a09eb832332774a4ed6222 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0, GPL-3.0
Large files files are truncated, but you can click here to view the full file
- /*
- Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved.
- File modified February 23, 2005 by PathScale, Inc. to add OpenMP support.
- */
- /* YACC parser for C++ syntax.
- Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
- Hacked by Michael Tiemann (tiemann@cygnus.com)
- This file is part of GNU CC.
- GNU CC is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
- GNU CC is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with GNU CC; see the file COPYING. If not, write to
- the Free Software Foundation, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
- /* This grammar is based on the GNU CC grammar. */
- /* Note: Bison automatically applies a default action of "$$ = $1" for
- all derivations; this is applied before the explicit action, if one
- is given. Keep this in mind when reading the actions. */
- %{
- #include "config.h"
- #include "system.h"
- #include "tree.h"
- #include "omp_types.h"
- #include "omp_directive.h"
- #include "input.h"
- #include "flags.h"
- #include "cp-tree.h"
- #include "decl.h"
- #include "lex.h"
- #include "c-pragma.h" /* For YYDEBUG definition. */
- #include "output.h"
- #include "toplev.h"
- #include "ggc.h"
- /* Like YYERROR but do call yyerror. */
- #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
- /* Like the default stack expander, except (1) use realloc when possible,
- (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
- Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
- give malloced_yyvs its proper type. This is ok since all we need from
- it is to be able to free it. */
- static short *malloced_yyss;
- static void *malloced_yyvs;
- static int class_template_ok_as_expr;
- #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
- do { \
- size_t newsize; \
- short *newss; \
- YYSTYPE *newvs; \
- newsize = *(YYSSZ) *= 2; \
- if (malloced_yyss) \
- { \
- newss = (short *) \
- really_call_realloc (*(SS), newsize * sizeof (short)); \
- newvs = (YYSTYPE *) \
- really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
- } \
- else \
- { \
- newss = (short *) really_call_malloc (newsize * sizeof (short)); \
- newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
- if (newss) \
- memcpy (newss, *(SS), (SSSIZE)); \
- if (newvs) \
- memcpy (newvs, *(VS), (VSSIZE)); \
- } \
- if (!newss || !newvs) \
- { \
- yyerror (MSG); \
- return 2; \
- } \
- *(SS) = newss; \
- *(VS) = newvs; \
- malloced_yyss = newss; \
- malloced_yyvs = (void *) newvs; \
- } while (0)
- #define OP0(NODE) (TREE_OPERAND (NODE, 0))
- #define OP1(NODE) (TREE_OPERAND (NODE, 1))
- /* Contains the statement keyword (if/while/do) to include in an
- error message if the user supplies an empty conditional expression. */
- static const char *cond_stmt_keyword;
- /* List of types and structure classes of the current declaration. */
- static GTY(()) tree current_declspecs;
- /* List of prefix attributes in effect.
- Prefix attributes are parsed by the reserved_declspecs and declmods
- rules. They create a list that contains *both* declspecs and attrs. */
- /* ??? It is not clear yet that all cases where an attribute can now appear in
- a declspec list have been updated. */
- static GTY(()) tree prefix_attributes;
- /* When defining an enumeration, this is the type of the enumeration. */
- static GTY(()) tree current_enum_type;
- /* When parsing a conversion operator name, this is the scope of the
- operator itself. */
- static GTY(()) tree saved_scopes;
- static tree empty_parms PARAMS ((void));
- static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
- static tree parse_decl PARAMS ((tree, tree, int));
- static void parse_end_decl PARAMS ((tree, tree, tree));
- static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
- static tree parse_field PARAMS ((tree, tree, tree, tree));
- static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
- static tree parse_bitfield PARAMS ((tree, tree, tree));
- static tree parse_method PARAMS ((tree, tree, tree));
- static void frob_specs PARAMS ((tree, tree));
- static void check_class_key PARAMS ((tree, tree));
- static tree parse_scoped_id PARAMS ((tree));
- static tree parse_xref_tag (tree, tree, int);
- static tree parse_handle_class_head (tree, tree, tree, int, int *);
- static void parse_decl_instantiation (tree, tree, tree);
- static int parse_begin_function_definition (tree, tree);
- static tree parse_finish_call_expr (tree, tree, int);
- bool In_MP_Region = false;
- static bool In_MP_Section = false;
- #define MAX_MP_NESTING 10
- static GTY(()) tree mp_locals[MAX_MP_NESTING];
- static int mp_nesting = -1;
- /* Cons up an empty parameter list. */
- static inline tree
- empty_parms ()
- {
- tree parms;
- #ifndef NO_IMPLICIT_EXTERN_C
- if (in_system_header && current_class_type == NULL
- && current_lang_name == lang_name_c)
- parms = NULL_TREE;
- else
- #endif
- parms = void_list_node;
- return parms;
- }
- /* Record the decl-specifiers, attributes and type lookups from the
- decl-specifier-seq in a declaration. */
- static void
- frob_specs (specs_attrs, lookups)
- tree specs_attrs, lookups;
- {
- save_type_access_control (lookups);
- split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
- if (current_declspecs
- && TREE_CODE (current_declspecs) != TREE_LIST)
- current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
- if (have_extern_spec)
- {
- /* We have to indicate that there is an "extern", but that it
- was part of a language specifier. For instance,
- extern "C" typedef int (*Ptr) ();
- is well formed. */
- current_declspecs = tree_cons (error_mark_node,
- get_identifier ("extern"),
- current_declspecs);
- have_extern_spec = false;
- }
- }
- static tree
- parse_decl (declarator, attributes, initialized)
- tree declarator, attributes;
- int initialized;
- {
- return start_decl (declarator, current_declspecs, initialized,
- attributes, prefix_attributes);
- }
- static tree
- parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
- tree declarator, specs_attrs, lookups, attributes;
- int initialized;
- {
- frob_specs (specs_attrs, lookups);
- return parse_decl (declarator, attributes, initialized);
- }
- extern tree pop_mp_local_vars (void);
- /* decl must be non-NULL, return true if this variable should be treated
- * as an OpenMP private variable
- */
- static bool
- Is_shared_mp_var (tree decl)
- {
- return TREE_CODE (decl) == VAR_DECL && DECL_CONTEXT (decl) &&
- TREE_CODE (DECL_CONTEXT (decl)) != NAMESPACE_DECL &&
- TREE_CODE (DECL_CONTEXT (decl)) != RECORD_TYPE &&
- !DECL_EXTERNAL (decl) && !DECL_WEAK (decl) &&
- !TREE_STATIC (decl);
- }
- static void
- parse_end_decl (decl, init, asmspec)
- tree decl, init, asmspec;
- {
- /* If decl is NULL_TREE, then this was a variable declaration using
- () syntax for the initializer, so we handled it in grokdeclarator. */
- if (decl)
- decl_type_access_control (decl);
- cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
- if (In_MP_Region && decl && Is_shared_mp_var (decl))
- mp_locals[mp_nesting] = chainon (mp_locals[mp_nesting],
- build_tree_list (NULL, decl));
- else if (In_MP_Region && !decl)
- {
- decl = pop_mp_local_vars ();
- /* This may introduce duplicate entries, some being introduced in the
- above if stmt also */
- while (decl)
- {
- if (Is_shared_mp_var (decl))
- mp_locals[mp_nesting] = chainon (mp_locals[mp_nesting],
- build_tree_list (NULL, decl));
- decl = pop_mp_local_vars ();
- }
- }
- }
- static tree
- parse_field (declarator, attributes, asmspec, init)
- tree declarator, attributes, asmspec, init;
- {
- tree d = grokfield (declarator, current_declspecs, init, asmspec,
- chainon (attributes, prefix_attributes));
- decl_type_access_control (d);
- return d;
- }
- static tree
- parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
- tree declarator, specs_attrs, lookups, attributes, asmspec, init;
- {
- frob_specs (specs_attrs, lookups);
- return parse_field (declarator, attributes, asmspec, init);
- }
- static tree
- parse_bitfield (declarator, attributes, width)
- tree declarator, attributes, width;
- {
- tree d = grokbitfield (declarator, current_declspecs, width);
- cplus_decl_attributes (&d, chainon (attributes, prefix_attributes), 0);
- decl_type_access_control (d);
- return d;
- }
- static tree
- parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
- tree declarator, specs_attrs, lookups, attributes, width;
- {
- frob_specs (specs_attrs, lookups);
- return parse_bitfield (declarator, attributes, width);
- }
- static tree
- parse_method (declarator, specs_attrs, lookups)
- tree declarator, specs_attrs, lookups;
- {
- tree d;
- frob_specs (specs_attrs, lookups);
- d = start_method (current_declspecs, declarator, prefix_attributes);
- decl_type_access_control (d);
- return d;
- }
- static void
- check_class_key (key, aggr)
- tree key;
- tree aggr;
- {
- if (TREE_CODE (key) == TREE_LIST)
- key = TREE_VALUE (key);
- if ((key == union_type_node) != (TREE_CODE (aggr) == UNION_TYPE))
- pedwarn ("`%s' tag used in naming `%#T'",
- key == union_type_node ? "union"
- : key == record_type_node ? "struct" : "class", aggr);
- }
- %}
- %start program
- %union { GTY(())
- long itype;
- tree ttype;
- char *strtype;
- enum tree_code code;
- flagged_type_tree ftype;
- struct unparsed_text *pi;
- enum reduction_op_type red_op_type;
- enum schedule_kind_type sch_k_type;
- struct parallel_clause_list * pclause_type;
- struct for_clause_list * for_clause_type;
- struct sections_clause_list * sections_clause_type;
- struct single_clause_list * single_clause_type;
- struct parallel_for_clause_list * parallel_for_clause_type;
- struct parallel_sections_clause_list * parallel_sections_clause_type;
- }
- /* All identifiers that are not reserved words
- and are not declared typedefs in the current block */
- %token IDENTIFIER
- /* All identifiers that are declared typedefs in the current block.
- In some contexts, they are treated just like IDENTIFIER,
- but they can also serve as typespecs in declarations. */
- %token tTYPENAME
- %token SELFNAME
- /* A template function. */
- %token PFUNCNAME
- /* Reserved words that specify storage class.
- yylval contains an IDENTIFIER_NODE which indicates which one. */
- %token SCSPEC
- /* Reserved words that specify type.
- yylval contains an IDENTIFIER_NODE which indicates which one. */
- %token TYPESPEC
- /* Reserved words that qualify type: "const" or "volatile".
- yylval contains an IDENTIFIER_NODE which indicates which one. */
- %token CV_QUALIFIER
- /* Character or numeric constants.
- yylval is the node for the constant. */
- %token CONSTANT
- /* __func__, __FUNCTION__ or __PRETTY_FUNCTION__.
- yylval contains an IDENTIFIER_NODE which indicates which one. */
- %token <ttype> VAR_FUNC_NAME
- /* String constants in raw form.
- yylval is a STRING_CST node. */
- %token STRING
- /* "...", used for functions with variable arglists. */
- %token ELLIPSIS
- %token OPTIONS_PRAGMA EXEC_FREQ_PRAGMA FREQ_NEVER FREQ_INIT FREQ_FREQUENT
- %token OMP_PRAGMA OMP_PARALLEL OMP_PRIVATE OMP_COPYPRIVATE
- %token OMP_FIRSTPRIVATE OMP_LASTPRIVATE OMP_SHARED OMP_DEFAULT OMP_NONE
- %token OMP_REDUCTION OMP_COPYIN OMP_DYNAMIC OMP_GUIDED OMP_RUNTIME
- %token OMP_ORDERED OMP_SCHEDULE OMP_NOWAIT OMP_NUM_THREADS OMP_SECTIONS
- %token OMP_SECTION OMP_SINGLE OMP_MASTER OMP_CRITICAL OMP_BARRIER
- %token OMP_ATOMIC OMP_FLUSH OMP_THREADPRIVATE
- %token <ttype> OMP_STATIC
- /* the reserved words */
- /* SCO include files test "ASM", so use something else. */
- %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
- %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
- %token SIGOF
- %token ATTRIBUTE EXTENSION LABEL
- %token REALPART IMAGPART VA_ARG
- /* the reserved words... C++ extensions */
- %token <ttype> AGGR
- %token <ttype> VISSPEC
- %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE OFFSETOF
- %token NAMESPACE TYPENAME_KEYWORD USING
- %token LEFT_RIGHT TEMPLATE
- %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
- %token SCOPE EXPORT
- /* Define the operator tokens and their precedences.
- The value is an integer because, if used, it is the tree code
- to use in the expression made from the operator. */
- %left EMPTY /* used to resolve s/r with epsilon */
- %left error
- /* Add precedence rules to solve dangling else s/r conflict */
- %nonassoc IF
- %nonassoc ELSE
- %left IDENTIFIER PFUNCNAME tTYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD ATTRIBUTE
- %left '{' ',' ';'
- %nonassoc THROW
- %right <code> ':'
- %right <code> ASSIGN '='
- %right <code> '?'
- %left <code> OROR
- %left <code> ANDAND
- %left <code> '|'
- %left <code> '^'
- %left <code> '&'
- %left <code> MIN_MAX
- %left <code> EQCOMPARE
- %left <code> ARITHCOMPARE '<' '>'
- %left <code> LSHIFT RSHIFT
- %left <code> '+' '-'
- %left <code> '*' '/' '%'
- %left <code> POINTSAT_STAR DOT_STAR
- %right <code> UNARY PLUSPLUS MINUSMINUS '~'
- %left HYPERUNARY
- %left <ttype> LEFT_RIGHT
- %left <code> POINTSAT '.' '(' '['
- %right SCOPE /* C++ extension */
- %nonassoc NEW DELETE TRY CATCH
- %type <code> unop
- %type <ttype> identifier IDENTIFIER tTYPENAME CONSTANT expr nonnull_exprlist
- %type <ttype> PFUNCNAME maybe_identifier
- %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
- %type <ttype> expr_no_commas expr_no_comma_rangle
- %type <ttype> cast_expr unary_expr primary STRING
- %type <ttype> reserved_declspecs boolean_literal
- %type <ttype> reserved_typespecquals
- %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
- %type <ttype> init initlist maybeasm maybe_init defarg defarg1
- %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
- %type <ttype> maybe_attribute attributes attribute attribute_list attrib
- %type <ttype> any_word unoperator
- %type <itype> save_lineno
- %type <ttype> simple_stmt simple_if
- %type <ttype> declarator notype_declarator after_type_declarator
- %type <ttype> notype_declarator_intern absdcl_intern
- %type <ttype> after_type_declarator_intern
- %type <ttype> direct_notype_declarator direct_after_type_declarator
- %type <itype> components notype_components
- %type <ttype> component_decl component_decl_1
- %type <ttype> component_declarator component_declarator0
- %type <ttype> notype_component_declarator notype_component_declarator0
- %type <ttype> after_type_component_declarator after_type_component_declarator0
- %type <ttype> absdcl cv_qualifiers
- %type <ttype> direct_abstract_declarator conversion_declarator
- %type <ttype> new_declarator direct_new_declarator
- %type <ttype> xexpr parmlist parms bad_parm
- %type <ttype> identifiers_or_typenames
- %type <ttype> fcast_or_absdcl regcast_or_absdcl
- %type <ttype> expr_or_declarator expr_or_declarator_intern
- %type <ttype> complex_notype_declarator
- %type <ttype> notype_unqualified_id unqualified_id qualified_id
- %type <ttype> template_id do_id object_template_id notype_template_declarator
- %type <ttype> overqualified_id notype_qualified_id any_id
- %type <ttype> complex_direct_notype_declarator functional_cast
- %type <ttype> complex_parmlist parms_comma
- %type <ttype> namespace_qualifier namespace_using_decl
- %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
- %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
- %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
- %type <ftype> declmods
- %type <itype> extension
- /* C++ extensions */
- %token <ttype> PTYPENAME
- %token <ttype> EXTERN_LANG_STRING ALL
- %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
- %token <pi> PRE_PARSED_FUNCTION_DECL
- %type <ttype> component_constructor_declarator
- %type <ttype> fn_def2 return_id constructor_declarator
- %type <ttype> begin_function_body_
- %type <ttype> class_head class_head_apparent_template
- %type <ftype> class_head_decl class_head_defn
- %type <ttype> base_class_list
- %type <ttype> base_class_access_list
- %type <ttype> base_class maybe_base_class_list base_class_1
- %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
- %type <ttype> operator_name
- %type <ttype> object aggr
- %type <itype> new delete
- /* %type <ttype> primary_no_id */
- %type <ttype> maybe_parmlist
- %type <ttype> begin_member_init member_init
- %type <ftype> member_init_list
- %type <ttype> template_parm_header template_spec_header template_header
- %type <ttype> template_parm_list template_parm
- %type <ttype> template_type_parm template_template_parm
- %type <code> template_close_bracket
- %type <ttype> apparent_template_type
- %type <ttype> template_type template_arg_list template_arg_list_opt
- %type <ttype> template_arg template_arg_1
- %type <ttype> condition xcond paren_cond_or_null
- %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
- %type <ttype> complete_type_name notype_identifier nonnested_type
- %type <ttype> complex_type_name nested_name_specifier_1
- %type <ttype> new_initializer new_placement
- %type <ttype> using_decl
- %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
- %type <ttype> explicit_template_type
- /* in order to recognize aggr tags as defining and thus shadowing. */
- %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
- %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
- %type <ttype> handler_args
- %type <ttype> self_template_type finish_template_type_
- %token NSNAME
- %type <ttype> NSNAME
- %type <ttype> options_directive exec_freq_directive exec_freq_directive_ignore
- %type <ttype> freq_hint
- /* OpenMP */
- %type <ttype> variable_list critical_directive region_phrase iteration_statement
- %type <red_op_type> reduction_operator
- %type <sch_k_type> schedule_kind
- %type <pclause_type> parallel_clause_list parallel_clause parallel_directive
- %type <ttype> openmp_construct parallel_construct for_construct sections_construct
- %type <ttype> single_construct parallel_for_construct parallel_sections_construct
- %type <ttype> master_construct critical_construct atomic_construct
- %type <ttype> ordered_construct
- %type <ttype> flush_directive
- %type <for_clause_type> for_clause_list for_clause for_directive
- %type <sections_clause_type> sections_clause_list sections_clause sections_directive
- %type <single_clause_type> single_clause single_clause_list single_directive
- %type <parallel_for_clause_type> parallel_for_clause parallel_for_clause_list parallel_for_directive
- %type <parallel_sections_clause_type> parallel_sections_clause parallel_sections_clause_list parallel_sections_directive
- /* SL2 FORK JOINT PRAGMA */
- %token SL2_SECTIONS SL2_MINOR_SECTIONS SL2_SECTION PRAGMA_SL2 SL2_MINOR_SECTION
- %type <ttype> sl2_sections_construct sl2_section_scope sl2_maybe_section_sequence
- %type <ttype> sl2_section_sequence sl2_maybe_structured_block sl2_section_construct
- /* Used in lex.c for parsing pragmas. */
- %token END_OF_LINE
- /* lex.c and pt.c depend on this being the last token. Define
- any new tokens before this one! */
- %token END_OF_SAVED_INPUT
- %{
- /* Tell yyparse how to print a token's value, if yydebug is set. */
- #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
- extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
- %}
- %%
- program:
- /* empty */
- { finish_translation_unit (); }
- | extdefs
- { finish_translation_unit (); }
- ;
- /* the reason for the strange actions in this rule
- is so that notype_initdecls when reached via datadef
- can find a valid list of type and sc specs in $0. */
- extdefs:
- { $<ttype>$ = NULL_TREE; }
- lang_extdef
- { $<ttype>$ = NULL_TREE; ggc_collect (); }
- | extdefs lang_extdef
- { $<ttype>$ = NULL_TREE; ggc_collect (); }
- ;
- extdefs_opt:
- extdefs
- | /* empty */
- ;
- .hush_warning:
- { have_extern_spec = true;
- $<ttype>$ = NULL_TREE; }
- ;
- .warning_ok:
- { have_extern_spec = false; }
- ;
- extension:
- EXTENSION
- { $$ = pedantic;
- pedantic = 0; }
- ;
- asm_keyword:
- ASM_KEYWORD
- ;
- lang_extdef:
- { if (pending_lang_change) do_pending_lang_change();
- type_lookups = NULL_TREE; }
- extdef
- { if (! toplevel_bindings_p ())
- pop_everything (); }
- ;
- extdef:
- fndef eat_saved_input
- { do_pending_inlines (); }
- | datadef
- { do_pending_inlines (); }
- | EXPORT
- { warning ("keyword `export' not implemented, and will be ignored"); }
- template_def
- { do_pending_inlines (); }
- | template_def
- { do_pending_inlines (); }
- | asm_keyword '(' STRING ')' ';'
- { assemble_asm ($3); }
- | extern_lang_string '{' extdefs_opt '}'
- { pop_lang_context (); }
- | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
- { do_pending_inlines (); pop_lang_context (); }
- | extern_lang_string .hush_warning datadef .warning_ok
- { do_pending_inlines (); pop_lang_context (); }
- | NAMESPACE identifier '{'
- { push_namespace ($2); }
- extdefs_opt '}'
- { pop_namespace (); }
- | NAMESPACE '{'
- { push_namespace (NULL_TREE); }
- extdefs_opt '}'
- { pop_namespace (); }
- | namespace_alias
- | using_decl ';'
- { do_toplevel_using_decl ($1); }
- | using_directive
- | extension extdef
- { pedantic = $1; }
- | threadprivate_directive
- | exec_freq_directive_ignore
- {}
- ;
- namespace_alias:
- NAMESPACE identifier '='
- { begin_only_namespace_names (); }
- any_id ';'
- {
- end_only_namespace_names ();
- if (lastiddecl)
- $5 = lastiddecl;
- do_namespace_alias ($2, $5);
- }
- ;
- using_decl:
- USING qualified_id
- { $$ = $2; }
- | USING global_scope qualified_id
- { $$ = $3; }
- | USING global_scope unqualified_id
- { $$ = $3; }
- ;
- namespace_using_decl:
- USING namespace_qualifier identifier
- { $$ = build_nt (SCOPE_REF, $2, $3); }
- | USING global_scope identifier
- { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
- | USING global_scope namespace_qualifier identifier
- { $$ = build_nt (SCOPE_REF, $3, $4); }
- ;
- using_directive:
- USING NAMESPACE
- { begin_only_namespace_names (); }
- any_id
- {
- end_only_namespace_names ();
- /* If no declaration was found, the using-directive is
- invalid. Since that was not reported, we need the
- identifier for the error message. */
- if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
- $4 = lastiddecl;
- do_using_directive ($4);
- }
- maybe_attribute ';' /* GNU 3.4 feature of namespace attributes */
- ;
- namespace_qualifier:
- NSNAME SCOPE
- {
- if (TREE_CODE ($$) == IDENTIFIER_NODE)
- $$ = lastiddecl;
- got_scope = $$;
- }
- | namespace_qualifier NSNAME SCOPE
- {
- $$ = $2;
- if (TREE_CODE ($$) == IDENTIFIER_NODE)
- $$ = lastiddecl;
- got_scope = $$;
- }
- ;
- any_id:
- unqualified_id
- | qualified_id
- | global_scope qualified_id
- { $$ = $2; }
- | global_scope unqualified_id
- { $$ = $2; }
- ;
- extern_lang_string:
- EXTERN_LANG_STRING
- { push_lang_context ($1); }
- | extern_lang_string EXTERN_LANG_STRING
- { if (current_lang_name != $2)
- error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
- pop_lang_context (); push_lang_context ($2); }
- ;
- template_parm_header:
- TEMPLATE '<'
- { begin_template_parm_list (); }
- template_parm_list '>'
- { $$ = end_template_parm_list ($4); }
- ;
- template_spec_header:
- TEMPLATE '<' '>'
- { begin_specialization();
- $$ = NULL_TREE; }
- ;
- template_header:
- template_parm_header
- | template_spec_header
- ;
- template_parm_list:
- template_parm
- { $$ = process_template_parm (NULL_TREE, $1); }
- | template_parm_list ',' template_parm
- { $$ = process_template_parm ($1, $3); }
- ;
- maybe_identifier:
- identifier
- { $$ = $1; }
- | /* empty */
- { $$ = NULL_TREE; }
- ;
- template_type_parm:
- aggr maybe_identifier
- { $$ = finish_template_type_parm ($1, $2); }
- | TYPENAME_KEYWORD maybe_identifier
- { $$ = finish_template_type_parm (class_type_node, $2); }
- ;
- template_template_parm:
- template_parm_header aggr maybe_identifier
- { $$ = finish_template_template_parm ($2, $3); }
- ;
- template_parm:
- /* The following rules introduce a new reduce/reduce
- conflict on the ',' and '>' input tokens: they are valid
- prefixes for a `structsp', which means they could match a
- nameless parameter. See 14.6, paragraph 3.
- By putting them before the `parm' rule, we get
- their match before considering them nameless parameter
- declarations. */
- template_type_parm
- { $$ = build_tree_list (NULL_TREE, $1); }
- | template_type_parm '=' type_id
- { $$ = build_tree_list (groktypename ($3.t), $1); }
- | parm
- { $$ = build_tree_list (NULL_TREE, $1.t); }
- | parm '=' expr_no_comma_rangle
- { $$ = build_tree_list ($3, $1.t); }
- | template_template_parm
- { $$ = build_tree_list (NULL_TREE, $1); }
- | template_template_parm '=' template_arg
- {
- $3 = check_template_template_default_arg ($3);
- $$ = build_tree_list ($3, $1);
- }
- ;
- template_def:
- template_header template_extdef
- { finish_template_decl ($1); }
- | template_header error %prec EMPTY
- { finish_template_decl ($1); }
- ;
- template_extdef:
- fndef eat_saved_input
- { do_pending_inlines (); }
- | template_datadef
- { do_pending_inlines (); }
- | template_def
- { do_pending_inlines (); }
- | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
- { do_pending_inlines ();
- pop_lang_context (); }
- | extern_lang_string .hush_warning template_datadef .warning_ok
- { do_pending_inlines ();
- pop_lang_context (); }
- | extension template_extdef
- { pedantic = $1; }
- ;
- template_datadef:
- nomods_initdecls ';'
- | declmods notype_initdecls ';'
- {}
- | typed_declspecs initdecls ';'
- { note_list_got_semicolon ($1.t); }
- | structsp ';'
- {
- if ($1.t != error_mark_node)
- {
- maybe_process_partial_specialization ($1.t);
- note_got_semicolon ($1.t);
- }
- }
- ;
- datadef:
- nomods_initdecls ';'
- | declmods notype_initdecls ';'
- {}
- | typed_declspecs initdecls ';'
- { note_list_got_semicolon ($1.t); }
- | declmods ';'
- { pedwarn ("empty declaration"); }
- | explicit_instantiation ';'
- | typed_declspecs ';'
- {
- tree t, attrs;
- split_specs_attrs ($1.t, &t, &attrs);
- shadow_tag (t);
- note_list_got_semicolon ($1.t);
- }
- | error ';'
- | error '}'
- | error END_OF_SAVED_INPUT
- { end_input (); }
- | ';'
- | bad_decl
- ;
- ctor_initializer_opt:
- nodecls
- | base_init
- ;
- maybe_return_init:
- /* empty */
- | return_init
- | return_init ';'
- ;
- eat_saved_input:
- /* empty */
- | END_OF_SAVED_INPUT
- ;
- /* The outermost block of a function really begins before the
- mem-initializer-list, so we open one there and suppress the one that
- actually corresponds to the curly braces. */
- function_body:
- begin_function_body_ ctor_initializer_opt save_lineno '{'
- { $<ttype>$ = begin_compound_stmt (/*has_no_scope=*/1); }
- compstmtend
- {
- STMT_LINENO ($<ttype>5) = $3;
- finish_compound_stmt (/*has_no_scope=*/1, $<ttype>5);
- finish_function_body ($1);
- }
- ;
- fndef:
- fn.def1 maybe_return_init function_body
- { expand_body (finish_function (0)); }
- | fn.def1 maybe_return_init function_try_block
- { expand_body (finish_function (0)); }
- | fn.def1 maybe_return_init error
- { }
- ;
- constructor_declarator:
- nested_name_specifier SELFNAME '('
- { $<ttype>$ = begin_constructor_declarator ($1, $2); }
- parmlist ')' cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
- | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
- { $$ = begin_constructor_declarator ($1, $2);
- $$ = make_call_declarator ($$, empty_parms (), $4, $5);
- }
- | global_scope nested_name_specifier SELFNAME '('
- { $<ttype>$ = begin_constructor_declarator ($2, $3); }
- parmlist ')' cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
- | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
- { $$ = begin_constructor_declarator ($2, $3);
- $$ = make_call_declarator ($$, empty_parms (), $5, $6);
- }
- | nested_name_specifier self_template_type '('
- { $<ttype>$ = begin_constructor_declarator ($1, $2); }
- parmlist ')' cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
- | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
- { $$ = begin_constructor_declarator ($1, $2);
- $$ = make_call_declarator ($$, empty_parms (), $4, $5);
- }
- | global_scope nested_name_specifier self_template_type '('
- { $<ttype>$ = begin_constructor_declarator ($2, $3); }
- parmlist ')' cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
- | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
- { $$ = begin_constructor_declarator ($2, $3);
- $$ = make_call_declarator ($$, empty_parms (), $5, $6);
- }
- ;
- fn.def1:
- typed_declspecs declarator
- { check_for_new_type ("return type", $1);
- if (!parse_begin_function_definition ($1.t, $2))
- YYERROR1; }
- | declmods notype_declarator
- { if (!parse_begin_function_definition ($1.t, $2))
- YYERROR1; }
- | notype_declarator
- { if (!parse_begin_function_definition (NULL_TREE, $1))
- YYERROR1; }
- | declmods constructor_declarator
- { if (!parse_begin_function_definition ($1.t, $2))
- YYERROR1; }
- | constructor_declarator
- { if (!parse_begin_function_definition (NULL_TREE, $1))
- YYERROR1; }
- ;
- /* ANSI allows optional parentheses around constructor class names.
- See ISO/IEC 14882:1998(E) 12.1. */
- component_constructor_declarator:
- SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($1, $3, $5, $6); }
- | '(' SELFNAME ')' '(' parmlist ')' cv_qualifiers
- exception_specification_opt
- { $$ = make_call_declarator ($2, $5, $7, $8); }
- | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
- | '(' SELFNAME ')' LEFT_RIGHT cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($2, empty_parms (), $5, $6); }
- | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($1, $3, $5, $6); }
- | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
- ;
- /* more C++ complexity. See component_decl for a comment on the
- reduce/reduce conflict introduced by these rules. */
- fn_def2:
- declmods component_constructor_declarator
- { $$ = parse_method ($2, $1.t, $1.lookups);
- rest_of_mdef:
- if (! $$)
- YYERROR1;
- if (yychar == YYEMPTY)
- yychar = YYLEX;
- snarf_method ($$); }
- | component_constructor_declarator
- { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
- goto rest_of_mdef; }
- | typed_declspecs declarator
- { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
- | declmods notype_declarator
- { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
- | notype_declarator
- { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
- goto rest_of_mdef; }
- | declmods constructor_declarator
- { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
- | constructor_declarator
- { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
- goto rest_of_mdef; }
- ;
- return_id:
- RETURN_KEYWORD IDENTIFIER
- {
- $$ = $2;
- }
- ;
- return_init:
- return_id maybe_init
- { finish_named_return_value ($<ttype>$, $2); }
- | return_id '(' nonnull_exprlist ')'
- { finish_named_return_value ($<ttype>$, $3); }
- | return_id LEFT_RIGHT
- { finish_named_return_value ($<ttype>$, NULL_TREE); }
- ;
- base_init:
- ':' { begin_mem_initializers (); } member_init_list
- {
- if ($3.new_type_flag == 0)
- error ("no base or member initializers given following ':'");
- finish_mem_initializers ($3.t);
- }
- ;
- begin_function_body_:
- /* empty */
- {
- $$ = begin_function_body ();
- }
- ;
- member_init_list:
- /* empty */
- {
- $$.new_type_flag = 0;
- $$.t = NULL_TREE;
- }
- | member_init
- {
- $$.new_type_flag = 1;
- $$.t = $1;
- }
- | member_init_list ',' member_init
- {
- if ($3)
- {
- $$.new_type_flag = 1;
- TREE_CHAIN ($3) = $1.t;
- $$.t = $3;
- }
- else
- $$ = $1;
- }
- | member_init_list error
- ;
- begin_member_init:
- /* empty */
- {
- if (current_class_name)
- pedwarn ("anachronistic old style base class initializer");
- $$ = expand_member_init (NULL_TREE);
- in_base_initializer = $$ && !DECL_P ($$);
- }
- | notype_identifier
- { $$ = expand_member_init ($1);
- in_base_initializer = $$ && !DECL_P ($$); }
- | nonnested_type
- { $$ = expand_member_init ($1);
- in_base_initializer = $$ && !DECL_P ($$); }
- | typename_sub
- { $$ = expand_member_init ($1);
- in_base_initializer = $$ && !DECL_P ($$); }
- ;
- member_init:
- begin_member_init '(' nonnull_exprlist ')'
- { in_base_initializer = 0;
- $$ = $1 ? build_tree_list ($1, $3) : NULL_TREE; }
- | begin_member_init LEFT_RIGHT
- { in_base_initializer = 0;
- $$ = $1 ? build_tree_list ($1, void_type_node) : NULL_TREE; }
- | error
- { in_base_initializer = 0;
- $$ = NULL_TREE; }
- ;
- identifier:
- IDENTIFIER
- | tTYPENAME
- | SELFNAME
- | PTYPENAME
- | NSNAME
- ;
- notype_identifier:
- IDENTIFIER
- | PTYPENAME
- | NSNAME %prec EMPTY
- ;
- identifier_defn:
- IDENTIFIER_DEFN
- | TYPENAME_DEFN
- | PTYPENAME_DEFN
- ;
- explicit_instantiation:
- TEMPLATE begin_explicit_instantiation typespec ';'
- { do_type_instantiation ($3.t, NULL_TREE, 1);
- yyungetc (';', 1); }
- end_explicit_instantiation
- | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
- { tree specs = strip_attrs ($3.t);
- parse_decl_instantiation (specs, $4, NULL_TREE); }
- end_explicit_instantiation
- | TEMPLATE begin_explicit_instantiation notype_declarator
- { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
- end_explicit_instantiation
- | TEMPLATE begin_explicit_instantiation constructor_declarator
- { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
- end_explicit_instantiation
- | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
- { do_type_instantiation ($4.t, $1, 1);
- yyungetc (';', 1); }
- end_explicit_instantiation
- {}
- | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
- declarator
- { tree specs = strip_attrs ($4.t);
- parse_decl_instantiation (specs, $5, $1); }
- end_explicit_instantiation
- {}
- | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
- { parse_decl_instantiation (NULL_TREE, $4, $1); }
- end_explicit_instantiation
- {}
- | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
- { parse_decl_instantiation (NULL_TREE, $4, $1); }
- end_explicit_instantiation
- {}
- ;
- begin_explicit_instantiation:
- { begin_explicit_instantiation(); }
- ;
- end_explicit_instantiation:
- { end_explicit_instantiation(); }
- ;
- /* The TYPENAME expansions are to deal with use of a template class name as
- a template within the class itself, where the template decl is hidden by
- a type decl. Got all that? */
- template_type:
- PTYPENAME '<' template_arg_list_opt template_close_bracket
- finish_template_type_
- { $$ = $5; }
- | tTYPENAME '<' template_arg_list_opt template_close_bracket
- finish_template_type_
- { $$ = $5; }
- | self_template_type
- ;
- apparent_template_type:
- template_type
- | identifier '<' template_arg_list_opt '>'
- finish_template_type_
- { $$ = $5; }
- ;
- self_template_type:
- SELFNAME '<' template_arg_list_opt template_close_bracket
- finish_template_type_
- { $$ = $5; }
- ;
- finish_template_type_:
- {
- if (yychar == YYEMPTY)
- yychar = YYLEX;
- $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
- yychar == SCOPE);
- }
- ;
- template_close_bracket:
- '>'
- | RSHIFT
- {
- /* Handle `Class<Class<Type>>' without space in the `>>' */
- pedwarn ("`>>' should be `> >' in template class name");
- yyungetc ('>', 1);
- }
- ;
- template_arg_list_opt:
- /* empty */
- { $$ = NULL_TREE; }
- | template_arg_list
- ;
- template_arg_list:
- template_arg
- { $$ = build_tree_list (NULL_TREE, $$); }
- | template_arg_list ',' template_arg
- { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
- ;
- template_arg:
- { ++class_template_ok_as_expr; }
- template_arg_1
- {
- --class_template_ok_as_expr;
- $$ = $2;
- }
- ;
- template_arg_1:
- type_id
- { $$ = groktypename ($1.t); }
- | PTYPENAME
- {
- $$ = lastiddecl;
- if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
- $$ = TREE_TYPE ($$);
- }
- | global_scope PTYPENAME
- {
- $$ = lastiddecl;
- if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
- $$ = TREE_TYPE ($$);
- }
- | expr_no_comma_rangle
- | nested_name_specifier TEMPLATE identifier
- {
- if (!processing_template_decl)
- {
- error ("use of template qualifier outside template");
- $$ = error_mark_node;
- }
- else
- $$ = make_unbound_class_template ($1, $3, tf_error | tf_parsing);
- }
- ;
- unop:
- '-'
- { $$ = NEGATE_EXPR; }
- | '+'
- { $$ = CONVERT_EXPR; }
- | PLUSPLUS
- { $$ = PREINCREMENT_EXPR; }
- | MINUSMINUS
- { $$ = PREDECREMENT_EXPR; }
- | '!'
- { $$ = TRUTH_NOT_EXPR; }
- ;
- expr:
- nontrivial_exprlist
- { $$ = build_x_compound_expr ($$); }
- | expr_no_commas
- ;
- paren_expr_or_null:
- LEFT_RIGHT
- { error ("ISO C++ forbids an empty condition for `%s'",
- cond_stmt_keyword);
- $$ = integer_zero_node; }
- | '(' expr ')'
- { $$ = $2; }
- ;
- paren_cond_or_null:
- LEFT_RIGHT
- { error ("ISO C++ forbids an empty condition for `%s'",
- cond_stmt_keyword);
- $$ = integer_zero_node; }
- | '(' condition ')'
- { $$ = $2; }
- ;
- xcond:
- /* empty */
- { $$ = NULL_TREE; }
- | condition
- | error
- { $$ = NULL_TREE; }
- ;
- condition:
- type_specifier_seq declarator maybeasm maybe_attribute '='
- { {
- tree d;
- for (d = getdecls (); d; d = TREE_CHAIN (d))
- if (TREE_CODE (d) == TYPE_DECL) {
- tree s = TREE_TYPE (d);
- if (TREE_CODE (s) == RECORD_TYPE)
- error ("definition of class `%T' in condition", s);
- else if (TREE_CODE (s) == ENUMERAL_TYPE)
- error ("definition of enum `%T' in condition", s);
- }
- }
- current_declspecs = $1.t;
- $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
- }
- init
- {
- parse_end_decl ($<ttype>6, $7, $4);
- $$ = convert_from_reference ($<ttype>6);
- if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
- error ("definition of array `%#D' in condition", $$);
- }
- | expr
- ;
- compstmtend:
- '}'
- | maybe_label_decls stmts '}'
- | maybe_label_decls stmts error '}'
- | maybe_label_decls error '}'
- ;
- nontrivial_exprlist:
- expr_no_commas ',' expr_no_commas
- { $$ = tree_cons (NULL_TREE, $$,
- build_tree_list (NULL_TREE, $3)); }
- | expr_no_commas ',' error
- { $$ = tree_cons (NULL_TREE, $$,
- build_tree_list (NULL_TREE, error_mark_node)); }
- | nontrivial_exprlist ',' expr_no_commas
- { chainon ($$, build_tree_list (NULL_TREE, $3)); }
- | nontrivial_exprlist ',' error
- { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
- ;
- nonnull_exprlist:
- expr_no_commas
- { $$ = build_tree_list (NULL_TREE, $$); }
- | nontrivial_exprlist
- ;
- unary_expr:
- primary %prec UNARY
- { $$ = $1; }
- /* __extension__ turns off -pedantic for following primary. */
- | extension cast_expr %prec UNARY
- { $$ = $2;
- pedantic = $1; }
- | '*' cast_expr %prec UNARY
- { $$ = build_x_indirect_ref ($2, "unary *"); }
- | '&' cast_expr %prec UNARY
- { $$ = build_x_unary_op (ADDR_EXPR, $2); }
- | '~' cast_expr
- { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
- | unop cast_expr %prec UNARY
- { $$ = finish_unary_op_expr ($1, $2); }
- /* Refer to the address of a label as a pointer. */
- | ANDAND identifier
- { $$ = finish_label_address_expr ($2); }
- | sizeof unary_expr %prec UNARY
- { $$ = finish_sizeof ($2);
- skip_evaluation--; }
- | sizeof '(' type_id ')' %prec HYPERUNARY
- { $$ = finish_sizeof (groktypename ($3.t));
- check_for_new_type ("sizeof", $3);
- skip_evaluation--; }
- | alignof unary_expr %prec UNARY
- { $$ = finish_alignof ($2);
- skip_evaluation--; }
- | alignof '(' type_id ')' %prec HYPERUNARY
- { $$ = finish_alignof (groktypename ($3.t));
- check_for_new_type ("alignof", $3);
- skip_evaluation--; }
- /* The %prec EMPTY's here are required by the = init initializer
- syntax extension; see below. */
- | new new_type_id %prec EMPTY
- { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
- check_for_new_type ("new", $2); }
- | new new_type_id new_initializer
- { $$ = build_new (NULL_TREE, $2.t, $3, $1);
- check_for_new_type ("new", $2); }
- | new new_placement new_type_id %prec EMPTY
- { $$ = build_new ($2, $3.t, NULL_TREE, $1);
- check_for_new_type ("new", $3); }
- | new new_placement new_type_id new_initializer
- { $$ = build_new ($2, $3.t, $4, $1);
- check_for_new_type ("new", $3); }
- | new '(' type_id ')'
- %prec EMPTY
- { $$ = build_new (NULL_TREE, groktypename($3.t),
- NULL_TREE, $1);
- check_for_new_type ("new", $3); }
- | new '(' type_id ')' new_initializer
- { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
- check_for_new_type ("new", $3); }
- | new new_placement '(' type_id ')' %prec EMPTY
- { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
- check_for_new_type ("new", $4); }
- | new new_placement '(' type_id ')' new_initializer
- { $$ = build_new ($2, groktypename($4.t), $6, $1);
- check_for_new_type ("new", $4); }
- | delete cast_expr %prec UNARY
- { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
- | delete '[' ']' cast_expr %prec UNARY
- { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
- if (yychar == YYEMPTY)
- yychar = YYLEX; }
- | delete '[' expr ']' cast_expr %prec UNARY
- { $$ = delete_sanity ($5, $3, 2, $1);
- if (yychar == YYEMPTY)
- yychar = YYLEX; }
- | REALPART cast_expr %prec UNARY
- { $$ = build_x_unary_op (REALPART_EXPR, $2); }
- | IMAGPART cast_expr %prec UNARY
- { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
- ;
- new_placement:
- '(' nonnull_exprlist ')'
- { $$ = $2; }
- | '{' nonnull_exprlist '}'
- { pedwarn ("old style placement syntax, use () instead");
- $$ = $2; }
- ;
- new_initializer:
- '(' nonnull_exprlist ')'
- { $$ = $2; }
- | LEFT_RIGHT
- { $$ = void_zero_node; }
- | '(' typespec ')'
- {
- error ("`%T' is not a valid expression", $2.t);
- $$ = error_mark_node;
- }
- | '=' init
- {
- /* This was previously allowed as an extension, but
- was removed in G++ 3.3. */
- error ("initialization of new expression with `='");
- $$ = error_mark_node;
- }
- ;
- /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
- regcast_or_absdcl:
- '(' type_id ')' %prec EMPTY
- { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
- $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
- check_for_new_type ("cast", $2); }
- | regcast_or_absdcl '(' type_id ')' %prec EMPTY
- { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
- $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
- check_for_new_type ("cast", $3); }
- ;
- cast_expr:
- unary_expr
- | regcast_or_absdcl unary_expr %prec UNARY
- { $$ = reparse_absdcl_as_casts ($$, $2); }
- | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
- {
- tree init = build_nt (CONSTRUCTOR, NULL_TREE,
- nreverse ($3));
- if (pedantic)
- pedwarn ("ISO C++ forbids compound literals");
- /* Indicate that this was a C99 compound literal. */
- TREE_HAS_CONSTRUCTOR (init) = 1;
- $$ = reparse_absdcl_as_casts ($$, init);
- }
- ;
- expr_no_commas:
- cast_expr
- /* Handle general members. */
- | expr_no_commas POINTSAT_STAR expr_no_commas
- { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
- | expr_no_commas DOT_STAR expr_no_commas
- { $$ = build_m_component_ref ($$, $3); }
- | expr_no_commas '+' expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas '-' expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas '*' expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas '/' expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas '%' expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas LSHIFT expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas RSHIFT expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas ARITHCOMPARE expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas '<' expr_no_commas
- { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
- | expr_no_commas '>' expr_no_commas
- { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
- | expr_no_commas EQCOMPARE expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas MIN_MAX expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas '&' expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas '|' expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas '^' expr_no_commas
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_commas ANDAND expr_no_commas
- { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
- | expr_no_commas OROR expr_no_commas
- { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
- | expr_no_commas '?' xexpr ':' expr_no_commas
- { $$ = build_x_conditional_expr ($$, $3, $5); }
- | expr_no_commas '=' expr_no_commas
- { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
- if ($$ != error_mark_node)
- C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
- | expr_no_commas ASSIGN expr_no_commas
- { $$ = build_x_modify_expr ($$, $2, $3); }
- | THROW
- { $$ = build_throw (NULL_TREE); }
- | THROW expr_no_commas
- { $$ = build_throw ($2); }
- ;
- expr_no_comma_rangle:
- cast_expr
- /* Handle general members. */
- | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
- { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
- | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
- { $$ = build_m_component_ref ($$, $3); }
- | expr_no_comma_rangle '+' expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle '-' expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle '*' expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle '/' expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle '%' expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle '<' expr_no_comma_rangle
- { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
- | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle '&' expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle '|' expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle '^' expr_no_comma_rangle
- { $$ = build_x_binary_op ($2, $$, $3); }
- | expr_no_comma_rangle ANDAND expr_no_comma_rangle
- { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
- | expr_no_comma_rangle OROR expr_no_comma_rangle
- { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
- | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
- { $$ = build_x_conditional_expr ($$, $3, $5); }
- | expr_no_comma_rangle '=' expr_no_comma_rangle
- { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
- if ($$ != error_mark_node)
- C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
- | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
- { $$ = build_x_modify_expr ($$, $2, $3); }
- | THROW
- { $$ = build_throw (NULL_TREE); }
- | THROW expr_no_comma_rangle
- { $$ = build_throw ($2); }
- ;
- notype_unqualified_id:
- '~' see_typename identifier
- { $$ = build_nt (BIT_NOT_EXPR, $3); }
- | '~' see_typename template_type
- { $$ = build_nt (BIT_NOT_EXPR, $3); }
- | template_id
- | operator_name
- | IDENTIFIER
- | PTYPENAME
- | NSNAME %prec EMPTY
- ;
- do_id:
- {
- /* If lastiddecl is a BASELINK we're in an
- expression like S::f<int>, so don't
- do_identifier; we only do that for unqualified
- identifiers. */
- if (!lastiddecl || !BASELINK_P (lastiddecl))
- $$ = do_identifier ($<ttype>-1, 3, NULL_TREE);
- else
- $$ = $<ttype>-1;
- }
- ;
- template_id:
- PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
- …
Large files files are truncated, but you can click here to view the full file