home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / obcp / parse.in < prev    next >
Text File  |  1996-06-12  |  133KB  |  4,748 lines

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