home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / GCC-2.3.3r12 / Sources-C / c-parse.y < prev    next >
Encoding:
GNU Bison Grammar  |  1993-04-16  |  51.7 KB  |  1,806 lines  |  [TEXT/MPS ]

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