/opensource.apple.com/source/gcc_legacy/gcc_legacy-938/gcc/cp/parse.y
Happy | 2076 lines | 1872 code | 204 blank | 0 comment | 0 complexity | 94b25433a210e1805fcce9ac3c471821 MD5 | raw file
Possible License(s): LGPL-2.0, MPL-2.0, GPL-2.0, ISC, LGPL-2.1, Apache-2.0, MPL-2.0-no-copyleft-exception, BSD-3-Clause, WTFPL, MIT, AGPL-1.0, AGPL-3.0
Large files files are truncated, but you can click here to view the full file
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>parse.y</title>
- <style type="text/css">
- .enscript-comment { font-style: italic; color: rgb(178,34,34); }
- .enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
- .enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
- .enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
- .enscript-reference { font-weight: bold; color: rgb(95,158,160); }
- .enscript-string { font-weight: bold; color: rgb(188,143,143); }
- .enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
- .enscript-type { font-weight: bold; color: rgb(34,139,34); }
- .enscript-highlight { text-decoration: underline; color: 0; }
- </style>
- </head>
- <body id="top">
- <h1 style="margin:8px;" id="f1">parse.y <span style="font-weight: normal; font-size: 0.5em;">[<a href="?txt">plain text</a>]</span></h1>
- <hr/>
- <div></div>
- <pre>
- /* YACC parser for C++ syntax.
- Copyright (C) 1988, 89, 93-98, 1999 Free Software Foundation, Inc.
- Hacked by Michael Tiemann (<a href="mailto:tiemann@cygnus.com">tiemann@cygnus.com</a>)
- 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. */
- %{
- /* Cause the `yydebug' variable to be defined. */
- #define YYDEBUG 1
- #include "config.h"
- #include "system.h"
- #include "tree.h"
- #include "input.h"
- #include "flags.h"
- #include "lex.h"
- #include "cp-tree.h"
- #include "output.h"
- #include "except.h"
- #include "toplev.h"
- /* Since parsers are distinct for each language, put the language string
- definition here. (fnf) */
- char *language_string = "GNU C++";
- extern tree void_list_node;
- extern struct obstack permanent_obstack;
- extern int end_of_file;
- /* Like YYERROR but do call yyerror. */
- #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
- #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;
- static tree empty_parms PROTO((void));
- static int parse_decl PROTO((tree, tree, tree, int, tree *));
- /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
- int have_extern_spec;
- int used_extern_spec;
- /* Cons up an empty parameter list. */
- #ifdef __GNUC__
- __inline
- #endif
- static tree
- empty_parms ()
- {
- tree parms;
- if (strict_prototype
- || current_class_type != NULL)
- parms = void_list_node;
- else
- parms = NULL_TREE;
- return parms;
- }
- %}
- %start program
- %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
- /* 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 TYPENAME
- %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
- /* String constants in raw form.
- yylval is a STRING_CST node. */
- %token STRING
- /* "...", used for functions with variable arglists. */
- %token ELLIPSIS
- /* 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
- %token VEC_STEP
- /* the reserved words... C++ extensions */
- %token <ttype> AGGR
- %token <ttype> VISSPEC
- %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
- %token NAMESPACE TYPENAME_KEYWORD USING
- %token LEFT_RIGHT TEMPLATE
- %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
- %token <itype> SCOPE
- /* 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 TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
- %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> PAREN_STAR_PAREN LEFT_RIGHT
- %left <code> POINTSAT '.' '(' '['
- %right SCOPE /* C++ extension */
- %nonassoc NEW DELETE TRY CATCH
- %type <code> unop
- %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
- %type <ttype> PFUNCNAME maybe_identifier
- %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
- %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
- %type <ttype> reserved_declspecs boolean.literal
- %type <ttype> reserved_typespecquals
- %type <ttype> declmods
- %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
- %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
- %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
- %type <ttype> compstmt implicitly_scoped_stmt
- %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> enumlist enumerator
- %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
- /* C++ extensions */
- %token <ttype> PTYPENAME
- %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
- %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
- %type <ttype> component_constructor_declarator
- %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
- %type <itype> ctor_initializer_opt function_try_block
- %type <ttype> named_class_head_sans_basetype
- %type <ftype> class_head named_class_head
- %type <ftype> named_complex_class_head_sans_basetype
- %type <ttype> unnamed_class_head
- %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 .begin_new_placement
- /* %type <ttype> primary_no_id */
- %type <ttype> nonmomentary_expr maybe_parmlist
- %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
- %type <ttype> template_header 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
- %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> named_class_head_sans_basetype_defn
- %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
- %type <ttype> self_template_type .finish_template_type
- %token NSNAME
- %type <ttype> NSNAME
- /* 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
- %{
- /* List of types and structure classes of the current declaration. */
- static 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 tree prefix_attributes;
- /* When defining an aggregate, this is the kind of the most recent one
- being defined. (For example, this might be class_type_node.) */
- tree current_aggr;
- /* When defining an enumeration, this is the type of the enumeration. */
- static tree current_enum_type;
- /* 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 PROTO((FILE *, int, YYSTYPE));
- extern tree combine_strings PROTO((tree));
- static int
- parse_decl(declarator, specs_attrs, attributes, initialized, decl)
- tree declarator;
- tree specs_attrs;
- tree attributes;
- int initialized;
- tree* decl;
- {
- int sm;
- split_specs_attrs (specs_attrs, &current_declspecs, &prefix_attributes);
- if (current_declspecs
- && TREE_CODE (current_declspecs) != TREE_LIST)
- current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
- if (have_extern_spec && !used_extern_spec)
- {
- current_declspecs = decl_tree_cons (NULL_TREE,
- get_identifier ("extern"),
- current_declspecs);
- used_extern_spec = 1;
- }
- sm = suspend_momentary ();
- *decl = start_decl (declarator, current_declspecs, initialized,
- attributes, prefix_attributes);
- return sm;
- }
- %}
- %%
- program:
- /* empty */
- | 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; }
- | extdefs lang_extdef
- { $<ttype>$ = NULL_TREE; }
- ;
- extdefs_opt:
- extdefs
- | /* empty */
- ;
- .hush_warning:
- { have_extern_spec = 1;
- used_extern_spec = 0;
- $<ttype>$ = NULL_TREE; }
- ;
- .warning_ok:
- { have_extern_spec = 0; }
- ;
- extension:
- EXTENSION
- { $<itype>$ = pedantic;
- pedantic = 0; }
- ;
- asm_keyword:
- ASM_KEYWORD
- ;
- lang_extdef:
- { if (pending_lang_change) do_pending_lang_change(); }
- extdef
- { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
- pop_everything (); }
- ;
- extdef:
- fndef eat_saved_input
- { if (pending_inlines) do_pending_inlines (); }
- | datadef
- { if (pending_inlines) do_pending_inlines (); }
- | template_def
- { if (pending_inlines) do_pending_inlines (); }
- | asm_keyword '(' string ')' ';'
- { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
- assemble_asm ($3); }
- | extern_lang_string '{' extdefs_opt '}'
- { pop_lang_context (); }
- | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
- { if (pending_inlines) do_pending_inlines ();
- pop_lang_context (); }
- | extern_lang_string .hush_warning datadef .warning_ok
- { if (pending_inlines) 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 = $<itype>1; }
- ;
- 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_parse_node (SCOPE_REF, $2, $3); }
- | USING global_scope identifier
- { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
- | USING global_scope namespace_qualifier identifier
- { $$ = build_parse_node (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);
- }
- ;
- 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)
- cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
- pop_lang_context (); push_lang_context ($2); }
- ;
- template_header:
- TEMPLATE '<'
- { begin_template_parm_list (); }
- template_parm_list '>'
- { $$ = end_template_parm_list ($4); }
- | TEMPLATE '<' '>'
- { begin_specialization();
- $$ = NULL_TREE; }
- ;
- 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_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_commas %prec ARITHCOMPARE
- { $$ = build_tree_list ($3, $1.t); }
- | template_template_parm
- { $$ = build_tree_list (NULL_TREE, $1); }
- | template_template_parm '=' template_arg
- {
- if (TREE_CODE ($3) != TEMPLATE_DECL
- && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
- && TREE_CODE ($3) != TYPE_DECL)
- {
- error ("invalid default template argument");
- $3 = error_mark_node;
- }
- $$ = 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
- { if (pending_inlines) do_pending_inlines (); }
- | template_datadef
- { if (pending_inlines) do_pending_inlines (); }
- | template_def
- { if (pending_inlines) do_pending_inlines (); }
- | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
- { if (pending_inlines) do_pending_inlines ();
- pop_lang_context (); }
- | extern_lang_string .hush_warning template_datadef .warning_ok
- { if (pending_inlines) do_pending_inlines ();
- pop_lang_context (); }
- | extension template_extdef
- { pedantic = $<itype>1; }
- ;
- template_datadef:
- nomods_initdecls ';'
- | declmods notype_initdecls ';'
- {}
- | typed_declspecs initdecls ';'
- { note_list_got_semicolon ($1.t); }
- | structsp ';'
- { 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 '}'
- | ';'
- ;
- ctor_initializer_opt:
- nodecls
- { $$ = 0; }
- | base_init
- { $$ = 1; }
- ;
- maybe_return_init:
- /* empty */
- | return_init
- | return_init ';'
- ;
- eat_saved_input:
- /* empty */
- | END_OF_SAVED_INPUT
- ;
- fndef:
- fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
- { finish_function (lineno, (int)$3, 0); }
- | fn.def1 maybe_return_init function_try_block
- {
- int nested = (hack_decl_function_context
- (current_function_decl) != NULL_TREE);
- finish_function (lineno, (int)$3, nested);
- }
- | fn.def1 maybe_return_init error
- { }
- ;
- constructor_declarator:
- nested_name_specifier SELFNAME '('
- { $$ = 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 '('
- { $$ = 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 '('
- { $$ = 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 '('
- { $$ = 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
- { if (!begin_function_definition ($1.t, $2))
- YYERROR1; }
- | declmods notype_declarator
- { if (!begin_function_definition ($1, $2))
- YYERROR1; }
- | notype_declarator
- { if (!begin_function_definition (NULL_TREE, $1))
- YYERROR1; }
- | declmods constructor_declarator
- { if (!begin_function_definition ($1, $2))
- YYERROR1; }
- | constructor_declarator
- { if (!begin_function_definition (NULL_TREE, $1))
- YYERROR1; }
- ;
- component_constructor_declarator:
- SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($1, $3, $5, $6); }
- | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
- { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
- | 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
- { tree specs, attrs;
- split_specs_attrs ($1, &specs, &attrs);
- attrs = build_tree_list (attrs, NULL_TREE);
- $$ = start_method (specs, $2, attrs);
- rest_of_mdef:
- if (! $$)
- YYERROR1;
- if (yychar == YYEMPTY)
- yychar = YYLEX;
- reinit_parse_for_method (yychar, $$); }
- | component_constructor_declarator
- { $$ = start_method (NULL_TREE, $1, NULL_TREE);
- goto rest_of_mdef; }
- | typed_declspecs declarator
- { tree specs, attrs;
- split_specs_attrs ($1.t, &specs, &attrs);
- attrs = build_tree_list (attrs, NULL_TREE);
- $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
- | declmods notype_declarator
- { tree specs, attrs;
- split_specs_attrs ($1, &specs, &attrs);
- attrs = build_tree_list (attrs, NULL_TREE);
- $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
- | notype_declarator
- { $$ = start_method (NULL_TREE, $$, NULL_TREE);
- goto rest_of_mdef; }
- | declmods constructor_declarator
- { tree specs, attrs;
- split_specs_attrs ($1, &specs, &attrs);
- attrs = build_tree_list (attrs, NULL_TREE);
- $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
- | constructor_declarator
- { $$ = start_method (NULL_TREE, $$, NULL_TREE);
- goto rest_of_mdef; }
- ;
- return_id:
- RETURN_KEYWORD IDENTIFIER
- {
- if (! current_function_parms_stored)
- store_parm_decls ();
- $$ = $2;
- }
- ;
- return_init:
- return_id maybe_init
- { store_return_init ($<ttype>$, $2); }
- | return_id '(' nonnull_exprlist ')'
- { store_return_init ($<ttype>$, $3); }
- | return_id LEFT_RIGHT
- { store_return_init ($<ttype>$, NULL_TREE); }
- ;
- base_init:
- ':' .set_base_init member_init_list
- {
- if ($3 == 0)
- error ("no base initializers given following ':'");
- setup_vtbl_ptr ();
- /* Always keep the BLOCK node associated with the outermost
- pair of curley braces of a function. These are needed
- for correct operation of dwarfout.c. */
- keep_next_level ();
- }
- ;
- .set_base_init:
- /* empty */
- {
- if (! current_function_parms_stored)
- store_parm_decls ();
- if (DECL_CONSTRUCTOR_P (current_function_decl))
- {
- /* Make a contour for the initializer list. */
- pushlevel (0);
- clear_last_expr ();
- expand_start_bindings (0);
- }
- else if (current_class_type == NULL_TREE)
- error ("base initializers not allowed for non-member functions");
- else if (! DECL_CONSTRUCTOR_P (current_function_decl))
- error ("only constructors take base initializers");
- }
- ;
- member_init_list:
- /* empty */
- { $$ = 0; }
- | member_init
- { $$ = 1; }
- | member_init_list ',' member_init
- | member_init_list error
- ;
- member_init:
- '(' nonnull_exprlist ')'
- {
- if (current_class_name)
- pedwarn ("anachronistic old style base class initializer");
- expand_member_init (current_class_ref, NULL_TREE, $2);
- }
- | LEFT_RIGHT
- {
- if (current_class_name)
- pedwarn ("anachronistic old style base class initializer");
- expand_member_init (current_class_ref, NULL_TREE, void_type_node);
- }
- | notype_identifier '(' nonnull_exprlist ')'
- { expand_member_init (current_class_ref, $1, $3); }
- | notype_identifier LEFT_RIGHT
- { expand_member_init (current_class_ref, $1, void_type_node); }
- | nonnested_type '(' nonnull_exprlist ')'
- { expand_member_init (current_class_ref, $1, $3); }
- | nonnested_type LEFT_RIGHT
- { expand_member_init (current_class_ref, $1, void_type_node); }
- | typename_sub '(' nonnull_exprlist ')'
- { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
- $3); }
- | typename_sub LEFT_RIGHT
- { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
- void_type_node); }
- ;
- identifier:
- IDENTIFIER
- | TYPENAME
- | 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);
- yyungetc (';', 1); }
- end_explicit_instantiation
- | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
- { tree specs = strip_attrs ($3.t);
- do_decl_instantiation (specs, $4, NULL_TREE); }
- end_explicit_instantiation
- | TEMPLATE begin_explicit_instantiation notype_declarator
- { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
- end_explicit_instantiation
- | TEMPLATE begin_explicit_instantiation constructor_declarator
- { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
- end_explicit_instantiation
- | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
- { do_type_instantiation ($4.t, $1);
- yyungetc (';', 1); }
- end_explicit_instantiation
- | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
- declarator
- { tree specs = strip_attrs ($4.t);
- do_decl_instantiation (specs, $5, $1); }
- end_explicit_instantiation
- | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
- { do_decl_instantiation (NULL_TREE, $4, $1); }
- end_explicit_instantiation
- | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
- { do_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; }
- | TYPENAME '<' 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:
- type_id
- { $$ = groktypename ($1.t); }
- | PTYPENAME
- { $$ = lastiddecl; }
- | expr_no_commas %prec ARITHCOMPARE
- ;
- 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 ("ANSI C++ forbids an empty condition for `%s'",
- cond_stmt_keyword);
- $$ = integer_zero_node; }
- | '(' expr ')'
- { $$ = $2; }
- ;
- paren_cond_or_null:
- LEFT_RIGHT
- { error ("ANSI 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)
- cp_error ("definition of class `%T' in condition", s);
- else if (TREE_CODE (s) == ENUMERAL_TYPE)
- cp_error ("definition of enum `%T' in condition", s);
- }
- }
- current_declspecs = $1.t;
- $<itype>5 = suspend_momentary ();
- $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
- $4, /*prefix_attributes*/ NULL_TREE);
- }
- init
- {
- cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
- resume_momentary ($<itype>5);
- $$ = convert_from_reference ($<ttype>6);
- if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
- cp_error ("definition of array `%#D' in condition", $$);
- }
- | expr
- ;
- compstmtend:
- '}'
- | maybe_label_decls stmts '}'
- | maybe_label_decls stmts error '}'
- | maybe_label_decls error '}'
- ;
- already_scoped_stmt:
- '{'
- { $<ttype>$ = begin_compound_stmt (1); }
- compstmtend
- { finish_compound_stmt (1, $<ttype>2); }
- | simple_stmt
- ;
- nontrivial_exprlist:
- expr_no_commas ',' expr_no_commas
- { $$ = expr_tree_cons (NULL_TREE, $$,
- build_expr_list (NULL_TREE, $3)); }
- | expr_no_commas ',' error
- { $$ = expr_tree_cons (NULL_TREE, $$,
- build_expr_list (NULL_TREE, error_mark_node)); }
- | nontrivial_exprlist ',' expr_no_commas
- { chainon ($$, build_expr_list (NULL_TREE, $3)); }
- | nontrivial_exprlist ',' error
- { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
- ;
- nonnull_exprlist:
- expr_no_commas
- { $$ = build_expr_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 = $<itype>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
- { if (pedantic)
- pedwarn ("ANSI C++ forbids `&&'");
- $$ = finish_label_address_expr ($2); }
- | SIZEOF unary_expr %prec UNARY
- { $$ = expr_sizeof ($2); }
- | SIZEOF '(' type_id ')' %prec HYPERUNARY
- { $$ = c_sizeof (groktypename ($3.t));
- check_for_new_type ("sizeof", $3); }
- | ALIGNOF unary_expr %prec UNARY
- { $$ = grok_alignof ($2); }
- | ALIGNOF '(' type_id ')' %prec HYPERUNARY
- { $$ = c_alignof (groktypename ($3.t));
- check_for_new_type ("alignof", $3); }
- | VEC_STEP unary_expr %prec UNARY
- { $$ = c_vec_step_expr ($2); }
- | VEC_STEP '(' type_id ')' %prec HYPERUNARY
- { $$ = c_vec_step (groktypename ($3.t)); }
- /* 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); }
- /* The .begin_new_placement in the following rules is
- necessary to avoid shift/reduce conflicts that lead to
- mis-parsing some expressions. Of course, these constructs
- are not really new-placement and it is bogus to call
- begin_new_placement. But, the parser cannot always tell at this
- point whether the next thing is an expression or a type-id,
- so there is nothing we can do. Fortunately,
- begin_new_placement does nothing harmful. When we rewrite
- the parser, this lossage should be removed, of course. */
- | new '(' .begin_new_placement type_id .finish_new_placement
- %prec EMPTY
- { $$ = build_new (NULL_TREE, groktypename($4.t),
- NULL_TREE, $1);
- check_for_new_type ("new", $4); }
- | new '(' .begin_new_placement type_id .finish_new_placement
- new_initializer
- { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
- check_for_new_type ("new", $4); }
- | new new_placement '(' .begin_new_placement type_id
- .finish_new_placement %prec EMPTY
- { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
- check_for_new_type ("new", $5); }
- | new new_placement '(' .begin_new_placement type_id
- .finish_new_placement new_initializer
- { $$ = build_new ($2, groktypename($5.t), $7, $1);
- check_for_new_type ("new", $5); }
- | 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); }
- ;
- /* Note this rule is not suitable for use in new_placement
- since it uses NULL_TREE as the argument to
- finish_new_placement. This rule serves only to avoid
- reduce/reduce conflicts in unary_expr. See the comments
- there on the use of begin/finish_new_placement. */
- .finish_new_placement:
- ')'
- { finish_new_placement (NULL_TREE, $<itype>-1); }
- .begin_new_placement:
- { $$ = begin_new_placement (); }
- new_placement:
- '(' .begin_new_placement nonnull_exprlist ')'
- { $$ = finish_new_placement ($3, $2); }
- | '{' .begin_new_placement nonnull_exprlist '}'
- { cp_pedwarn ("old style placement syntax, use () instead");
- $$ = finish_new_placement ($3, $2); }
- ;
- new_initializer:
- '(' nonnull_exprlist ')'
- { $$ = $2; }
- | LEFT_RIGHT
- { $$ = NULL_TREE; }
- | '(' typespec ')'
- {
- cp_error ("`%T' is not a valid expression", $2.t);
- $$ = error_mark_node;
- }
- /* GNU extension so people can use initializer lists. Note that
- this alters the meaning of `new int = 1', which was previously
- syntactically valid but semantically invalid. */
- | '=' init
- {
- if (pedantic)
- pedwarn ("ANSI C++ forbids initialization of new expression with `='");
- if (TREE_CODE ($2) != TREE_LIST
- && TREE_CODE ($2) != CONSTRUCTOR)
- $$ = build_expr_list (NULL_TREE, $2);
- else
- $$ = $2;
- }
- ;
- /* 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 '(' nontrivial_exprlist ')' %prec UNARY
- { $$ = reparse_absdcl_as_casts_or_vector_constant ($$, $3); }
- | regcast_or_absdcl unary_expr %prec UNARY
- { $$ = reparse_absdcl_as_casts_or_vector_constant ($$, $2); }
- | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
- {
- tree init = build_nt (CONSTRUCTOR, NULL_TREE,
- nreverse ($3));
- if (pedantic)
- pedwarn ("ANSI C++ forbids constructor-expressions");
- /* Indicate that this was a GNU C constructor expression. */
- 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); }
- /* These extensions are not defined. The second arg to build_m_component_ref
- is old, build_m_component_ref now does an implicit
- build_indirect_ref (x, NULL_PTR) on the second argument.
- | object '&' expr_no_commas %prec UNARY
- { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
- | object unop expr_no_commas %prec UNARY
- { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
- | object '(' type_id ')' expr_no_commas %prec UNARY
- { tree type = groktypename ($3.t);
- $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
- | object primary_no_id %prec UNARY
- { $$ = build_m_component_ref ($$, $2); }
- */
- ;
- notype_unqualified_id:
- '~' see_typename identifier
- { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
- | '~' see_typename template_type
- { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
- | template_id
- | operator_name
- | IDENTIFIER
- | PTYPENAME
- | NSNAME %prec EMPTY
- ;
- do_id:
- {
- /* If lastiddecl is a TREE_LIST, it's a baselink, which
- means that we're in an expression like S::f<int>, so
- don't do_identifier; we only do that for unqualified
- identifiers. */
- if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
- $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
- else
- $$ = $<ttype>-1;
- }
- template_id:
- PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
- { $$ = lookup_template_function ($3, $4); }
- | operator_name '<' do_id template_arg_list_opt template_close_bracket
- { $$ = lookup_template_function ($3, $4); }
- ;
- object_template_id:
- TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
- { $$ = lookup_template_function ($2, $4); }
- | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
- { $$ = lookup_template_function ($2, $4); }
- | TEMPLATE operator_name '<' template_arg_list_opt
- template_close_bracket
- { $$ = lookup_template_function ($2, $4); }
- ;
- unqualified_id:
- notype_unqualified_id
- | TYPENAME
- | SELFNAME
- ;
- expr_or_declarator_intern:
- expr_or_declarator
- | attributes expr_or_declarator
- {
- /* Provide support for '(' attributes '*' declarator ')'
- etc */
- $$ = decl_tree_cons ($1, $2, NULL_TREE);
- }
- ;
- expr_or_declarator:
- notype_unqualified_id
- | '*' expr_or_declarator_intern %prec UNARY
- { $$ = build_parse_node (INDIRECT_REF, $2); }
- | '&' expr_or_declarator_intern %prec UNARY
- { $$ = build_parse_node (ADDR_EXPR, $2); }
- | '(' expr_or_declarator_intern ')'
- { $$ = $2; }
- ;
- notype_template_declarator:
- IDENTIFIER '<' template_arg_list_opt template_close_bracket
- { $$ = lookup_template_function ($1, $3); }
- | NSNAME '<' template_arg_list template_close_bracket
- { $$ = lookup_template_function ($1, $3); }
- ;
-
- direct_notype_declarator:
- complex_direct_notype_declarator
- /* This precedence declaration is to prefer this reduce
- to the Koenig lookup shift in primary, below. I hate yacc. */
- | notype_unqualified_id %prec '('
- | notype_template_declarator
- | '(' expr_or_declarator_intern ')'
- { $$ = finish_decl_parsing ($2); }
- ;
- primary:
- notype_unqualified_id
- {
- if (TREE_CODE ($1) == BIT_NOT_EXPR)
- $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
- else
- $$ = finish_id_expr ($1);
- }
- | CONSTANT
- | boolean.literal
- | string
- {
- if (processing_template_decl)
- push_obstacks (&permanent_obstack, &permanent_obstack);
- $$ = combine_strings ($$);
- /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
- a const array the way we want, so fix it. */
- if (flag_const_strings)
- TREE_TYPE ($$) = build_cplus_array_type
- (TREE_TYPE (TREE_TYPE ($$)),
- TYPE_DOMAIN (TREE_TYPE ($$)));
- if (processing_template_decl)
- pop_obstacks ();
- }
- | '(' expr ')'
- { $$ = finish_parenthesized_expr ($2); }
- | '(' expr_or_declarator_intern ')'
- { $2 = reparse_decl_as_expr (NULL_TREE, $2);
- $$ = finish_parenthesized_expr ($2); }
- | '(' error ')'
- { $$ = error_mark_node; }
- | '('
- { tree scope = current_scope ();
- if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
- {
- error ("braced-group within expression allowed only inside a function");
- YYERROR;
- }
- if (pedantic)
- pedwarn ("ANSI C++ forbids braced-groups within expressions");
- $<ttype>$ = begin_stmt_expr ();
- }
- compstmt ')'
- { $$ = finish_stmt_expr ($<ttype>2, $3); }
- /* Koenig lookup support
- We could store lastiddecl in $1 to avoid another lookup,
- but that would result in many additional reduce/reduce conflicts. */
- | notype_unqualified_id '(' nonnull_exprlist ')'
- { $$ = finish_call_expr ($1, $3, 1); }
- | notype_unqualified_id LEFT_RIGHT
- { $$ = finish_call_expr ($1, NULL_TREE, 1); }
- | primary '(' nonnull_exprlist ')'
- { $$ = finish_call_expr ($1, $3, 0); }
- | primary LEFT_RIGHT
- { $$ = finish_call_expr ($1, NULL_TREE, 0); }
- | primary '[' expr ']'
- { $$ = grok_array_decl ($$, $3); }
- | primary PLUSPLUS
- { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
- | primary MINUSMINUS
- { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
- /* C++ extensions */
- | THIS
- { $$ = finish_this_expr (); }
- | CV_QUALIFIER '(' nonnull_exprlist ')'
- {
- /* This is a C cast in C++'s `functional' notation
- using the "implicit int" extension so that:
- `const (3)' is equivalent to `const int (3)'. */
- tree type;
- if ($3 == error_mark_node)
- {
- $$ = error_mark_node;
- break;
- }
- type = cp_build_qualified_type (integer_type_node,
- cp_type_qual_from_rid ($1));
- $$ = build_c_cast (type, build_compound_expr ($3));
- }
- | functional_cast
- | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
- { tree type = groktypename ($3.t);
- check_for_new_type ("dynamic_cast", $3);
- $$ = build_dynamic_cast (type, $6); }
- | STATIC_CAST '<' type_id '>' '(' expr ')'
- { tree type = groktypename ($3.t);
- check_for_new_type ("static_cast", $3);
- $$ = build_static_cast (type, $6); }
- | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
- { tree type = groktypename ($3.t);
- check_for_new_type ("reinterpret_cast", $3);
- $$ = build_reinterpret_cast (type, $6); }
- | CONST_CAST '<' type_id '>' '(' expr ')'
- { tree type = groktypename ($3.t);
- check_for_new_type ("const_cast", $3);
- $$ = build_const_cast (type, $6); }
- | TYPEID '(' expr ')'
- { $$ = build_x_typeid ($3); }
- | TYPEID '(' type_id ')'
- { tree type = groktypename ($3.t);
- check_for_new_type ("typeid", $3);
- $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
- | global_scope IDENTIFIER
- { $$ = do_scoped_id ($2, 1); }
- | global_scope template_id
- { $$ = $2; }
- | global_scope operator_name
- {
- got_scope = NULL_TREE;
- if (TREE_CODE ($2) == IDENTIFIER_NODE)
- $$ = do_scoped_id ($2, 1);
- else
- $$ = $2;
- }
- | overqualified_id %prec HYPERUNARY
- { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
- | overqualif…
Large files files are truncated, but you can click here to view the full file