home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / gcc-2.3.3-src.lha / src / amiga / gcc-2.3.3 / c-parse.y < prev    next >
Encoding:
GNU Bison Grammar  |  1994-02-07  |  51.4 KB  |  1,794 lines

  1. /* YACC parser for C syntax and for Objective C.  -*-c-*-
  2.    Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* This file defines the grammar of C and that of Objective C.
  21.    ifobjc ... end ifobjc  conditionals contain code for Objective C only.
  22.    ifc ... end ifc  conditionals contain code for C only.
  23.    The awk script cond.awk is used to convert this file into
  24.    c-parse.y and into objc-parse.y.  */
  25.  
  26. /* To whomever it may concern: I have heard that such a thing was once
  27. written by AT&T, but I have never seen it.  */
  28.  
  29. %expect 8
  30.  
  31. /* These are the 8 conflicts you should get in parse.output;
  32.    the state numbers may vary if minor changes in the grammar are made.
  33.  
  34. State 41 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  35. State 92 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  36. State 99 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  37. State 103 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  38. State 119 contains 1 shift/reduce conflict.  (See comment at component_decl.)
  39. State 183 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  40. State 193 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  41. State 199 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  42. */
  43.  
  44. %{
  45. #include <stdio.h>
  46. #include <errno.h>
  47. #include <setjmp.h>
  48.  
  49. #include "config.h"
  50. #include "tree.h"
  51. #include "input.h"
  52. #include "c-lex.h"
  53. #include "c-tree.h"
  54. #include "flags.h"
  55.  
  56. #ifdef MULTIBYTE_CHARS
  57. #include <stdlib.h>
  58. #include <locale.h>
  59. #endif
  60.  
  61.  
  62. #ifndef errno
  63. extern int errno;
  64. #endif
  65.  
  66. void yyerror ();
  67.  
  68. /* Like YYERROR but do call yyerror.  */
  69. #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
  70.  
  71. /* Cause the `yydebug' variable to be defined.  */
  72. #define YYDEBUG 1
  73. %}
  74.  
  75. %start program
  76.  
  77. %union {long itype; tree ttype; enum tree_code code;
  78.     char *filename; int lineno; }
  79.  
  80. /* All identifiers that are not reserved words
  81.    and are not declared typedefs in the current block */
  82. %token IDENTIFIER
  83.  
  84. /* All identifiers that are declared typedefs in the current block.
  85.    In some contexts, they are treated just like IDENTIFIER,
  86.    but they can also serve as typespecs in declarations.  */
  87. %token TYPENAME
  88.  
  89. /* Reserved words that specify storage class.
  90.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  91. %token SCSPEC
  92.  
  93. /* Reserved words that specify type.
  94.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  95. %token TYPESPEC
  96.  
  97. /* Reserved words that qualify type: "const" or "volatile".
  98.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  99. %token TYPE_QUAL
  100.  
  101. /* Character or numeric constants.
  102.    yylval is the node for the constant.  */
  103. %token CONSTANT
  104.  
  105. /* String constants in raw form.
  106.    yylval is a STRING_CST node.  */
  107. %token STRING
  108.  
  109. /* "...", used for functions with variable arglists.  */
  110. %token ELLIPSIS
  111.  
  112. /* the reserved words */
  113. /* SCO include files test "ASM", so use something else. */
  114. %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
  115. %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF ALIGN
  116. %token ATTRIBUTE EXTENSION LABEL
  117.  
  118. /* Add precedence rules to solve dangling else s/r conflict */
  119. %nonassoc IF
  120. %nonassoc ELSE
  121.  
  122. /* Define the operator tokens and their precedences.
  123.    The value is an integer because, if used, it is the tree code
  124.    to use in the expression made from the operator.  */
  125.  
  126. %right <code> ASSIGN '='
  127. %right <code> '?' ':'
  128. %left <code> OROR
  129. %left <code> ANDAND
  130. %left <code> '|'
  131. %left <code> '^'
  132. %left <code> '&'
  133. %left <code> EQCOMPARE
  134. %left <code> ARITHCOMPARE
  135. %left <code> LSHIFT RSHIFT
  136. %left <code> '+' '-'
  137. %left <code> '*' '/' '%'
  138. %right <code> UNARY PLUSPLUS MINUSMINUS
  139. %left HYPERUNARY
  140. %left <code> POINTSAT '.' '(' '['
  141.  
  142. /* The Objective-C keywords.  These are included in C and in
  143.    Objective C, so that the token codes are the same in both.  */
  144. %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
  145. %token CLASSNAME PUBLIC
  146.  
  147.  
  148. %type <code> unop
  149.  
  150. %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
  151. %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
  152. %type <ttype> typed_declspecs reserved_declspecs
  153. %type <ttype> typed_typespecs reserved_typespecquals
  154. %type <ttype> declmods typespec typespecqual_reserved
  155. %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
  156. %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
  157. %type <ttype> init initlist maybeasm
  158. %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
  159. %type <ttype> maybe_attribute attribute_list attrib
  160.  
  161. %type <ttype> compstmt
  162.  
  163. %type <ttype> declarator
  164. %type <ttype> notype_declarator after_type_declarator
  165. %type <ttype> parm_declarator
  166.  
  167. %type <ttype> structsp component_decl_list component_decl_list2
  168. %type <ttype> component_decl components component_declarator
  169. %type <ttype> enumlist enumerator
  170. %type <ttype> typename absdcl absdcl1 type_quals
  171. %type <ttype> xexpr parms parm identifiers
  172.  
  173. %type <ttype> parmlist parmlist_1 parmlist_2
  174. %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
  175. %type <ttype> identifiers_or_typenames
  176.  
  177. %type <itype> setspecs
  178.  
  179. %type <filename> save_filename
  180. %type <lineno> save_lineno
  181.  
  182.  
  183. %{
  184. /* Number of statements (loosely speaking) seen so far.  */
  185. static int stmt_count;
  186.  
  187. /* Input file and line number of the end of the body of last simple_if;
  188.    used by the stmt-rule immediately after simple_if returns.  */
  189. static char *if_stmt_file;
  190. static int if_stmt_line;
  191.  
  192. /* List of types and structure classes of the current declaration.  */
  193. static tree current_declspecs;
  194.  
  195. /* Stack of saved values of current_declspecs.  */
  196. static tree declspec_stack;
  197.  
  198. /* 1 if we explained undeclared var errors.  */
  199. static int undeclared_variable_notice;
  200.  
  201.  
  202. /* Tell yyparse how to print a token's value, if yydebug is set.  */
  203.  
  204. #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
  205. extern void yyprint ();
  206. %}
  207.  
  208. %%
  209. program: /* empty */
  210.         { if (pedantic)
  211.             pedwarn ("ANSI C forbids an empty source file");
  212.         }
  213.     | extdefs
  214.         {
  215.         }
  216.     ;
  217.  
  218. /* the reason for the strange actions in this rule
  219.  is so that notype_initdecls when reached via datadef
  220.  can find a valid list of type and sc specs in $0. */
  221.  
  222. extdefs:
  223.     {$<ttype>$ = NULL_TREE; } extdef
  224.     | extdefs {$<ttype>$ = NULL_TREE; } extdef
  225.     ;
  226.  
  227. extdef:
  228.     fndef
  229.     | datadef
  230.     | ASM_KEYWORD '(' expr ')' ';'
  231.         { STRIP_NOPS ($3);
  232.           if ((TREE_CODE ($3) == ADDR_EXPR
  233.                && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
  234.               || TREE_CODE ($3) == STRING_CST)
  235.             assemble_asm ($3);
  236.           else
  237.             error ("argument of `asm' is not a constant string"); }
  238.     ;
  239.  
  240. datadef:
  241.       setspecs notype_initdecls ';'
  242.         { if (pedantic)
  243.             error ("ANSI C forbids data definition with no type or storage class");
  244.           else if (!flag_traditional)
  245.             warning ("data definition has no type or storage class"); }
  246.         | declmods setspecs notype_initdecls ';'
  247.       {}
  248.     | typed_declspecs setspecs initdecls ';'
  249.       {}
  250.         | declmods ';'
  251.       { pedwarn ("empty declaration"); }
  252.     | typed_declspecs ';'
  253.       { shadow_tag ($1); }
  254.     | error ';'
  255.     | error '}'
  256.     | ';'
  257.         { if (pedantic)
  258.             pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
  259.     ;
  260.  
  261. fndef:
  262.       typed_declspecs setspecs declarator
  263.         { if (! start_function ($1, $3, 0))
  264.             YYERROR1;
  265.           reinit_parse_for_function (); }
  266.       xdecls
  267.         { store_parm_decls (); }
  268.       compstmt_or_error
  269.         { finish_function (0); }
  270.     | typed_declspecs setspecs declarator error
  271.         { }
  272.     | declmods setspecs notype_declarator
  273.         { if (! start_function ($1, $3, 0))
  274.             YYERROR1;
  275.           reinit_parse_for_function (); }
  276.       xdecls
  277.         { store_parm_decls (); }
  278.       compstmt_or_error
  279.         { finish_function (0); }
  280.     | declmods setspecs notype_declarator error
  281.         { }
  282.     | setspecs notype_declarator
  283.         { if (! start_function (NULL_TREE, $2, 0))
  284.             YYERROR1;
  285.           reinit_parse_for_function (); }
  286.       xdecls
  287.         { store_parm_decls (); }
  288.       compstmt_or_error
  289.         { finish_function (0); }
  290.     | setspecs notype_declarator error
  291.         { }
  292.     ;
  293.  
  294. identifier:
  295.     IDENTIFIER
  296.     | TYPENAME
  297.     ;
  298.  
  299. unop:     '&'
  300.         { $$ = ADDR_EXPR; }
  301.     | '-'
  302.         { $$ = NEGATE_EXPR; }
  303.     | '+'
  304.         { $$ = CONVERT_EXPR; }
  305.     | PLUSPLUS
  306.         { $$ = PREINCREMENT_EXPR; }
  307.     | MINUSMINUS
  308.         { $$ = PREDECREMENT_EXPR; }
  309.     | '~'
  310.         { $$ = BIT_NOT_EXPR; }
  311.     | '!'
  312.         { $$ = TRUTH_NOT_EXPR; }
  313.     ;
  314.  
  315. expr:    nonnull_exprlist
  316.         { $$ = build_compound_expr ($1); }
  317.     ;
  318.  
  319. exprlist:
  320.       /* empty */
  321.         { $$ = NULL_TREE; }
  322.     | nonnull_exprlist
  323.     ;
  324.  
  325. nonnull_exprlist:
  326.     expr_no_commas
  327.         { $$ = build_tree_list (NULL_TREE, $1); }
  328.     | nonnull_exprlist ',' expr_no_commas
  329.         { chainon ($1, build_tree_list (NULL_TREE, $3)); }
  330.     ;
  331.  
  332. unary_expr:
  333.     primary
  334.     | '*' cast_expr   %prec UNARY
  335.         { $$ = build_indirect_ref ($2, "unary *"); }
  336.     /* __extension__ turns off -pedantic for following primary.  */
  337.     | EXTENSION
  338.         { $<itype>1 = pedantic;
  339.           pedantic = 0; }
  340.       cast_expr      %prec UNARY
  341.         { $$ = $3;
  342.           pedantic = $<itype>1; }
  343.     | unop cast_expr  %prec UNARY
  344.         { $$ = build_unary_op ($1, $2, 0); }
  345.     /* Refer to the address of a label as a pointer.  */
  346.     | ANDAND identifier
  347.         { tree label = lookup_label ($2);
  348.           TREE_USED (label) = 1;
  349.           $$ = build1 (ADDR_EXPR, ptr_type_node, label);
  350.           TREE_CONSTANT ($$) = 1; }
  351. /* This seems to be impossible on some machines, so let's turn it off.
  352.    You can use __builtin_next_arg to find the anonymous stack args.
  353.     | '&' ELLIPSIS
  354.         { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
  355.           $$ = error_mark_node;
  356.           if (TREE_VALUE (tree_last (types)) == void_type_node)
  357.             error ("`&...' used in function with fixed number of arguments");
  358.           else
  359.             {
  360.               if (pedantic)
  361.             pedwarn ("ANSI C forbids `&...'");
  362.               $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
  363.               $$ = build_unary_op (ADDR_EXPR, $$, 0);
  364.             } }
  365. */
  366.     | SIZEOF unary_expr  %prec UNARY
  367.         { if (TREE_CODE ($2) == COMPONENT_REF
  368.               && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
  369.             error ("`sizeof' applied to a bit-field");
  370.           $$ = c_sizeof (TREE_TYPE ($2)); }
  371.     | SIZEOF '(' typename ')'  %prec HYPERUNARY
  372.         { $$ = c_sizeof (groktypename ($3)); }
  373.     | ALIGNOF unary_expr  %prec UNARY
  374.         { $$ = c_alignof_expr ($2); }
  375.     | ALIGNOF '(' typename ')'  %prec HYPERUNARY
  376.         { $$ = c_alignof (groktypename ($3)); }
  377.     ;
  378.  
  379. cast_expr:
  380.     unary_expr
  381.     | '(' typename ')' cast_expr  %prec UNARY
  382.         { tree type = groktypename ($2);
  383.           $$ = build_c_cast (type, $4); }
  384.     | '(' typename ')' '{' initlist maybecomma '}'  %prec UNARY
  385.         { tree type = groktypename ($2);
  386.           char *name;
  387.           if (pedantic)
  388.             pedwarn ("ANSI C forbids constructor expressions");
  389.           if (TYPE_NAME (type) != 0)
  390.             {
  391.               if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
  392.             name = IDENTIFIER_POINTER (TYPE_NAME (type));
  393.               else
  394.             name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
  395.             }
  396.           else
  397.             name = "";
  398.           $$ = digest_init (type, build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($5)),
  399.                     NULL_PTR, 0, 0, name);
  400.           if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
  401.             {
  402.               int failure = complete_array_type (type, $$, 1);
  403.               if (failure)
  404.             abort ();
  405.             }
  406.         }
  407.     ;
  408.  
  409. expr_no_commas:
  410.       cast_expr
  411.     | expr_no_commas '+' expr_no_commas
  412.         { $$ = parser_build_binary_op ($2, $1, $3); }
  413.     | expr_no_commas '-' expr_no_commas
  414.         { $$ = parser_build_binary_op ($2, $1, $3); }
  415.     | expr_no_commas '*' expr_no_commas
  416.         { $$ = parser_build_binary_op ($2, $1, $3); }
  417.     | expr_no_commas '/' expr_no_commas
  418.         { $$ = parser_build_binary_op ($2, $1, $3); }
  419.     | expr_no_commas '%' expr_no_commas
  420.         { $$ = parser_build_binary_op ($2, $1, $3); }
  421.     | expr_no_commas LSHIFT expr_no_commas
  422.         { $$ = parser_build_binary_op ($2, $1, $3); }
  423.     | expr_no_commas RSHIFT expr_no_commas
  424.         { $$ = parser_build_binary_op ($2, $1, $3); }
  425.     | expr_no_commas ARITHCOMPARE expr_no_commas
  426.         { $$ = parser_build_binary_op ($2, $1, $3); }
  427.     | expr_no_commas EQCOMPARE expr_no_commas
  428.         { $$ = parser_build_binary_op ($2, $1, $3); }
  429.     | expr_no_commas '&' expr_no_commas
  430.         { $$ = parser_build_binary_op ($2, $1, $3); }
  431.     | expr_no_commas '|' expr_no_commas
  432.         { $$ = parser_build_binary_op ($2, $1, $3); }
  433.     | expr_no_commas '^' expr_no_commas
  434.         { $$ = parser_build_binary_op ($2, $1, $3); }
  435.     | expr_no_commas ANDAND expr_no_commas
  436.         { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
  437.     | expr_no_commas OROR expr_no_commas
  438.         { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
  439.     | expr_no_commas '?' xexpr ':' expr_no_commas
  440.         { $$ = build_conditional_expr ($1, $3, $5); }
  441.     | expr_no_commas '=' expr_no_commas
  442.         { $$ = build_modify_expr ($1, NOP_EXPR, $3);
  443.           C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
  444.     | expr_no_commas ASSIGN expr_no_commas
  445.         { $$ = build_modify_expr ($1, $2, $3);
  446.           C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
  447.     ;
  448.  
  449. primary:
  450.     IDENTIFIER
  451.         {
  452.           tree context;
  453.  
  454.           $$ = lastiddecl;
  455.           if (!$$ || $$ == error_mark_node)
  456.             {
  457.               if (yychar == YYEMPTY)
  458.             yychar = YYLEX;
  459.               if (yychar == '(')
  460.             {
  461.                 {
  462.                   /* Ordinary implicit function declaration.  */
  463.                   $$ = implicitly_declare ($1);
  464.                   assemble_external ($$);
  465.                   TREE_USED ($$) = 1;
  466.                 }
  467.             }
  468.               else if (current_function_decl == 0)
  469.             {
  470.               error ("`%s' undeclared, outside of functions",
  471.                  IDENTIFIER_POINTER ($1));
  472.               $$ = error_mark_node;
  473.             }
  474.               else
  475.             {
  476.                 {
  477.                   if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
  478.                   || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
  479.                 {
  480.                   error ("`%s' undeclared (first use this function)",
  481.                      IDENTIFIER_POINTER ($1));
  482.  
  483.                   if (! undeclared_variable_notice)
  484.                     {
  485.                       error ("(Each undeclared identifier is reported only once");
  486.                       error ("for each function it appears in.)");
  487.                       undeclared_variable_notice = 1;
  488.                     }
  489.                 }
  490.                   $$ = error_mark_node;
  491.                   /* Prevent repeated error messages.  */
  492.                   IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
  493.                   IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
  494.                 }
  495.             }
  496.             }
  497.           else if (TREE_TYPE ($$) == error_mark_node)
  498.             $$ = error_mark_node;
  499.           else if (C_DECL_ANTICIPATED ($$))
  500.             {
  501.               /* The first time we see a build-in function used,
  502.              if it has not been declared.  */
  503.               C_DECL_ANTICIPATED ($$) = 0;
  504.               if (yychar == YYEMPTY)
  505.             yychar = YYLEX;
  506.               if (yychar == '(')
  507.             {
  508.               /* Omit the implicit declaration we
  509.                  would ordinarily do, so we don't lose
  510.                  the actual built in type.
  511.                  But print a diagnostic for the mismatch.  */
  512.                 if (TREE_CODE ($$) != FUNCTION_DECL)
  513.                   error ("`%s' implicitly declared as function",
  514.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  515.               else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
  516.                     != TYPE_MODE (integer_type_node))
  517.                    && (TREE_TYPE (TREE_TYPE ($$))
  518.                        != void_type_node))
  519.                 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
  520.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  521.               /* If it really returns void, change that to int.  */
  522.               if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
  523.                 TREE_TYPE ($$)
  524.                   = build_function_type (integer_type_node,
  525.                              TYPE_ARG_TYPES (TREE_TYPE ($$)));
  526.             }
  527.               else
  528.             pedwarn ("built-in function `%s' used without declaration",
  529.                  IDENTIFIER_POINTER (DECL_NAME ($$)));
  530.  
  531.               /* Do what we would ordinarily do when a fn is used.  */
  532.               assemble_external ($$);
  533.               TREE_USED ($$) = 1;
  534.             }
  535.           else
  536.             {
  537.               assemble_external ($$);
  538.               TREE_USED ($$) = 1;
  539.             }
  540.  
  541.           if (TREE_CODE ($$) == CONST_DECL)
  542.             {
  543.               $$ = DECL_INITIAL ($$);
  544.               /* This is to prevent an enum whose value is 0
  545.              from being considered a null pointer constant.  */
  546.               $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
  547.               TREE_CONSTANT ($$) = 1;
  548.             }
  549.         }
  550.     | CONSTANT
  551.     | string
  552.         { $$ = combine_strings ($1); }
  553.     | '(' expr ')'
  554.         { char class = TREE_CODE_CLASS (TREE_CODE ($2));
  555.           if (class == 'e' || class == '1'
  556.               || class == '2' || class == '<')
  557.             C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
  558.           $$ = $2; }
  559.     | '(' error ')'
  560.         { $$ = error_mark_node; }
  561.     | '('
  562.         { if (current_function_decl == 0)
  563.             {
  564.               error ("braced-group within expression allowed only inside a function");
  565.               YYERROR;
  566.             }
  567.           /* We must force a BLOCK for this level
  568.              so that, if it is not expanded later,
  569.              there is a way to turn off the entire subtree of blocks
  570.              that are contained in it.  */
  571.           keep_next_level ();
  572.           push_label_level ();
  573.           $<ttype>$ = expand_start_stmt_expr (); }
  574.       compstmt ')'
  575.         { tree rtl_exp;
  576.           if (pedantic)
  577.             pedwarn ("ANSI C forbids braced-groups within expressions");
  578.           pop_label_level ();
  579.           rtl_exp = expand_end_stmt_expr ($<ttype>2);
  580.           /* The statements have side effects, so the group does.  */
  581.           TREE_SIDE_EFFECTS (rtl_exp) = 1;
  582.  
  583.           /* Make a BIND_EXPR for the BLOCK already made.  */
  584.           $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
  585.                   NULL_TREE, rtl_exp, $3);
  586.           /* Remove the block from the tree at this point.
  587.              It gets put back at the proper place
  588.              when the BIND_EXPR is expanded.  */
  589.           delete_block ($3);
  590.         }
  591.     | primary '(' exprlist ')'   %prec '.'
  592.         { $$ = build_function_call ($1, $3); }
  593.     | primary '[' expr ']'   %prec '.'
  594.         { $$ = build_array_ref ($1, $3); }
  595.     | primary '.' identifier
  596.         {
  597.             $$ = build_component_ref ($1, $3);
  598.         }
  599.     | primary POINTSAT identifier
  600.         {
  601.                   tree expr = build_indirect_ref ($1, "->");
  602.  
  603.                     $$ = build_component_ref (expr, $3);
  604.         }
  605.     | primary PLUSPLUS
  606.         { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
  607.     | primary MINUSMINUS
  608.         { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
  609.     ;
  610.  
  611. /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
  612. string:
  613.       STRING
  614.     | string STRING
  615.         { $$ = chainon ($1, $2); }
  616.     ;
  617.  
  618. xdecls:
  619.     /* empty */
  620.     | datadecls
  621.     | datadecls ELLIPSIS
  622.         /* ... is used here to indicate a varargs function.  */
  623.         { c_mark_varargs ();
  624.           if (pedantic)
  625.             pedwarn ("ANSI C does not permit use of `varargs.h'"); }
  626.     ;
  627.  
  628. /* The following are analogous to lineno_decl, decls and decl
  629.    except that they do not allow nested functions.
  630.    They are used for old-style parm decls.  */
  631. lineno_datadecl:
  632.       save_filename save_lineno datadecl
  633.         { }
  634.     ;
  635.  
  636. datadecls:
  637.     lineno_datadecl
  638.     | errstmt
  639.     | datadecls lineno_datadecl
  640.     | lineno_datadecl errstmt
  641.     ;
  642.  
  643. datadecl:
  644.     typed_declspecs setspecs initdecls ';'
  645.         { current_declspecs = TREE_VALUE (declspec_stack);
  646.           declspec_stack = TREE_CHAIN (declspec_stack);
  647.           resume_momentary ($2); }
  648.     | declmods setspecs notype_initdecls ';'
  649.         { current_declspecs = TREE_VALUE (declspec_stack);
  650.           declspec_stack = TREE_CHAIN (declspec_stack);
  651.           resume_momentary ($2); }
  652.     | typed_declspecs ';'
  653.         { shadow_tag_warned ($1, 1);
  654.           pedwarn ("empty declaration"); }
  655.     | declmods ';'
  656.         { pedwarn ("empty declaration"); }
  657.     ;
  658.  
  659. /* This combination which saves a lineno before a decl
  660.    is the normal thing to use, rather than decl itself.
  661.    This is to avoid shift/reduce conflicts in contexts
  662.    where statement labels are allowed.  */
  663. lineno_decl:
  664.       save_filename save_lineno decl
  665.         { }
  666.     ;
  667.  
  668. decls:
  669.     lineno_decl
  670.     | errstmt
  671.     | decls lineno_decl
  672.     | lineno_decl errstmt
  673.     ;
  674.  
  675. /* records the type and storage class specs to use for processing
  676.    the declarators that follow.
  677.    Maintains a stack of outer-level values of current_declspecs,
  678.    for the sake of parm declarations nested in function declarators.  */
  679. setspecs: /* empty */
  680.         { $$ = suspend_momentary ();
  681.           pending_xref_error ();
  682.           declspec_stack = tree_cons (NULL_TREE, current_declspecs,
  683.                           declspec_stack);
  684.           current_declspecs = $<ttype>0; }
  685.     ;
  686.  
  687. decl:
  688.     typed_declspecs setspecs initdecls ';'
  689.         { current_declspecs = TREE_VALUE (declspec_stack);
  690.           declspec_stack = TREE_CHAIN (declspec_stack);
  691.           resume_momentary ($2); }
  692.     | declmods setspecs notype_initdecls ';'
  693.         { current_declspecs = TREE_VALUE (declspec_stack);
  694.           declspec_stack = TREE_CHAIN (declspec_stack);
  695.           resume_momentary ($2); }
  696.     | typed_declspecs setspecs nested_function
  697.         { current_declspecs = TREE_VALUE (declspec_stack);
  698.           declspec_stack = TREE_CHAIN (declspec_stack);
  699.           resume_momentary ($2); }
  700.     | declmods setspecs notype_nested_function
  701.         { current_declspecs = TREE_VALUE (declspec_stack);
  702.           declspec_stack = TREE_CHAIN (declspec_stack);
  703.           resume_momentary ($2); }
  704.     | typed_declspecs ';'
  705.         { shadow_tag ($1); }
  706.     | declmods ';'
  707.         { pedwarn ("empty declaration"); }
  708.     ;
  709.  
  710. /* Declspecs which contain at least one type specifier or typedef name.
  711.    (Just `const' or `volatile' is not enough.)
  712.    A typedef'd name following these is taken as a name to be declared.  */
  713.  
  714. typed_declspecs:
  715.       typespec reserved_declspecs
  716.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  717.     | declmods typespec reserved_declspecs
  718.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  719.     ;
  720.  
  721. reserved_declspecs:  /* empty */
  722.         { $$ = NULL_TREE; }
  723.     | reserved_declspecs typespecqual_reserved
  724.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  725.     | reserved_declspecs SCSPEC
  726.         { if (extra_warnings)
  727.             warning ("`%s' is not at beginning of declaration",
  728.                  IDENTIFIER_POINTER ($2));
  729.           $$ = tree_cons (NULL_TREE, $2, $1); }
  730.     ;
  731.  
  732. /* List of just storage classes and type modifiers.
  733.    A declaration can start with just this, but then it cannot be used
  734.    to redeclare a typedef-name.  */
  735.  
  736. declmods:
  737.       TYPE_QUAL
  738.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  739.           TREE_STATIC ($$) = 1; }
  740.     | SCSPEC
  741.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  742.     | declmods TYPE_QUAL
  743.         { $$ = tree_cons (NULL_TREE, $2, $1);
  744.           TREE_STATIC ($$) = 1; }
  745.     | declmods SCSPEC
  746.         { if (extra_warnings && TREE_STATIC ($1))
  747.             warning ("`%s' is not at beginning of declaration",
  748.                  IDENTIFIER_POINTER ($2));
  749.           $$ = tree_cons (NULL_TREE, $2, $1);
  750.           TREE_STATIC ($$) = TREE_STATIC ($1); }
  751.     ;
  752.  
  753.  
  754. /* Used instead of declspecs where storage classes are not allowed
  755.    (that is, for typenames and structure components).
  756.    Don't accept a typedef-name if anything but a modifier precedes it.  */
  757.  
  758. typed_typespecs:
  759.       typespec reserved_typespecquals
  760.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  761.     | nonempty_type_quals typespec reserved_typespecquals
  762.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  763.     ;
  764.  
  765. reserved_typespecquals:  /* empty */
  766.         { $$ = NULL_TREE; }
  767.     | reserved_typespecquals typespecqual_reserved
  768.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  769.     ;
  770.  
  771. /* A typespec (but not a type qualifier).
  772.    Once we have seen one of these in a declaration,
  773.    if a typedef name appears then it is being redeclared.  */
  774.  
  775. typespec: TYPESPEC
  776.     | structsp
  777.     | TYPENAME
  778.         { /* For a typedef name, record the meaning, not the name.
  779.              In case of `foo foo, bar;'.  */
  780.           $$ = lookup_name ($1); }
  781.     | TYPEOF '(' expr ')'
  782.         { $$ = TREE_TYPE ($3); }
  783.     | TYPEOF '(' typename ')'
  784.         { $$ = groktypename ($3); }
  785.     ;
  786.  
  787. /* A typespec that is a reserved word, or a type qualifier.  */
  788.  
  789. typespecqual_reserved: TYPESPEC
  790.     | TYPE_QUAL
  791.     | structsp
  792.     ;
  793.  
  794. initdecls:
  795.     initdcl
  796.     | initdecls ',' initdcl
  797.     ;
  798.  
  799. notype_initdecls:
  800.     notype_initdcl
  801.     | notype_initdecls ',' initdcl
  802.     ;
  803.  
  804. maybeasm:
  805.       /* empty */
  806.         { $$ = NULL_TREE; }
  807.     | ASM_KEYWORD '(' string ')'
  808.         { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
  809.           $$ = $3;
  810.         }
  811.     ;
  812.  
  813. initdcl:
  814.       declarator maybeasm maybe_attribute '='
  815.         { $<ttype>$ = start_decl ($1, current_declspecs, 1); }
  816.       init
  817. /* Note how the declaration of the variable is in effect while its init is parsed! */
  818.         { decl_attributes ($<ttype>5, $3);
  819.           finish_decl ($<ttype>5, $6, $2); }
  820.     | declarator maybeasm maybe_attribute
  821.         { tree d = start_decl ($1, current_declspecs, 0);
  822.           decl_attributes (d, $3);
  823.           finish_decl (d, NULL_TREE, $2); }
  824.     ;
  825.  
  826. notype_initdcl:
  827.       notype_declarator maybeasm maybe_attribute '='
  828.         { $<ttype>$ = start_decl ($1, current_declspecs, 1); }
  829.       init
  830. /* Note how the declaration of the variable is in effect while its init is parsed! */
  831.         { decl_attributes ($<ttype>5, $3);
  832.           finish_decl ($<ttype>5, $6, $2); }
  833.     | notype_declarator maybeasm maybe_attribute
  834.         { tree d = start_decl ($1, current_declspecs, 0);
  835.           decl_attributes (d, $3);
  836.           finish_decl (d, NULL_TREE, $2); }
  837.     ;
  838. /* the * rules are dummies to accept the Apollo extended syntax
  839.    so that the header files compile. */
  840. maybe_attribute:
  841.     /* empty */
  842.         { $$ = NULL_TREE; }
  843.     | ATTRIBUTE '(' '(' attribute_list ')' ')'
  844.         { $$ = $4; }
  845.     ;
  846.  
  847. attribute_list
  848.     : attrib
  849.     { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  850.     | attribute_list ',' attrib
  851.     { $$ = tree_cons (NULL_TREE, $3, $1); }
  852.     ;
  853.  
  854. attrib
  855.     : IDENTIFIER
  856.     {
  857. #ifdef HANDLE_ATTRIBUTE0
  858.       /* give the function a chance to validate further attributes */
  859.       if (HANDLE_ATTRIBUTE0 (IDENTIFIER_POINTER ($1)) ||
  860.           strcmp (IDENTIFIER_POINTER ($1), "packed"))
  861. #else
  862.       if (strcmp (IDENTIFIER_POINTER ($1), "packed"))
  863. #endif
  864.         warning ("`%s' attribute directive ignored",
  865.              IDENTIFIER_POINTER ($1));
  866.       $$ = $1; }
  867.     | IDENTIFIER '(' IDENTIFIER ')'
  868.     { /* If not "mode (m)", then issue warning.  */
  869.       if (strcmp (IDENTIFIER_POINTER ($1), "mode") != 0)
  870.         {
  871.           warning ("`%s' attribute directive ignored",
  872.                IDENTIFIER_POINTER ($1));
  873.           $$ = $1;
  874.         }
  875.       else
  876.         $$ = tree_cons ($1, $3, NULL_TREE); }
  877.     | IDENTIFIER '(' CONSTANT ')'
  878.     { /* if not "aligned(n)", then issue warning */
  879.       if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0
  880.           || TREE_CODE ($3) != INTEGER_CST)
  881.         {
  882.           warning ("`%s' attribute directive ignored",
  883.                IDENTIFIER_POINTER ($1));
  884.           $$ = $1;
  885.         }
  886.       else
  887.         $$ = tree_cons ($1, $3, NULL_TREE); }
  888.     | IDENTIFIER '(' IDENTIFIER ',' CONSTANT ',' CONSTANT ')'
  889.     { /* if not "format(...)", then issue warning */
  890.       if (strcmp (IDENTIFIER_POINTER ($1), "format") != 0
  891.           || TREE_CODE ($5) != INTEGER_CST
  892.           || TREE_CODE ($7) != INTEGER_CST)
  893.         {
  894.           warning ("`%s' attribute directive ignored",
  895.                IDENTIFIER_POINTER ($1));
  896.           $$ = $1;
  897.         }
  898.       else
  899.         $$ = tree_cons ($1,
  900.                 tree_cons ($3,
  901.                        tree_cons ($5, $7, NULL_TREE),
  902.                        NULL_TREE),
  903.                 NULL_TREE); }
  904.     ;
  905.  
  906. init:
  907.     expr_no_commas
  908.     | '{' '}'
  909.         { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
  910.           if (pedantic)
  911.             pedwarn ("ANSI C forbids empty initializer braces"); }
  912.     | '{' initlist '}'
  913.         { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); }
  914.     | '{' initlist ',' '}'
  915.         { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); }
  916.     | error
  917.         { $$ = NULL_TREE; }
  918.     ;
  919.  
  920. /* This chain is built in reverse order,
  921.    and put in forward order where initlist is used.  */
  922. initlist:
  923.       init
  924.         { $$ = build_tree_list (NULL_TREE, $1); }
  925.     | initlist ',' init
  926.         { $$ = tree_cons (NULL_TREE, $3, $1); }
  927.     /* These are for labeled elements.  */
  928.     | '[' expr_no_commas ELLIPSIS expr_no_commas ']' init
  929.         { $$ = build_tree_list (tree_cons ($2, NULL_TREE,
  930.                            build_tree_list ($4, NULL_TREE)),
  931.                     $6); }
  932.     | initlist ',' '[' expr_no_commas ELLIPSIS expr_no_commas ']' init
  933.         { $$ = tree_cons (tree_cons ($4, NULL_TREE,
  934.                          build_tree_list ($6, NULL_TREE)),
  935.                   $8,
  936.                   $1); }
  937.     | '[' expr_no_commas ']' init
  938.         { $$ = build_tree_list ($2, $4); }
  939.     | initlist ',' '[' expr_no_commas ']' init
  940.         { $$ = tree_cons ($4, $6, $1); }
  941.     | identifier ':' init
  942.         { $$ = build_tree_list ($1, $3); }
  943.     | initlist ',' identifier ':' init
  944.         { $$ = tree_cons ($3, $5, $1); }
  945.     ;
  946.  
  947. nested_function:
  948.       declarator
  949.         { push_c_function_context ();
  950.           if (! start_function (current_declspecs, $1, 1))
  951.             {
  952.               pop_c_function_context ();
  953.               YYERROR1;
  954.             }
  955.           reinit_parse_for_function ();
  956.           store_parm_decls (); }
  957. /* This used to use compstmt_or_error.
  958.    That caused a bug with input `f(g) int g {}',
  959.    where the use of YYERROR1 above caused an error
  960.    which then was handled by compstmt_or_error.
  961.    There followed a repeated execution of that same rule,
  962.    which called YYERROR1 again, and so on.  */
  963.       compstmt
  964.         { finish_function (1);
  965.           pop_c_function_context (); }
  966.     ;
  967.  
  968. notype_nested_function:
  969.       notype_declarator
  970.         { push_c_function_context ();
  971.           if (! start_function (current_declspecs, $1, 1))
  972.             {
  973.               pop_c_function_context ();
  974.               YYERROR1;
  975.             }
  976.           reinit_parse_for_function ();
  977.           store_parm_decls (); }
  978. /* This used to use compstmt_or_error.
  979.    That caused a bug with input `f(g) int g {}',
  980.    where the use of YYERROR1 above caused an error
  981.    which then was handled by compstmt_or_error.
  982.    There followed a repeated execution of that same rule,
  983.    which called YYERROR1 again, and so on.  */
  984.       compstmt
  985.         { finish_function (1);
  986.           pop_c_function_context (); }
  987.     ;
  988.  
  989. /* Any kind of declarator (thus, all declarators allowed
  990.    after an explicit typespec).  */
  991.  
  992. declarator:
  993.       after_type_declarator
  994.     | notype_declarator
  995.     ;
  996.  
  997. /* A declarator that is allowed only after an explicit typespec.  */
  998.  
  999. after_type_declarator:
  1000.       '(' after_type_declarator ')'
  1001.         { $$ = $2; }
  1002.     | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
  1003.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1004. /*    | after_type_declarator '(' error ')'  %prec '.'
  1005.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1006.           poplevel (0, 0, 0); }  */
  1007.     | after_type_declarator '[' expr ']'  %prec '.'
  1008.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1009.     | after_type_declarator '[' ']'  %prec '.'
  1010.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1011.     | '*' type_quals after_type_declarator  %prec UNARY
  1012.         { $$ = make_pointer_declarator ($2, $3); }
  1013.     | TYPENAME
  1014.     ;
  1015.  
  1016. /* Kinds of declarator that can appear in a parameter list
  1017.    in addition to notype_declarator.  This is like after_type_declarator
  1018.    but does not allow a typedef name in parentheses as an identifier
  1019.    (because it would conflict with a function with that typedef as arg).  */
  1020.  
  1021. parm_declarator:
  1022.       parm_declarator '(' parmlist_or_identifiers  %prec '.'
  1023.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1024. /*    | parm_declarator '(' error ')'  %prec '.'
  1025.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1026.           poplevel (0, 0, 0); }  */
  1027.     | parm_declarator '[' expr ']'  %prec '.'
  1028.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1029.     | parm_declarator '[' ']'  %prec '.'
  1030.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1031.     | '*' type_quals parm_declarator  %prec UNARY
  1032.         { $$ = make_pointer_declarator ($2, $3); }
  1033.     | TYPENAME
  1034.     ;
  1035.  
  1036. /* A declarator allowed whether or not there has been
  1037.    an explicit typespec.  These cannot redeclare a typedef-name.  */
  1038.  
  1039. notype_declarator:
  1040.       notype_declarator '(' parmlist_or_identifiers  %prec '.'
  1041.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1042. /*    | notype_declarator '(' error ')'  %prec '.'
  1043.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1044.           poplevel (0, 0, 0); }  */
  1045.     | '(' notype_declarator ')'
  1046.         { $$ = $2; }
  1047.     | '*' type_quals notype_declarator  %prec UNARY
  1048.         { $$ = make_pointer_declarator ($2, $3); }
  1049.     | notype_declarator '[' expr ']'  %prec '.'
  1050.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1051.     | notype_declarator '[' ']'  %prec '.'
  1052.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1053.     | IDENTIFIER
  1054.     ;
  1055.  
  1056. structsp:
  1057.       STRUCT identifier '{'
  1058.         { $$ = start_struct (RECORD_TYPE, $2);
  1059.           /* Start scope of tag before parsing components.  */
  1060.         }
  1061.       component_decl_list '}'
  1062.         { $$ = finish_struct ($<ttype>4, $5);
  1063.           /* Really define the structure.  */
  1064.         }
  1065.     | STRUCT '{' component_decl_list '}'
  1066.         { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
  1067.                       $3); }
  1068.     | STRUCT identifier
  1069.         { $$ = xref_tag (RECORD_TYPE, $2); }
  1070.     | UNION identifier '{'
  1071.         { $$ = start_struct (UNION_TYPE, $2); }
  1072.       component_decl_list '}'
  1073.         { $$ = finish_struct ($<ttype>4, $5); }
  1074.     | UNION '{' component_decl_list '}'
  1075.         { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
  1076.                       $3); }
  1077.     | UNION identifier
  1078.         { $$ = xref_tag (UNION_TYPE, $2); }
  1079.     | ENUM identifier '{'
  1080.         { $<itype>3 = suspend_momentary ();
  1081.           $$ = start_enum ($2); }
  1082.       enumlist maybecomma_warn '}'
  1083.         { $$ = finish_enum ($<ttype>4, nreverse ($5));
  1084.           resume_momentary ($<itype>3); }
  1085.     | ENUM '{'
  1086.         { $<itype>2 = suspend_momentary ();
  1087.           $$ = start_enum (NULL_TREE); }
  1088.       enumlist maybecomma_warn '}'
  1089.         { $$ = finish_enum ($<ttype>3, nreverse ($4));
  1090.           resume_momentary ($<itype>2); }
  1091.     | ENUM identifier
  1092.         { $$ = xref_tag (ENUMERAL_TYPE, $2); }
  1093.     ;
  1094.  
  1095. maybecomma:
  1096.       /* empty */
  1097.     | ','
  1098.     ;
  1099.  
  1100. maybecomma_warn:
  1101.       /* empty */
  1102.     | ','
  1103.         { if (pedantic) pedwarn ("comma at end of enumerator list"); }
  1104.     ;
  1105.  
  1106. component_decl_list:
  1107.       component_decl_list2
  1108.         { $$ = $1; }
  1109.     | component_decl_list2 component_decl
  1110.         { $$ = chainon ($1, $2);
  1111.           pedwarn ("no semicolon at end of struct or union"); }
  1112.     ;
  1113.  
  1114. component_decl_list2:    /* empty */
  1115.         { $$ = NULL_TREE; }
  1116.     | component_decl_list2 component_decl ';'
  1117.         { $$ = chainon ($1, $2); }
  1118.     | component_decl_list2 ';'
  1119.         { if (pedantic)
  1120.             pedwarn ("extra semicolon in struct or union specified"); }
  1121.     ;
  1122.  
  1123. /* There is a shift-reduce conflict here, because `components' may
  1124.    start with a `typename'.  It happens that shifting (the default resolution)
  1125.    does the right thing, because it treats the `typename' as part of
  1126.    a `typed_typespecs'.
  1127.  
  1128.    It is possible that this same technique would allow the distinction
  1129.    between `notype_initdecls' and `initdecls' to be eliminated.
  1130.    But I am being cautious and not trying it.  */
  1131.  
  1132. component_decl:
  1133.       typed_typespecs setspecs components
  1134.         { $$ = $3;
  1135.           current_declspecs = TREE_VALUE (declspec_stack);
  1136.           declspec_stack = TREE_CHAIN (declspec_stack);
  1137.           resume_momentary ($2); }
  1138.     | typed_typespecs
  1139.         { if (pedantic)
  1140.             pedwarn ("ANSI C forbids member declarations with no members");
  1141.           shadow_tag($1);
  1142.           $$ = NULL_TREE; }
  1143.     | nonempty_type_quals setspecs components
  1144.         { $$ = $3;
  1145.           current_declspecs = TREE_VALUE (declspec_stack);
  1146.           declspec_stack = TREE_CHAIN (declspec_stack);
  1147.           resume_momentary ($2); }
  1148.     | nonempty_type_quals
  1149.         { if (pedantic)
  1150.             pedwarn ("ANSI C forbids member declarations with no members");
  1151.           shadow_tag($1);
  1152.           $$ = NULL_TREE; }
  1153.     | error
  1154.         { $$ = NULL_TREE; }
  1155.     ;
  1156.  
  1157. components:
  1158.       component_declarator
  1159.     | components ',' component_declarator
  1160.         { $$ = chainon ($1, $3); }
  1161.     ;
  1162.  
  1163. component_declarator:
  1164.       save_filename save_lineno declarator maybe_attribute
  1165.         { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
  1166.           decl_attributes ($$, $4); }
  1167.     | save_filename save_lineno
  1168.       declarator ':' expr_no_commas maybe_attribute
  1169.         { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
  1170.           decl_attributes ($$, $6); }
  1171.     | save_filename save_lineno ':' expr_no_commas
  1172.         { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4); }
  1173.     ;
  1174.  
  1175. /* We chain the enumerators in reverse order.
  1176.    They are put in forward order where enumlist is used.
  1177.    (The order used to be significant, but no longer is so.
  1178.    However, we still maintain the order, just to be clean.)  */
  1179.  
  1180. enumlist:
  1181.       enumerator
  1182.     | enumlist ',' enumerator
  1183.         { $$ = chainon ($3, $1); }
  1184.     ;
  1185.  
  1186.  
  1187. enumerator:
  1188.       identifier
  1189.         { $$ = build_enumerator ($1, NULL_TREE); }
  1190.     | identifier '=' expr_no_commas
  1191.         { $$ = build_enumerator ($1, $3); }
  1192.     ;
  1193.  
  1194. typename:
  1195.     typed_typespecs absdcl
  1196.         { $$ = build_tree_list ($1, $2); }
  1197.     | nonempty_type_quals absdcl
  1198.         { $$ = build_tree_list ($1, $2); }
  1199.     ;
  1200.  
  1201. absdcl:   /* an absolute declarator */
  1202.     /* empty */
  1203.         { $$ = NULL_TREE; }
  1204.     | absdcl1
  1205.     ;
  1206.  
  1207. nonempty_type_quals:
  1208.       TYPE_QUAL
  1209.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  1210.     | nonempty_type_quals TYPE_QUAL
  1211.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1212.     ;
  1213.  
  1214. type_quals:
  1215.       /* empty */
  1216.         { $$ = NULL_TREE; }
  1217.     | type_quals TYPE_QUAL
  1218.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1219.     ;
  1220.  
  1221. absdcl1:  /* a nonempty absolute declarator */
  1222.       '(' absdcl1 ')'
  1223.         { $$ = $2; }
  1224.       /* `(typedef)1' is `int'.  */
  1225.     | '*' type_quals absdcl1  %prec UNARY
  1226.         { $$ = make_pointer_declarator ($2, $3); }
  1227.     | '*' type_quals  %prec UNARY
  1228.         { $$ = make_pointer_declarator ($2, NULL_TREE); }
  1229.     | absdcl1 '(' parmlist  %prec '.'
  1230.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1231.     | absdcl1 '[' expr ']'  %prec '.'
  1232.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1233.     | absdcl1 '[' ']'  %prec '.'
  1234.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1235.     | '(' parmlist  %prec '.'
  1236.         { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
  1237.     | '[' expr ']'  %prec '.'
  1238.         { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
  1239.     | '[' ']'  %prec '.'
  1240.         { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
  1241.     ;
  1242.  
  1243. /* at least one statement, the first of which parses without error.  */
  1244. /* stmts is used only after decls, so an invalid first statement
  1245.    is actually regarded as an invalid decl and part of the decls.  */
  1246.  
  1247. stmts:
  1248.       lineno_stmt_or_label
  1249.     | stmts lineno_stmt_or_label
  1250.     | stmts errstmt
  1251.     ;
  1252.  
  1253. xstmts:
  1254.     /* empty */
  1255.     | stmts
  1256.     ;
  1257.  
  1258. errstmt:  error ';'
  1259.     ;
  1260.  
  1261. pushlevel:  /* empty */
  1262.         { emit_line_note (input_filename, lineno);
  1263.           pushlevel (0);
  1264.           clear_last_expr ();
  1265.           push_momentary ();
  1266.           expand_start_bindings (0);
  1267.         }
  1268.     ;
  1269.  
  1270. /* Read zero or more forward-declarations for labels
  1271.    that nested functions can jump to.  */
  1272. maybe_label_decls:
  1273.       /* empty */
  1274.     | label_decls
  1275.         { if (pedantic)
  1276.             pedwarn ("ANSI C forbids label declarations"); }
  1277.     ;
  1278.  
  1279. label_decls:
  1280.       label_decl
  1281.     | label_decls label_decl
  1282.     ;
  1283.  
  1284. label_decl:
  1285.       LABEL identifiers_or_typenames ';'
  1286.         { tree link;
  1287.           for (link = $2; link; link = TREE_CHAIN (link))
  1288.             {
  1289.               tree label = shadow_label (TREE_VALUE (link));
  1290.               C_DECLARED_LABEL_FLAG (label) = 1;
  1291.               declare_nonlocal_label (label);
  1292.             }
  1293.         }
  1294.     ;
  1295.  
  1296. /* This is the body of a function definition.
  1297.    It causes syntax errors to ignore to the next openbrace.  */
  1298. compstmt_or_error:
  1299.       compstmt
  1300.         {}
  1301.     | error compstmt
  1302.     ;
  1303.  
  1304. compstmt: '{' '}'
  1305.         { $$ = convert (void_type_node, integer_zero_node); }
  1306.     | '{' pushlevel maybe_label_decls decls xstmts '}'
  1307.         { emit_line_note (input_filename, lineno);
  1308.           expand_end_bindings (getdecls (), 1, 0);
  1309.           $$ = poplevel (1, 1, 0);
  1310.           pop_momentary (); }
  1311.     | '{' pushlevel maybe_label_decls error '}'
  1312.         { emit_line_note (input_filename, lineno);
  1313.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1314.           $$ = poplevel (kept_level_p (), 0, 0);
  1315.           pop_momentary (); }
  1316.     | '{' pushlevel maybe_label_decls stmts '}'
  1317.         { emit_line_note (input_filename, lineno);
  1318.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1319.           $$ = poplevel (kept_level_p (), 0, 0);
  1320.           pop_momentary (); }
  1321.     ;
  1322.  
  1323. /* Value is number of statements counted as of the closeparen.  */
  1324. simple_if:
  1325.       if_prefix lineno_labeled_stmt
  1326. /* Make sure expand_end_cond is run once
  1327.    for each call to expand_start_cond.
  1328.    Otherwise a crash is likely.  */
  1329.     | if_prefix error
  1330.     ;
  1331.  
  1332. if_prefix:
  1333.       IF '(' expr ')'
  1334.         { emit_line_note ($<filename>-1, $<lineno>0);
  1335.           expand_start_cond (truthvalue_conversion ($3), 0);
  1336.           $<itype>1 = stmt_count;
  1337.           if_stmt_file = $<filename>-1;
  1338.           if_stmt_line = $<lineno>0;
  1339.           position_after_white_space (); }
  1340.     ;
  1341.  
  1342. /* This is a subroutine of stmt.
  1343.    It is used twice, once for valid DO statements
  1344.    and once for catching errors in parsing the end test.  */
  1345. do_stmt_start:
  1346.       DO
  1347.         { stmt_count++;
  1348.           emit_line_note ($<filename>-1, $<lineno>0);
  1349.           /* See comment in `while' alternative, above.  */
  1350.           emit_nop ();
  1351.           expand_start_loop_continue_elsewhere (1);
  1352.           position_after_white_space (); }
  1353.       lineno_labeled_stmt WHILE
  1354.         { expand_loop_continue_here (); }
  1355.     ;
  1356.  
  1357. save_filename:
  1358.         { $$ = input_filename; }
  1359.     ;
  1360.  
  1361. save_lineno:
  1362.         { $$ = lineno; }
  1363.     ;
  1364.  
  1365. lineno_labeled_stmt:
  1366.       save_filename save_lineno stmt
  1367.         { }
  1368. /*    | save_filename save_lineno error
  1369.         { }
  1370. */
  1371.     | save_filename save_lineno label lineno_labeled_stmt
  1372.         { }
  1373.     ;
  1374.  
  1375. lineno_stmt_or_label:
  1376.       save_filename save_lineno stmt_or_label
  1377.         { }
  1378.     ;
  1379.  
  1380. stmt_or_label:
  1381.       stmt
  1382.     | label
  1383.         { int next;
  1384.           position_after_white_space ();
  1385.           next = getc (finput);
  1386.           ungetc (next, finput);
  1387.           if (pedantic && next == '}')
  1388.             pedwarn ("ANSI C forbids label at end of compound statement");
  1389.         }
  1390.     ;
  1391.  
  1392. /* Parse a single real statement, not including any labels.  */
  1393. stmt:
  1394.       compstmt
  1395.         { stmt_count++; }
  1396.     | expr ';'
  1397.         { stmt_count++;
  1398.           emit_line_note ($<filename>-1, $<lineno>0);
  1399.           c_expand_expr_stmt ($1);
  1400.           clear_momentary (); }
  1401.     | simple_if ELSE
  1402.         { expand_start_else ();
  1403.           $<itype>1 = stmt_count;
  1404.           position_after_white_space (); }
  1405.       lineno_labeled_stmt
  1406.         { expand_end_cond ();
  1407.           if (extra_warnings && stmt_count == $<itype>1)
  1408.             warning ("empty body in an else-statement"); }
  1409.     | simple_if %prec IF
  1410.         { expand_end_cond ();
  1411.           if (extra_warnings && stmt_count == $<itype>1)
  1412.             warning_with_file_and_line (if_stmt_file, if_stmt_line,
  1413.                         "empty body in an if-statement"); }
  1414. /* Make sure expand_end_cond is run once
  1415.    for each call to expand_start_cond.
  1416.    Otherwise a crash is likely.  */
  1417.     | simple_if ELSE error
  1418.         { expand_end_cond (); }
  1419.     | WHILE
  1420.         { stmt_count++;
  1421.           emit_line_note ($<filename>-1, $<lineno>0);
  1422.           /* The emit_nop used to come before emit_line_note,
  1423.              but that made the nop seem like part of the preceding line.
  1424.              And that was confusing when the preceding line was
  1425.              inside of an if statement and was not really executed.
  1426.              I think it ought to work to put the nop after the line number.
  1427.              We will see.  --rms, July 15, 1991.  */
  1428.           emit_nop (); }
  1429.       '(' expr ')'
  1430.         { /* Don't start the loop till we have succeeded
  1431.              in parsing the end test.  This is to make sure
  1432.              that we end every loop we start.  */
  1433.           expand_start_loop (1);
  1434.           emit_line_note (input_filename, lineno);
  1435.           expand_exit_loop_if_false (NULL_PTR,
  1436.                          truthvalue_conversion ($4));
  1437.           position_after_white_space (); }
  1438.       lineno_labeled_stmt
  1439.         { expand_end_loop (); }
  1440.     | do_stmt_start
  1441.       '(' expr ')' ';'
  1442.         { emit_line_note (input_filename, lineno);
  1443.           expand_exit_loop_if_false (NULL_PTR,
  1444.                          truthvalue_conversion ($3));
  1445.           expand_end_loop ();
  1446.           clear_momentary (); }
  1447. /* This rule is needed to make sure we end every loop we start.  */
  1448.     | do_stmt_start error
  1449.         { expand_end_loop ();
  1450.           clear_momentary (); }
  1451.     | FOR
  1452.       '(' xexpr ';'
  1453.         { stmt_count++;
  1454.           emit_line_note ($<filename>-1, $<lineno>0);
  1455.           /* See comment in `while' alternative, above.  */
  1456.           emit_nop ();
  1457.           if ($3) c_expand_expr_stmt ($3);
  1458.           /* Next step is to call expand_start_loop_continue_elsewhere,
  1459.              but wait till after we parse the entire for (...).
  1460.              Otherwise, invalid input might cause us to call that
  1461.              fn without calling expand_end_loop.  */
  1462.         }
  1463.       xexpr ';'
  1464.         /* Can't emit now; wait till after expand_start_loop...  */
  1465.         { $<lineno>7 = lineno;
  1466.           $<filename>$ = input_filename; }
  1467.       xexpr ')'
  1468.         { 
  1469.           /* Start the loop.  Doing this after parsing
  1470.              all the expressions ensures we will end the loop.  */
  1471.           expand_start_loop_continue_elsewhere (1);
  1472.           /* Emit the end-test, with a line number.  */
  1473.           emit_line_note ($<filename>8, $<lineno>7);
  1474.           if ($6)
  1475.             expand_exit_loop_if_false (NULL_PTR,
  1476.                            truthvalue_conversion ($6));
  1477.           /* Don't let the tree nodes for $9 be discarded by
  1478.              clear_momentary during the parsing of the next stmt.  */
  1479.           push_momentary ();
  1480.           $<lineno>7 = lineno;
  1481.           $<filename>8 = input_filename; }
  1482.       lineno_labeled_stmt
  1483.         { /* Emit the increment expression, with a line number.  */
  1484.           emit_line_note ($<filename>8, $<lineno>7);
  1485.           expand_loop_continue_here ();
  1486.           if ($9)
  1487.             c_expand_expr_stmt ($9);
  1488.           pop_momentary ();
  1489.           expand_end_loop (); }
  1490.     | SWITCH '(' expr ')'
  1491.         { stmt_count++;
  1492.           emit_line_note ($<filename>-1, $<lineno>0);
  1493.           c_expand_start_case ($3);
  1494.           /* Don't let the tree nodes for $3 be discarded by
  1495.              clear_momentary during the parsing of the next stmt.  */
  1496.           push_momentary ();
  1497.           position_after_white_space (); }
  1498.       lineno_labeled_stmt
  1499.         { expand_end_case ($3);
  1500.           pop_momentary (); }
  1501.     | BREAK ';'
  1502.         { stmt_count++;
  1503.           emit_line_note ($<filename>-1, $<lineno>0);
  1504.           if ( ! expand_exit_something ())
  1505.             error ("break statement not within loop or switch"); }
  1506.     | CONTINUE ';'
  1507.         { stmt_count++;
  1508.           emit_line_note ($<filename>-1, $<lineno>0);
  1509.           if (! expand_continue_loop (NULL_PTR))
  1510.             error ("continue statement not within a loop"); }
  1511.     | RETURN ';'
  1512.         { stmt_count++;
  1513.           emit_line_note ($<filename>-1, $<lineno>0);
  1514.           c_expand_return (NULL_TREE); }
  1515.     | RETURN expr ';'
  1516.         { stmt_count++;
  1517.           emit_line_note ($<filename>-1, $<lineno>0);
  1518.           c_expand_return ($2); }
  1519.     | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
  1520.         { stmt_count++;
  1521.           emit_line_note ($<filename>-1, $<lineno>0);
  1522.           STRIP_NOPS ($4);
  1523.           if ((TREE_CODE ($4) == ADDR_EXPR
  1524.                && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
  1525.               || TREE_CODE ($4) == STRING_CST)
  1526.             expand_asm ($4);
  1527.           else
  1528.             error ("argument of `asm' is not a constant string"); }
  1529.     /* This is the case with just output operands.  */
  1530.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
  1531.         { stmt_count++;
  1532.           emit_line_note ($<filename>-1, $<lineno>0);
  1533.           c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
  1534.                      $2 == ridpointers[(int)RID_VOLATILE],
  1535.                      input_filename, lineno); }
  1536.     /* This is the case with input operands as well.  */
  1537.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
  1538.         { stmt_count++;
  1539.           emit_line_note ($<filename>-1, $<lineno>0);
  1540.           c_expand_asm_operands ($4, $6, $8, NULL_TREE,
  1541.                      $2 == ridpointers[(int)RID_VOLATILE],
  1542.                      input_filename, lineno); }
  1543.     /* This is the case with clobbered registers as well.  */
  1544.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
  1545.         asm_operands ':' asm_clobbers ')' ';'
  1546.         { stmt_count++;
  1547.           emit_line_note ($<filename>-1, $<lineno>0);
  1548.           c_expand_asm_operands ($4, $6, $8, $10,
  1549.                      $2 == ridpointers[(int)RID_VOLATILE],
  1550.                      input_filename, lineno); }
  1551.     | GOTO identifier ';'
  1552.         { tree decl;
  1553.           stmt_count++;
  1554.           emit_line_note ($<filename>-1, $<lineno>0);
  1555.           decl = lookup_label ($2);
  1556.           if (decl != 0)
  1557.             {
  1558.               TREE_USED (decl) = 1;
  1559.               expand_goto (decl);
  1560.             }
  1561.         }
  1562.     | GOTO '*' expr ';'
  1563.         { stmt_count++;
  1564.           emit_line_note ($<filename>-1, $<lineno>0);
  1565.           expand_computed_goto (convert (ptr_type_node, $3)); }
  1566.     | ';'
  1567.     ;
  1568.  
  1569. /* Any kind of label, including jump labels and case labels.
  1570.    ANSI C accepts labels only before statements, but we allow them
  1571.    also at the end of a compound statement.  */
  1572.  
  1573. label:      CASE expr ':'
  1574.         { register tree value = check_case_value ($2);
  1575.           register tree label
  1576.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1577.  
  1578.           stmt_count++;
  1579.  
  1580.           if (value != error_mark_node)
  1581.             {
  1582.               tree duplicate;
  1583.               int success = pushcase (value, label, &duplicate);
  1584.               if (success == 1)
  1585.             error ("case label not within a switch statement");
  1586.               else if (success == 2)
  1587.             {
  1588.               error ("duplicate case value");
  1589.               error_with_decl (duplicate, "this is the first entry for that value");
  1590.             }
  1591.               else if (success == 3)
  1592.             warning ("case value out of range");
  1593.               else if (success == 5)
  1594.             error ("case label within scope of cleanup or variable array");
  1595.             }
  1596.           position_after_white_space (); }
  1597.     | CASE expr ELLIPSIS expr ':'
  1598.         { register tree value1 = check_case_value ($2);
  1599.           register tree value2 = check_case_value ($4);
  1600.           register tree label
  1601.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1602.  
  1603.           stmt_count++;
  1604.  
  1605.           if (value1 != error_mark_node && value2 != error_mark_node)
  1606.             {
  1607.               tree duplicate;
  1608.               int success = pushcase_range (value1, value2, label,
  1609.                             &duplicate);
  1610.               if (success == 1)
  1611.             error ("case label not within a switch statement");
  1612.               else if (success == 2)
  1613.             {
  1614.               error ("duplicate case value");
  1615.               error_with_decl (duplicate, "this is the first entry for that value");
  1616.             }
  1617.               else if (success == 3)
  1618.             warning ("case value out of range");
  1619.               else if (success == 4)
  1620.             warning ("empty case range");
  1621.               else if (success == 5)
  1622.             error ("case label within scope of cleanup or variable array");
  1623.             }
  1624.           position_after_white_space (); }
  1625.     | DEFAULT ':'
  1626.         {
  1627.           tree duplicate;
  1628.           register tree label
  1629.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1630.           int success = pushcase (NULL_TREE, label, &duplicate);
  1631.           stmt_count++;
  1632.           if (success == 1)
  1633.             error ("default label not within a switch statement");
  1634.           else if (success == 2)
  1635.             {
  1636.               error ("multiple default labels in one switch");
  1637.               error_with_decl (duplicate, "this is the first default label");
  1638.             }
  1639.           position_after_white_space (); }
  1640.     | identifier ':'
  1641.         { tree label = define_label (input_filename, lineno, $1);
  1642.           stmt_count++;
  1643.           emit_nop ();
  1644.           if (label)
  1645.             expand_label (label);
  1646.           position_after_white_space (); }
  1647.     ;
  1648.  
  1649. /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
  1650.  
  1651. maybe_type_qual:
  1652.     /* empty */
  1653.         { emit_line_note (input_filename, lineno); }
  1654.     | TYPE_QUAL
  1655.         { emit_line_note (input_filename, lineno); }
  1656.     ;
  1657.  
  1658. xexpr:
  1659.     /* empty */
  1660.         { $$ = NULL_TREE; }
  1661.     | expr
  1662.     ;
  1663.  
  1664. /* These are the operands other than the first string and colon
  1665.    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
  1666. asm_operands: /* empty */
  1667.         { $$ = NULL_TREE; }
  1668.     | nonnull_asm_operands
  1669.     ;
  1670.  
  1671. nonnull_asm_operands:
  1672.       asm_operand
  1673.     | nonnull_asm_operands ',' asm_operand
  1674.         { $$ = chainon ($1, $3); }
  1675.     ;
  1676.  
  1677. asm_operand:
  1678.       STRING '(' expr ')'
  1679.         { $$ = build_tree_list ($1, $3); }
  1680.     ;
  1681.  
  1682. asm_clobbers:
  1683.       string
  1684.         { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
  1685.     | asm_clobbers ',' string
  1686.         { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
  1687.     ;
  1688.  
  1689. /* This is what appears inside the parens in a function declarator.
  1690.    Its value is a list of ..._TYPE nodes.  */
  1691. parmlist:
  1692.         { pushlevel (0);
  1693.           clear_parm_order ();
  1694.           declare_parm_level (0); }
  1695.       parmlist_1
  1696.         { $$ = $2;
  1697.           parmlist_tags_warning ();
  1698.           poplevel (0, 0, 0); }
  1699.     ;
  1700.  
  1701. parmlist_1:
  1702.       parmlist_2 ')'
  1703.     | parms ';'
  1704.         { tree parm;
  1705.           if (pedantic)
  1706.             pedwarn ("ANSI C forbids forward parameter declarations");
  1707.           /* Mark the forward decls as such.  */
  1708.           for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
  1709.             TREE_ASM_WRITTEN (parm) = 1;
  1710.           clear_parm_order (); }
  1711.       parmlist_1
  1712.         { $$ = $4; }
  1713.     | error ')'
  1714.         { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
  1715.     ;
  1716.  
  1717. /* This is what appears inside the parens in a function declarator.
  1718.    Is value is represented in the format that grokdeclarator expects.  */
  1719. parmlist_2:  /* empty */
  1720.         { $$ = get_parm_info (0); }
  1721.     | ELLIPSIS
  1722.         { $$ = get_parm_info (0);
  1723.           if (pedantic)
  1724.             pedwarn ("ANSI C requires a named argument before `...'");
  1725.         }
  1726.     | parms
  1727.         { $$ = get_parm_info (1); }
  1728.     | parms ',' ELLIPSIS
  1729.         { $$ = get_parm_info (0); }
  1730.     ;
  1731.  
  1732. parms:
  1733.     parm
  1734.         { push_parm_decl ($1); }
  1735.     | parms ',' parm
  1736.         { push_parm_decl ($3); }
  1737.     ;
  1738.  
  1739. /* A single parameter declaration or parameter type name,
  1740.    as found in a parmlist.  */
  1741. parm:
  1742.       typed_declspecs parm_declarator
  1743.         { $$ = build_tree_list ($1, $2)    ; }
  1744.     | typed_declspecs notype_declarator
  1745.         { $$ = build_tree_list ($1, $2)    ; }
  1746.     | typed_declspecs absdcl
  1747.         { $$ = build_tree_list ($1, $2); }
  1748.     | declmods notype_declarator
  1749.         { $$ = build_tree_list ($1, $2)    ; }
  1750.     | declmods absdcl
  1751.         { $$ = build_tree_list ($1, $2); }
  1752.     ;
  1753.  
  1754. /* This is used in a function definition
  1755.    where either a parmlist or an identifier list is ok.
  1756.    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
  1757. parmlist_or_identifiers:
  1758.         { pushlevel (0);
  1759.           clear_parm_order ();
  1760.           declare_parm_level (1); }
  1761.       parmlist_or_identifiers_1
  1762.         { $$ = $2;
  1763.           parmlist_tags_warning ();
  1764.           poplevel (0, 0, 0); }
  1765.     ;
  1766.  
  1767. parmlist_or_identifiers_1:
  1768.       parmlist_1
  1769.     | identifiers ')'
  1770.         { tree t;
  1771.           for (t = $1; t; t = TREE_CHAIN (t))
  1772.             if (TREE_VALUE (t) == NULL_TREE)
  1773.               error ("`...' in old-style identifier list");
  1774.           $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
  1775.     ;
  1776.  
  1777. /* A nonempty list of identifiers.  */
  1778. identifiers:
  1779.     IDENTIFIER
  1780.         { $$ = build_tree_list (NULL_TREE, $1); }
  1781.     | identifiers ',' IDENTIFIER
  1782.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  1783.     ;
  1784.  
  1785. /* A nonempty list of identifiers, including typenames.  */
  1786. identifiers_or_typenames:
  1787.     identifier
  1788.         { $$ = build_tree_list (NULL_TREE, $1); }
  1789.     | identifiers_or_typenames ',' identifier
  1790.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  1791.     ;
  1792.  
  1793. %%
  1794.