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