PageRenderTime 3ms CodeModel.GetById 3ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 1ms

/gcc/c-parse.y

https://github.com/acassis/xap-gcc
Happy | 3132 lines | 2808 code | 324 blank | 0 comment | 0 complexity | 75e13aa4d238329138d6b3add519f117 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*WARNING: This file is automatically generated!*/
   2/* YACC parser for C syntax and for Objective C.  -*-c-*-
   3   Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996,
   4   1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
   5
   6This file is part of GCC.
   7
   8GCC is free software; you can redistribute it and/or modify it under
   9the terms of the GNU General Public License as published by the Free
  10Software Foundation; either version 2, or (at your option) any later
  11version.
  12
  13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  14WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16for more details.
  17
  18You should have received a copy of the GNU General Public License
  19along with GCC; see the file COPYING.  If not, write to the Free
  20Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  2102111-1307, USA.  */
  22
  23/* This file defines the grammar of C and that of Objective C.
  24   ifobjc ... end ifobjc  conditionals contain code for Objective C only.
  25   ifc ... end ifc  conditionals contain code for C only.
  26   Sed commands in Makefile.in are used to convert this file into
  27   c-parse.y and into objc-parse.y.  */
  28
  29/* To whomever it may concern: I have heard that such a thing was once
  30   written by AT&T, but I have never seen it.  */
  31
  32%expect 10 /* shift/reduce conflicts, and no reduce/reduce conflicts.  */
  33
  34%{
  35#include "config.h"
  36#include "system.h"
  37#include "tree.h"
  38#include "input.h"
  39#include "cpplib.h"
  40#include "intl.h"
  41#include "timevar.h"
  42#include "c-pragma.h"		/* For YYDEBUG definition, and parse_in.  */
  43#include "c-tree.h"
  44#include "flags.h"
  45#include "output.h"
  46#include "toplev.h"
  47#include "ggc.h"
  48
  49#ifdef MULTIBYTE_CHARS
  50#include <locale.h>
  51#endif
  52
  53
  54/* Like YYERROR but do call yyerror.  */
  55#define YYERROR1 { yyerror ("syntax error"); YYERROR; }
  56
  57/* Like the default stack expander, except (1) use realloc when possible,
  58   (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
  59
  60   Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
  61   give malloced_yyvs its proper type.  This is ok since all we need from
  62   it is to be able to free it.  */
  63
  64static short *malloced_yyss;
  65static void *malloced_yyvs;
  66
  67#define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ)			\
  68do {									\
  69  size_t newsize;							\
  70  short *newss;								\
  71  YYSTYPE *newvs;							\
  72  newsize = *(YYSSZ) *= 2;						\
  73  if (malloced_yyss)							\
  74    {									\
  75      newss = (short *)							\
  76	really_call_realloc (*(SS), newsize * sizeof (short));		\
  77      newvs = (YYSTYPE *)						\
  78	really_call_realloc (*(VS), newsize * sizeof (YYSTYPE));	\
  79    }									\
  80  else									\
  81    {									\
  82      newss = (short *) really_call_malloc (newsize * sizeof (short));	\
  83      newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
  84      if (newss)							\
  85        memcpy (newss, *(SS), (SSSIZE));				\
  86      if (newvs)							\
  87        memcpy (newvs, *(VS), (VSSIZE));				\
  88    }									\
  89  if (!newss || !newvs)							\
  90    {									\
  91      yyerror (MSG);							\
  92      return 2;								\
  93    }									\
  94  *(SS) = newss;							\
  95  *(VS) = newvs;							\
  96  malloced_yyss = newss;						\
  97  malloced_yyvs = (void *) newvs;					\
  98} while (0)
  99%}
 100
 101%start program
 102
 103%union {long itype; tree ttype; enum tree_code code;
 104	const char *filename; int lineno; }
 105
 106/* All identifiers that are not reserved words
 107   and are not declared typedefs in the current block */
 108%token IDENTIFIER
 109
 110/* All identifiers that are declared typedefs in the current block.
 111   In some contexts, they are treated just like IDENTIFIER,
 112   but they can also serve as typespecs in declarations.  */
 113%token TYPENAME
 114
 115/* Reserved words that specify storage class.
 116   yylval contains an IDENTIFIER_NODE which indicates which one.  */
 117%token SCSPEC			/* Storage class other than static.  */
 118%token STATIC			/* Static storage class.  */
 119
 120/* Reserved words that specify type.
 121   yylval contains an IDENTIFIER_NODE which indicates which one.  */
 122%token TYPESPEC
 123
 124/* Reserved words that qualify type: "const", "volatile", or "restrict".
 125   yylval contains an IDENTIFIER_NODE which indicates which one.  */
 126%token TYPE_QUAL
 127
 128/* Character or numeric constants.
 129   yylval is the node for the constant.  */
 130%token CONSTANT
 131
 132/* String constants in raw form.
 133   yylval is a STRING_CST node.  */
 134%token STRING
 135
 136/* "...", used for functions with variable arglists.  */
 137%token ELLIPSIS
 138
 139/* the reserved words */
 140/* SCO include files test "ASM", so use something else. */
 141%token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
 142%token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
 143%token ATTRIBUTE EXTENSION LABEL
 144%token REALPART IMAGPART VA_ARG CHOOSE_EXPR TYPES_COMPATIBLE_P
 145%token PTR_VALUE PTR_BASE PTR_EXTENT
 146
 147/* function name can be a string const or a var decl. */
 148%token STRING_FUNC_NAME VAR_FUNC_NAME
 149
 150/* Add precedence rules to solve dangling else s/r conflict */
 151%nonassoc IF
 152%nonassoc ELSE
 153
 154/* Define the operator tokens and their precedences.
 155   The value is an integer because, if used, it is the tree code
 156   to use in the expression made from the operator.  */
 157
 158%right <code> ASSIGN '='
 159%right <code> '?' ':'
 160%left <code> OROR
 161%left <code> ANDAND
 162%left <code> '|'
 163%left <code> '^'
 164%left <code> '&'
 165%left <code> EQCOMPARE
 166%left <code> ARITHCOMPARE
 167%left <code> LSHIFT RSHIFT
 168%left <code> '+' '-'
 169%left <code> '*' '/' '%'
 170%right <code> UNARY PLUSPLUS MINUSMINUS
 171%left HYPERUNARY
 172%left <code> POINTSAT '.' '(' '['
 173
 174/* The Objective-C keywords.  These are included in C and in
 175   Objective C, so that the token codes are the same in both.  */
 176%token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
 177%token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
 178
 179%type <code> unop
 180%type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
 181%type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
 182
 183%type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
 184%type <ttype> expr_no_commas cast_expr unary_expr primary STRING
 185%type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
 186%type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
 187%type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
 188%type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
 189%type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
 190%type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
 191%type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
 192%type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
 193%type <ttype> declspecs_ts declspecs_nots
 194%type <ttype> declspecs_ts_nosa declspecs_nots_nosa
 195%type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
 196%type <ttype> maybe_type_quals_attrs typespec_nonattr typespec_attr
 197%type <ttype> typespec_reserved_nonattr typespec_reserved_attr
 198%type <ttype> typespec_nonreserved_nonattr
 199
 200%type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_type_qual
 201%type <ttype> initdecls notype_initdecls initdcl notype_initdcl
 202%type <ttype> init maybeasm
 203%type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
 204%type <ttype> maybe_attribute attributes attribute attribute_list attrib
 205%type <ttype> any_word extension
 206
 207%type <ttype> compstmt compstmt_start compstmt_nostart compstmt_primary_start
 208%type <ttype> do_stmt_start poplevel stmt label
 209
 210%type <ttype> c99_block_start c99_block_end
 211%type <ttype> declarator
 212%type <ttype> notype_declarator after_type_declarator
 213%type <ttype> parm_declarator
 214%type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
 215%type <ttype> array_declarator
 216
 217%type <ttype> structsp_attr structsp_nonattr
 218%type <ttype> component_decl_list component_decl_list2
 219%type <ttype> component_decl components components_notype component_declarator
 220%type <ttype> component_notype_declarator
 221%type <ttype> enumlist enumerator
 222%type <ttype> struct_head union_head enum_head
 223%type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
 224%type <ttype> direct_absdcl1 absdcl_maybe_attribute
 225%type <ttype> xexpr parms parm firstparm identifiers
 226
 227%type <ttype> parmlist parmlist_1 parmlist_2
 228%type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
 229%type <ttype> identifiers_or_typenames
 230
 231%type <itype> setspecs setspecs_fp
 232
 233%type <filename> save_filename
 234%type <lineno> save_lineno
 235
 236
 237%{
 238/* Number of statements (loosely speaking) and compound statements
 239   seen so far.  */
 240static int stmt_count;
 241static int compstmt_count;
 242
 243/* Input file and line number of the end of the body of last simple_if;
 244   used by the stmt-rule immediately after simple_if returns.  */
 245static const char *if_stmt_file;
 246static int if_stmt_line;
 247
 248/* List of types and structure classes of the current declaration.  */
 249static GTY(()) tree current_declspecs;
 250static GTY(()) tree prefix_attributes;
 251
 252/* List of all the attributes applying to the identifier currently being
 253   declared; includes prefix_attributes and possibly some more attributes
 254   just after a comma.  */
 255static GTY(()) tree all_prefix_attributes;
 256
 257/* Stack of saved values of current_declspecs, prefix_attributes and
 258   all_prefix_attributes.  */
 259static GTY(()) tree declspec_stack;
 260
 261/* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
 262   should be called from the productions making use of setspecs.  */
 263#define PUSH_DECLSPEC_STACK						 \
 264  do {									 \
 265    declspec_stack = tree_cons (build_tree_list (prefix_attributes,	 \
 266						 all_prefix_attributes), \
 267				current_declspecs,			 \
 268				declspec_stack);			 \
 269  } while (0)
 270
 271#define POP_DECLSPEC_STACK						\
 272  do {									\
 273    current_declspecs = TREE_VALUE (declspec_stack);			\
 274    prefix_attributes = TREE_PURPOSE (TREE_PURPOSE (declspec_stack));	\
 275    all_prefix_attributes = TREE_VALUE (TREE_PURPOSE (declspec_stack));	\
 276    declspec_stack = TREE_CHAIN (declspec_stack);			\
 277  } while (0)
 278
 279/* For __extension__, save/restore the warning flags which are
 280   controlled by __extension__.  */
 281#define SAVE_EXT_FLAGS()			\
 282	size_int (pedantic			\
 283		  | (warn_pointer_arith << 1)	\
 284		  | (warn_traditional << 2)	\
 285		  | (flag_iso << 3))
 286
 287#define RESTORE_EXT_FLAGS(tval)			\
 288  do {						\
 289    int val = tree_low_cst (tval, 0);		\
 290    pedantic = val & 1;				\
 291    warn_pointer_arith = (val >> 1) & 1;	\
 292    warn_traditional = (val >> 2) & 1;		\
 293    flag_iso = (val >> 3) & 1;			\
 294  } while (0)
 295
 296
 297#define OBJC_NEED_RAW_IDENTIFIER(VAL)	/* nothing */
 298
 299static bool parsing_iso_function_signature;
 300
 301/* Tell yyparse how to print a token's value, if yydebug is set.  */
 302
 303#define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
 304
 305static void yyprint	  PARAMS ((FILE *, int, YYSTYPE));
 306static void yyerror	  PARAMS ((const char *));
 307static int yylexname	  PARAMS ((void));
 308static int yylexstring	  PARAMS ((void));
 309static inline int _yylex  PARAMS ((void));
 310static int  yylex	  PARAMS ((void));
 311static void init_reswords PARAMS ((void));
 312
 313  /* Initialisation routine for this file.  */
 314void
 315c_parse_init ()
 316{
 317  init_reswords ();
 318}
 319
 320%}
 321
 322%%
 323program: /* empty */
 324		{ if (pedantic)
 325		    pedwarn ("ISO C forbids an empty source file");
 326		  finish_file ();
 327		}
 328	| extdefs
 329		{
 330		  /* In case there were missing closebraces,
 331		     get us back to the global binding level.  */
 332		  while (! global_bindings_p ())
 333		    poplevel (0, 0, 0);
 334		  /* __FUNCTION__ is defined at file scope ("").  This
 335		     call may not be necessary as my tests indicate it
 336		     still works without it.  */
 337		  finish_fname_decls ();
 338                  finish_file ();
 339		}
 340	;
 341
 342/* the reason for the strange actions in this rule
 343 is so that notype_initdecls when reached via datadef
 344 can find a valid list of type and sc specs in $0. */
 345
 346extdefs:
 347	{$<ttype>$ = NULL_TREE; } extdef
 348	| extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
 349	;
 350
 351extdef:
 352	extdef_1
 353	{ parsing_iso_function_signature = false; } /* Reset after any external definition.  */
 354	;
 355
 356extdef_1:
 357	fndef
 358	| datadef
 359	| ASM_KEYWORD '(' expr ')' ';'
 360		{ STRIP_NOPS ($3);
 361		  if ((TREE_CODE ($3) == ADDR_EXPR
 362		       && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
 363		      || TREE_CODE ($3) == STRING_CST)
 364		    assemble_asm ($3);
 365		  else
 366		    error ("argument of `asm' is not a constant string"); }
 367	| extension extdef
 368		{ RESTORE_EXT_FLAGS ($1); }
 369	;
 370
 371datadef:
 372	  setspecs notype_initdecls ';'
 373		{ if (pedantic)
 374		    error ("ISO C forbids data definition with no type or storage class");
 375		  else
 376		    warning ("data definition has no type or storage class");
 377
 378		  POP_DECLSPEC_STACK; }
 379        | declspecs_nots setspecs notype_initdecls ';'
 380		{ POP_DECLSPEC_STACK; }
 381	| declspecs_ts setspecs initdecls ';'
 382		{ POP_DECLSPEC_STACK; }
 383	| declspecs ';'
 384	  { shadow_tag ($1); }
 385	| error ';'
 386	| error '}'
 387	| ';'
 388		{ if (pedantic)
 389		    pedwarn ("ISO C does not allow extra `;' outside of a function"); }
 390	;
 391
 392fndef:
 393	  declspecs_ts setspecs declarator
 394		{ if (! start_function (current_declspecs, $3,
 395					all_prefix_attributes))
 396		    YYERROR1;
 397		}
 398	  old_style_parm_decls
 399		{ store_parm_decls (); }
 400	  save_filename save_lineno compstmt_or_error
 401		{ DECL_SOURCE_FILE (current_function_decl) = $7;
 402		  DECL_SOURCE_LINE (current_function_decl) = $8;
 403		  finish_function (0, 1);
 404		  POP_DECLSPEC_STACK; }
 405	| declspecs_ts setspecs declarator error
 406		{ POP_DECLSPEC_STACK; }
 407	| declspecs_nots setspecs notype_declarator
 408		{ if (! start_function (current_declspecs, $3,
 409					all_prefix_attributes))
 410		    YYERROR1;
 411		}
 412	  old_style_parm_decls
 413		{ store_parm_decls (); }
 414	  save_filename save_lineno compstmt_or_error
 415		{ DECL_SOURCE_FILE (current_function_decl) = $7;
 416		  DECL_SOURCE_LINE (current_function_decl) = $8;
 417		  finish_function (0, 1);
 418		  POP_DECLSPEC_STACK; }
 419	| declspecs_nots setspecs notype_declarator error
 420		{ POP_DECLSPEC_STACK; }
 421	| setspecs notype_declarator
 422		{ if (! start_function (NULL_TREE, $2,
 423					all_prefix_attributes))
 424		    YYERROR1;
 425		}
 426	  old_style_parm_decls
 427		{ store_parm_decls (); }
 428	  save_filename save_lineno compstmt_or_error
 429		{ DECL_SOURCE_FILE (current_function_decl) = $6;
 430		  DECL_SOURCE_LINE (current_function_decl) = $7;
 431		  finish_function (0, 1);
 432		  POP_DECLSPEC_STACK; }
 433	| setspecs notype_declarator error
 434		{ POP_DECLSPEC_STACK; }
 435	;
 436
 437identifier:
 438	IDENTIFIER
 439	| TYPENAME
 440	;
 441
 442unop:     '&'
 443		{ $$ = ADDR_EXPR; }
 444	| '-'
 445		{ $$ = NEGATE_EXPR; }
 446	| '+'
 447		{ $$ = CONVERT_EXPR;
 448  if (warn_traditional && !in_system_header)
 449    warning ("traditional C rejects the unary plus operator");
 450		}
 451	| PLUSPLUS
 452		{ $$ = PREINCREMENT_EXPR; }
 453	| MINUSMINUS
 454		{ $$ = PREDECREMENT_EXPR; }
 455	| '~'
 456		{ $$ = BIT_NOT_EXPR; }
 457	| '!'
 458		{ $$ = TRUTH_NOT_EXPR; }
 459	;
 460
 461expr:	nonnull_exprlist
 462		{ $$ = build_compound_expr ($1); }
 463	;
 464
 465exprlist:
 466	  /* empty */
 467		{ $$ = NULL_TREE; }
 468	| nonnull_exprlist
 469	;
 470
 471nonnull_exprlist:
 472	expr_no_commas
 473		{ $$ = build_tree_list (NULL_TREE, $1); }
 474	| nonnull_exprlist ',' expr_no_commas
 475		{ chainon ($1, build_tree_list (NULL_TREE, $3)); }
 476	;
 477
 478unary_expr:
 479	primary
 480	| '*' cast_expr   %prec UNARY
 481		{ $$ = build_indirect_ref ($2, "unary *"); }
 482	/* __extension__ turns off -pedantic for following primary.  */
 483	| extension cast_expr	  %prec UNARY
 484		{ $$ = $2;
 485		  RESTORE_EXT_FLAGS ($1); }
 486	| unop cast_expr  %prec UNARY
 487		{ $$ = build_unary_op ($1, $2, 0);
 488		  overflow_warning ($$); }
 489	/* Refer to the address of a label as a pointer.  */
 490	| ANDAND identifier
 491		{ $$ = finish_label_address_expr ($2); }
 492	| sizeof unary_expr  %prec UNARY
 493		{ skip_evaluation--;
 494		  if (TREE_CODE ($2) == COMPONENT_REF
 495		      && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
 496		    error ("`sizeof' applied to a bit-field");
 497		  $$ = c_sizeof (TREE_TYPE ($2)); }
 498	| sizeof '(' typename ')'  %prec HYPERUNARY
 499		{ skip_evaluation--;
 500		  $$ = c_sizeof (groktypename ($3)); }
 501	| alignof unary_expr  %prec UNARY
 502		{ skip_evaluation--;
 503		  $$ = c_alignof_expr ($2); }
 504	| alignof '(' typename ')'  %prec HYPERUNARY
 505		{ skip_evaluation--;
 506		  $$ = c_alignof (groktypename ($3)); }
 507	| REALPART cast_expr %prec UNARY
 508		{ $$ = build_unary_op (REALPART_EXPR, $2, 0); }
 509	| IMAGPART cast_expr %prec UNARY
 510		{ $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
 511	;
 512
 513sizeof:
 514	SIZEOF { skip_evaluation++; }
 515	;
 516
 517alignof:
 518	ALIGNOF { skip_evaluation++; }
 519	;
 520
 521typeof:
 522	TYPEOF { skip_evaluation++; }
 523	;
 524
 525cast_expr:
 526	unary_expr
 527	| '(' typename ')' cast_expr  %prec UNARY
 528		{ $$ = c_cast_expr ($2, $4); }
 529	;
 530
 531expr_no_commas:
 532	  cast_expr
 533	| expr_no_commas '+' expr_no_commas
 534		{ $$ = parser_build_binary_op ($2, $1, $3); }
 535	| expr_no_commas '-' expr_no_commas
 536		{ $$ = parser_build_binary_op ($2, $1, $3); }
 537	| expr_no_commas '*' expr_no_commas
 538		{ $$ = parser_build_binary_op ($2, $1, $3); }
 539	| expr_no_commas '/' expr_no_commas
 540		{ $$ = parser_build_binary_op ($2, $1, $3); }
 541	| expr_no_commas '%' expr_no_commas
 542		{ $$ = parser_build_binary_op ($2, $1, $3); }
 543	| expr_no_commas LSHIFT expr_no_commas
 544		{ $$ = parser_build_binary_op ($2, $1, $3); }
 545	| expr_no_commas RSHIFT expr_no_commas
 546		{ $$ = parser_build_binary_op ($2, $1, $3); }
 547	| expr_no_commas ARITHCOMPARE expr_no_commas
 548		{ $$ = parser_build_binary_op ($2, $1, $3); }
 549	| expr_no_commas EQCOMPARE expr_no_commas
 550		{ $$ = parser_build_binary_op ($2, $1, $3); }
 551	| expr_no_commas '&' expr_no_commas
 552		{ $$ = parser_build_binary_op ($2, $1, $3); }
 553	| expr_no_commas '|' expr_no_commas
 554		{ $$ = parser_build_binary_op ($2, $1, $3); }
 555	| expr_no_commas '^' expr_no_commas
 556		{ $$ = parser_build_binary_op ($2, $1, $3); }
 557	| expr_no_commas ANDAND
 558		{ $1 = c_common_truthvalue_conversion
 559		    (default_conversion ($1));
 560		  skip_evaluation += $1 == boolean_false_node; }
 561	  expr_no_commas
 562		{ skip_evaluation -= $1 == boolean_false_node;
 563		  $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
 564	| expr_no_commas OROR
 565		{ $1 = c_common_truthvalue_conversion
 566		    (default_conversion ($1));
 567		  skip_evaluation += $1 == boolean_true_node; }
 568	  expr_no_commas
 569		{ skip_evaluation -= $1 == boolean_true_node;
 570		  $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
 571	| expr_no_commas '?'
 572		{ $1 = c_common_truthvalue_conversion
 573		    (default_conversion ($1));
 574		  skip_evaluation += $1 == boolean_false_node; }
 575          expr ':'
 576		{ skip_evaluation += (($1 == boolean_true_node)
 577				      - ($1 == boolean_false_node)); }
 578	  expr_no_commas
 579		{ skip_evaluation -= $1 == boolean_true_node;
 580		  $$ = build_conditional_expr ($1, $4, $7); }
 581	| expr_no_commas '?'
 582		{ if (pedantic)
 583		    pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
 584		  /* Make sure first operand is calculated only once.  */
 585		  $<ttype>2 = save_expr ($1);
 586		  $1 = c_common_truthvalue_conversion
 587		    (default_conversion ($<ttype>2));
 588		  skip_evaluation += $1 == boolean_true_node; }
 589	  ':' expr_no_commas
 590		{ skip_evaluation -= $1 == boolean_true_node;
 591		  $$ = build_conditional_expr ($1, $<ttype>2, $5); }
 592	| expr_no_commas '=' expr_no_commas
 593		{ char class;
 594		  $$ = build_modify_expr ($1, NOP_EXPR, $3);
 595		  class = TREE_CODE_CLASS (TREE_CODE ($$));
 596		  if (IS_EXPR_CODE_CLASS (class))
 597		    C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
 598		}
 599	| expr_no_commas ASSIGN expr_no_commas
 600		{ char class;
 601		  $$ = build_modify_expr ($1, $2, $3);
 602		  /* This inhibits warnings in
 603		     c_common_truthvalue_conversion.  */
 604		  class = TREE_CODE_CLASS (TREE_CODE ($$));
 605		  if (IS_EXPR_CODE_CLASS (class))
 606		    C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
 607		}
 608	;
 609
 610primary:
 611	IDENTIFIER
 612		{
 613		  if (yychar == YYEMPTY)
 614		    yychar = YYLEX;
 615		  $$ = build_external_ref ($1, yychar == '(');
 616		}
 617	| CONSTANT
 618	| STRING
 619		{ $$ = fix_string_type ($$); }
 620	| VAR_FUNC_NAME
 621		{ $$ = fname_decl (C_RID_CODE ($$), $$); }
 622	| '(' typename ')' '{'
 623		{ start_init (NULL_TREE, NULL, 0);
 624		  $2 = groktypename ($2);
 625		  really_start_incremental_init ($2); }
 626	  initlist_maybe_comma '}'  %prec UNARY
 627		{ tree constructor = pop_init_level (0);
 628		  tree type = $2;
 629		  finish_init ();
 630
 631		  if (pedantic && ! flag_isoc99)
 632		    pedwarn ("ISO C89 forbids compound literals");
 633		  $$ = build_compound_literal (type, constructor);
 634		}
 635	| '(' expr ')'
 636		{ char class = TREE_CODE_CLASS (TREE_CODE ($2));
 637		  if (IS_EXPR_CODE_CLASS (class))
 638		    C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
 639		  $$ = $2; }
 640	| '(' error ')'
 641		{ $$ = error_mark_node; }
 642	| compstmt_primary_start compstmt_nostart ')'
 643                 { tree saved_last_tree;
 644
 645		   if (pedantic)
 646		     pedwarn ("ISO C forbids braced-groups within expressions");
 647		  pop_label_level ();
 648
 649		  saved_last_tree = COMPOUND_BODY ($1);
 650		  RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
 651		  last_tree = saved_last_tree;
 652		  TREE_CHAIN (last_tree) = NULL_TREE;
 653		  if (!last_expr_type)
 654		    last_expr_type = void_type_node;
 655		  $$ = build1 (STMT_EXPR, last_expr_type, $1);
 656		  TREE_SIDE_EFFECTS ($$) = 1;
 657		}
 658	| compstmt_primary_start error ')'
 659		{
 660		  pop_label_level ();
 661		  last_tree = COMPOUND_BODY ($1);
 662		  TREE_CHAIN (last_tree) = NULL_TREE;
 663		  $$ = error_mark_node;
 664		}
 665	| primary '(' exprlist ')'   %prec '.'
 666		{ $$ = build_function_call ($1, $3); }
 667	| VA_ARG '(' expr_no_commas ',' typename ')'
 668		{ $$ = build_va_arg ($3, groktypename ($5)); }
 669
 670      | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ',' expr_no_commas ')'
 671		{
 672                  tree c;
 673
 674                  c = fold ($3);
 675                  STRIP_NOPS (c);
 676                  if (TREE_CODE (c) != INTEGER_CST)
 677                    error ("first argument to __builtin_choose_expr not a constant");
 678                  $$ = integer_zerop (c) ? $7 : $5;
 679		}
 680      | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
 681		{
 682		  tree e1, e2;
 683
 684		  e1 = TYPE_MAIN_VARIANT (groktypename ($3));
 685		  e2 = TYPE_MAIN_VARIANT (groktypename ($5));
 686
 687		  $$ = comptypes (e1, e2)
 688		    ? build_int_2 (1, 0) : build_int_2 (0, 0);
 689		}
 690	| primary '[' expr ']'   %prec '.'
 691		{ $$ = build_array_ref ($1, $3); }
 692	| primary '.' identifier
 693		{
 694		      $$ = build_component_ref ($1, $3);
 695		}
 696	| primary POINTSAT identifier
 697		{
 698                  tree expr = build_indirect_ref ($1, "->");
 699
 700			$$ = build_component_ref (expr, $3);
 701		}
 702	| primary PLUSPLUS
 703		{ $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
 704	| primary MINUSMINUS
 705		{ $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
 706	;
 707
 708
 709old_style_parm_decls:
 710	old_style_parm_decls_1
 711	{
 712	  parsing_iso_function_signature = false; /* Reset after decls.  */
 713	}
 714	;
 715
 716old_style_parm_decls_1:
 717	/* empty */
 718	{
 719	  if (warn_traditional && !in_system_header
 720	      && parsing_iso_function_signature)
 721	    warning ("traditional C rejects ISO C style function definitions");
 722	  parsing_iso_function_signature = false; /* Reset after warning.  */
 723	}
 724	| datadecls
 725	;
 726
 727/* The following are analogous to lineno_decl, decls and decl
 728   except that they do not allow nested functions.
 729   They are used for old-style parm decls.  */
 730lineno_datadecl:
 731	  save_filename save_lineno datadecl
 732		{ }
 733	;
 734
 735datadecls:
 736	lineno_datadecl
 737	| errstmt
 738	| datadecls lineno_datadecl
 739	| lineno_datadecl errstmt
 740	;
 741
 742/* We don't allow prefix attributes here because they cause reduce/reduce
 743   conflicts: we can't know whether we're parsing a function decl with
 744   attribute suffix, or function defn with attribute prefix on first old
 745   style parm.  */
 746datadecl:
 747	declspecs_ts_nosa setspecs initdecls ';'
 748		{ POP_DECLSPEC_STACK; }
 749	| declspecs_nots_nosa setspecs notype_initdecls ';'
 750		{ POP_DECLSPEC_STACK; }
 751	| declspecs_ts_nosa ';'
 752		{ shadow_tag_warned ($1, 1);
 753		  pedwarn ("empty declaration"); }
 754	| declspecs_nots_nosa ';'
 755		{ pedwarn ("empty declaration"); }
 756	;
 757
 758/* This combination which saves a lineno before a decl
 759   is the normal thing to use, rather than decl itself.
 760   This is to avoid shift/reduce conflicts in contexts
 761   where statement labels are allowed.  */
 762lineno_decl:
 763	  save_filename save_lineno decl
 764		{ }
 765	;
 766
 767/* records the type and storage class specs to use for processing
 768   the declarators that follow.
 769   Maintains a stack of outer-level values of current_declspecs,
 770   for the sake of parm declarations nested in function declarators.  */
 771setspecs: /* empty */
 772		{ pending_xref_error ();
 773		  PUSH_DECLSPEC_STACK;
 774		  split_specs_attrs ($<ttype>0,
 775				     &current_declspecs, &prefix_attributes);
 776		  all_prefix_attributes = prefix_attributes; }
 777	;
 778
 779/* Possibly attributes after a comma, which should reset all_prefix_attributes
 780   to prefix_attributes with these ones chained on the front.  */
 781maybe_resetattrs:
 782	  maybe_attribute
 783		{ all_prefix_attributes = chainon ($1, prefix_attributes); }
 784	;
 785
 786decl:
 787	declspecs_ts setspecs initdecls ';'
 788		{ POP_DECLSPEC_STACK; }
 789	| declspecs_nots setspecs notype_initdecls ';'
 790		{ POP_DECLSPEC_STACK; }
 791	| declspecs_ts setspecs nested_function
 792		{ POP_DECLSPEC_STACK; }
 793	| declspecs_nots setspecs notype_nested_function
 794		{ POP_DECLSPEC_STACK; }
 795	| declspecs ';'
 796		{ shadow_tag ($1); }
 797	| extension decl
 798		{ RESTORE_EXT_FLAGS ($1); }
 799	;
 800
 801/* A list of declaration specifiers.  These are:
 802
 803   - Storage class specifiers (scspec), which for GCC currently includes
 804   function specifiers ("inline").
 805
 806   - Type specifiers (typespec_*).
 807
 808   - Type qualifiers (TYPE_QUAL).
 809
 810   - Attribute specifier lists (attributes).
 811
 812   These are stored as a TREE_LIST; the head of the list is the last
 813   item in the specifier list.  Each entry in the list has either a
 814   TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
 815   is a single other specifier or qualifier; and a TREE_CHAIN that is the
 816   rest of the list.  TREE_STATIC is set on the list if something other
 817   than a storage class specifier or attribute has been seen; this is used
 818   to warn for the obsolescent usage of storage class specifiers other than
 819   at the start of the list.  (Doing this properly would require function
 820   specifiers to be handled separately from storage class specifiers.)
 821
 822   The various cases below are classified according to:
 823
 824   (a) Whether a storage class specifier is included or not; some
 825   places in the grammar disallow storage class specifiers (_sc or _nosc).
 826
 827   (b) Whether a type specifier has been seen; after a type specifier,
 828   a typedef name is an identifier to redeclare (_ts or _nots).
 829
 830   (c) Whether the list starts with an attribute; in certain places,
 831   the grammar requires specifiers that don't start with an attribute
 832   (_sa or _nosa).
 833
 834   (d) Whether the list ends with an attribute (or a specifier such that
 835   any following attribute would have been parsed as part of that specifier);
 836   this avoids shift-reduce conflicts in the parsing of attributes
 837   (_ea or _noea).
 838
 839   TODO:
 840
 841   (i) Distinguish between function specifiers and storage class specifiers,
 842   at least for the purpose of warnings about obsolescent usage.
 843
 844   (ii) Halve the number of productions here by eliminating the _sc/_nosc
 845   distinction and instead checking where required that storage class
 846   specifiers aren't present.  */
 847
 848/* Declspecs which contain at least one type specifier or typedef name.
 849   (Just `const' or `volatile' is not enough.)
 850   A typedef'd name following these is taken as a name to be declared.
 851   Declspecs have a non-NULL TREE_VALUE, attributes do not.  */
 852
 853declspecs_nosc_nots_nosa_noea:
 854	  TYPE_QUAL
 855		{ $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
 856		  TREE_STATIC ($$) = 1; }
 857	| declspecs_nosc_nots_nosa_noea TYPE_QUAL
 858		{ $$ = tree_cons (NULL_TREE, $2, $1);
 859		  TREE_STATIC ($$) = 1; }
 860	| declspecs_nosc_nots_nosa_ea TYPE_QUAL
 861		{ $$ = tree_cons (NULL_TREE, $2, $1);
 862		  TREE_STATIC ($$) = 1; }
 863	;
 864
 865declspecs_nosc_nots_nosa_ea:
 866	  declspecs_nosc_nots_nosa_noea attributes
 867		{ $$ = tree_cons ($2, NULL_TREE, $1);
 868		  TREE_STATIC ($$) = TREE_STATIC ($1); }
 869	;
 870
 871declspecs_nosc_nots_sa_noea:
 872	  declspecs_nosc_nots_sa_noea TYPE_QUAL
 873		{ $$ = tree_cons (NULL_TREE, $2, $1);
 874		  TREE_STATIC ($$) = 1; }
 875	| declspecs_nosc_nots_sa_ea TYPE_QUAL
 876		{ $$ = tree_cons (NULL_TREE, $2, $1);
 877		  TREE_STATIC ($$) = 1; }
 878	;
 879
 880declspecs_nosc_nots_sa_ea:
 881	  attributes
 882		{ $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
 883		  TREE_STATIC ($$) = 0; }
 884	| declspecs_nosc_nots_sa_noea attributes
 885		{ $$ = tree_cons ($2, NULL_TREE, $1);
 886		  TREE_STATIC ($$) = TREE_STATIC ($1); }
 887	;
 888
 889declspecs_nosc_ts_nosa_noea:
 890	  typespec_nonattr
 891		{ $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
 892		  TREE_STATIC ($$) = 1; }
 893	| declspecs_nosc_ts_nosa_noea TYPE_QUAL
 894		{ $$ = tree_cons (NULL_TREE, $2, $1);
 895		  TREE_STATIC ($$) = 1; }
 896	| declspecs_nosc_ts_nosa_ea TYPE_QUAL
 897		{ $$ = tree_cons (NULL_TREE, $2, $1);
 898		  TREE_STATIC ($$) = 1; }
 899	| declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
 900		{ $$ = tree_cons (NULL_TREE, $2, $1);
 901		  TREE_STATIC ($$) = 1; }
 902	| declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
 903		{ $$ = tree_cons (NULL_TREE, $2, $1);
 904		  TREE_STATIC ($$) = 1; }
 905	| declspecs_nosc_nots_nosa_noea typespec_nonattr
 906		{ $$ = tree_cons (NULL_TREE, $2, $1);
 907		  TREE_STATIC ($$) = 1; }
 908	| declspecs_nosc_nots_nosa_ea typespec_nonattr
 909		{ $$ = tree_cons (NULL_TREE, $2, $1);
 910		  TREE_STATIC ($$) = 1; }
 911	;
 912
 913declspecs_nosc_ts_nosa_ea:
 914	  typespec_attr
 915		{ $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
 916		  TREE_STATIC ($$) = 1; }
 917	| declspecs_nosc_ts_nosa_noea attributes
 918		{ $$ = tree_cons ($2, NULL_TREE, $1);
 919		  TREE_STATIC ($$) = TREE_STATIC ($1); }
 920	| declspecs_nosc_ts_nosa_noea typespec_reserved_attr
 921		{ $$ = tree_cons (NULL_TREE, $2, $1);
 922		  TREE_STATIC ($$) = 1; }
 923	| declspecs_nosc_ts_nosa_ea typespec_reserved_attr
 924		{ $$ = tree_cons (NULL_TREE, $2, $1);
 925		  TREE_STATIC ($$) = 1; }
 926	| declspecs_nosc_nots_nosa_noea typespec_attr
 927		{ $$ = tree_cons (NULL_TREE, $2, $1);
 928		  TREE_STATIC ($$) = 1; }
 929	| declspecs_nosc_nots_nosa_ea typespec_attr
 930		{ $$ = tree_cons (NULL_TREE, $2, $1);
 931		  TREE_STATIC ($$) = 1; }
 932	;
 933
 934declspecs_nosc_ts_sa_noea:
 935	  declspecs_nosc_ts_sa_noea TYPE_QUAL
 936		{ $$ = tree_cons (NULL_TREE, $2, $1);
 937		  TREE_STATIC ($$) = 1; }
 938	| declspecs_nosc_ts_sa_ea TYPE_QUAL
 939		{ $$ = tree_cons (NULL_TREE, $2, $1);
 940		  TREE_STATIC ($$) = 1; }
 941	| declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
 942		{ $$ = tree_cons (NULL_TREE, $2, $1);
 943		  TREE_STATIC ($$) = 1; }
 944	| declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
 945		{ $$ = tree_cons (NULL_TREE, $2, $1);
 946		  TREE_STATIC ($$) = 1; }
 947	| declspecs_nosc_nots_sa_noea typespec_nonattr
 948		{ $$ = tree_cons (NULL_TREE, $2, $1);
 949		  TREE_STATIC ($$) = 1; }
 950	| declspecs_nosc_nots_sa_ea typespec_nonattr
 951		{ $$ = tree_cons (NULL_TREE, $2, $1);
 952		  TREE_STATIC ($$) = 1; }
 953	;
 954
 955declspecs_nosc_ts_sa_ea:
 956	  declspecs_nosc_ts_sa_noea attributes
 957		{ $$ = tree_cons ($2, NULL_TREE, $1);
 958		  TREE_STATIC ($$) = TREE_STATIC ($1); }
 959	| declspecs_nosc_ts_sa_noea typespec_reserved_attr
 960		{ $$ = tree_cons (NULL_TREE, $2, $1);
 961		  TREE_STATIC ($$) = 1; }
 962	| declspecs_nosc_ts_sa_ea typespec_reserved_attr
 963		{ $$ = tree_cons (NULL_TREE, $2, $1);
 964		  TREE_STATIC ($$) = 1; }
 965	| declspecs_nosc_nots_sa_noea typespec_attr
 966		{ $$ = tree_cons (NULL_TREE, $2, $1);
 967		  TREE_STATIC ($$) = 1; }
 968	| declspecs_nosc_nots_sa_ea typespec_attr
 969		{ $$ = tree_cons (NULL_TREE, $2, $1);
 970		  TREE_STATIC ($$) = 1; }
 971	;
 972
 973declspecs_sc_nots_nosa_noea:
 974	  scspec
 975		{ $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
 976		  TREE_STATIC ($$) = 0; }
 977	| declspecs_sc_nots_nosa_noea TYPE_QUAL
 978		{ $$ = tree_cons (NULL_TREE, $2, $1);
 979		  TREE_STATIC ($$) = 1; }
 980	| declspecs_sc_nots_nosa_ea TYPE_QUAL
 981		{ $$ = tree_cons (NULL_TREE, $2, $1);
 982		  TREE_STATIC ($$) = 1; }
 983	| declspecs_nosc_nots_nosa_noea scspec
 984		{ if (extra_warnings && TREE_STATIC ($1))
 985		    warning ("`%s' is not at beginning of declaration",
 986			     IDENTIFIER_POINTER ($2));
 987		  $$ = tree_cons (NULL_TREE, $2, $1);
 988		  TREE_STATIC ($$) = TREE_STATIC ($1); }
 989	| declspecs_nosc_nots_nosa_ea scspec
 990		{ if (extra_warnings && TREE_STATIC ($1))
 991		    warning ("`%s' is not at beginning of declaration",
 992			     IDENTIFIER_POINTER ($2));
 993		  $$ = tree_cons (NULL_TREE, $2, $1);
 994		  TREE_STATIC ($$) = TREE_STATIC ($1); }
 995	| declspecs_sc_nots_nosa_noea scspec
 996		{ if (extra_warnings && TREE_STATIC ($1))
 997		    warning ("`%s' is not at beginning of declaration",
 998			     IDENTIFIER_POINTER ($2));
 999		  $$ = tree_cons (NULL_TREE, $2, $1);
1000		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1001	| declspecs_sc_nots_nosa_ea scspec
1002		{ if (extra_warnings && TREE_STATIC ($1))
1003		    warning ("`%s' is not at beginning of declaration",
1004			     IDENTIFIER_POINTER ($2));
1005		  $$ = tree_cons (NULL_TREE, $2, $1);
1006		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1007	;
1008
1009declspecs_sc_nots_nosa_ea:
1010	  declspecs_sc_nots_nosa_noea attributes
1011		{ $$ = tree_cons ($2, NULL_TREE, $1);
1012		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1013	;
1014
1015declspecs_sc_nots_sa_noea:
1016	  declspecs_sc_nots_sa_noea TYPE_QUAL
1017		{ $$ = tree_cons (NULL_TREE, $2, $1);
1018		  TREE_STATIC ($$) = 1; }
1019	| declspecs_sc_nots_sa_ea TYPE_QUAL
1020		{ $$ = tree_cons (NULL_TREE, $2, $1);
1021		  TREE_STATIC ($$) = 1; }
1022	| declspecs_nosc_nots_sa_noea scspec
1023		{ if (extra_warnings && TREE_STATIC ($1))
1024		    warning ("`%s' is not at beginning of declaration",
1025			     IDENTIFIER_POINTER ($2));
1026		  $$ = tree_cons (NULL_TREE, $2, $1);
1027		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1028	| declspecs_nosc_nots_sa_ea scspec
1029		{ if (extra_warnings && TREE_STATIC ($1))
1030		    warning ("`%s' is not at beginning of declaration",
1031			     IDENTIFIER_POINTER ($2));
1032		  $$ = tree_cons (NULL_TREE, $2, $1);
1033		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1034	| declspecs_sc_nots_sa_noea scspec
1035		{ if (extra_warnings && TREE_STATIC ($1))
1036		    warning ("`%s' is not at beginning of declaration",
1037			     IDENTIFIER_POINTER ($2));
1038		  $$ = tree_cons (NULL_TREE, $2, $1);
1039		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1040	| declspecs_sc_nots_sa_ea scspec
1041		{ if (extra_warnings && TREE_STATIC ($1))
1042		    warning ("`%s' is not at beginning of declaration",
1043			     IDENTIFIER_POINTER ($2));
1044		  $$ = tree_cons (NULL_TREE, $2, $1);
1045		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1046	;
1047
1048declspecs_sc_nots_sa_ea:
1049	  declspecs_sc_nots_sa_noea attributes
1050		{ $$ = tree_cons ($2, NULL_TREE, $1);
1051		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1052	;
1053
1054declspecs_sc_ts_nosa_noea:
1055	  declspecs_sc_ts_nosa_noea TYPE_QUAL
1056		{ $$ = tree_cons (NULL_TREE, $2, $1);
1057		  TREE_STATIC ($$) = 1; }
1058	| declspecs_sc_ts_nosa_ea TYPE_QUAL
1059		{ $$ = tree_cons (NULL_TREE, $2, $1);
1060		  TREE_STATIC ($$) = 1; }
1061	| declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1062		{ $$ = tree_cons (NULL_TREE, $2, $1);
1063		  TREE_STATIC ($$) = 1; }
1064	| declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1065		{ $$ = tree_cons (NULL_TREE, $2, $1);
1066		  TREE_STATIC ($$) = 1; }
1067	| declspecs_sc_nots_nosa_noea typespec_nonattr
1068		{ $$ = tree_cons (NULL_TREE, $2, $1);
1069		  TREE_STATIC ($$) = 1; }
1070	| declspecs_sc_nots_nosa_ea typespec_nonattr
1071		{ $$ = tree_cons (NULL_TREE, $2, $1);
1072		  TREE_STATIC ($$) = 1; }
1073	| declspecs_nosc_ts_nosa_noea scspec
1074		{ if (extra_warnings && TREE_STATIC ($1))
1075		    warning ("`%s' is not at beginning of declaration",
1076			     IDENTIFIER_POINTER ($2));
1077		  $$ = tree_cons (NULL_TREE, $2, $1);
1078		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1079	| declspecs_nosc_ts_nosa_ea scspec
1080		{ if (extra_warnings && TREE_STATIC ($1))
1081		    warning ("`%s' is not at beginning of declaration",
1082			     IDENTIFIER_POINTER ($2));
1083		  $$ = tree_cons (NULL_TREE, $2, $1);
1084		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1085	| declspecs_sc_ts_nosa_noea scspec
1086		{ if (extra_warnings && TREE_STATIC ($1))
1087		    warning ("`%s' is not at beginning of declaration",
1088			     IDENTIFIER_POINTER ($2));
1089		  $$ = tree_cons (NULL_TREE, $2, $1);
1090		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1091	| declspecs_sc_ts_nosa_ea scspec
1092		{ if (extra_warnings && TREE_STATIC ($1))
1093		    warning ("`%s' is not at beginning of declaration",
1094			     IDENTIFIER_POINTER ($2));
1095		  $$ = tree_cons (NULL_TREE, $2, $1);
1096		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1097	;
1098
1099declspecs_sc_ts_nosa_ea:
1100	  declspecs_sc_ts_nosa_noea attributes
1101		{ $$ = tree_cons ($2, NULL_TREE, $1);
1102		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1103	| declspecs_sc_ts_nosa_noea typespec_reserved_attr
1104		{ $$ = tree_cons (NULL_TREE, $2, $1);
1105		  TREE_STATIC ($$) = 1; }
1106	| declspecs_sc_ts_nosa_ea typespec_reserved_attr
1107		{ $$ = tree_cons (NULL_TREE, $2, $1);
1108		  TREE_STATIC ($$) = 1; }
1109	| declspecs_sc_nots_nosa_noea typespec_attr
1110		{ $$ = tree_cons (NULL_TREE, $2, $1);
1111		  TREE_STATIC ($$) = 1; }
1112	| declspecs_sc_nots_nosa_ea typespec_attr
1113		{ $$ = tree_cons (NULL_TREE, $2, $1);
1114		  TREE_STATIC ($$) = 1; }
1115	;
1116
1117declspecs_sc_ts_sa_noea:
1118	  declspecs_sc_ts_sa_noea TYPE_QUAL
1119		{ $$ = tree_cons (NULL_TREE, $2, $1);
1120		  TREE_STATIC ($$) = 1; }
1121	| declspecs_sc_ts_sa_ea TYPE_QUAL
1122		{ $$ = tree_cons (NULL_TREE, $2, $1);
1123		  TREE_STATIC ($$) = 1; }
1124	| declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1125		{ $$ = tree_cons (NULL_TREE, $2, $1);
1126		  TREE_STATIC ($$) = 1; }
1127	| declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1128		{ $$ = tree_cons (NULL_TREE, $2, $1);
1129		  TREE_STATIC ($$) = 1; }
1130	| declspecs_sc_nots_sa_noea typespec_nonattr
1131		{ $$ = tree_cons (NULL_TREE, $2, $1);
1132		  TREE_STATIC ($$) = 1; }
1133	| declspecs_sc_nots_sa_ea typespec_nonattr
1134		{ $$ = tree_cons (NULL_TREE, $2, $1);
1135		  TREE_STATIC ($$) = 1; }
1136	| declspecs_nosc_ts_sa_noea scspec
1137		{ if (extra_warnings && TREE_STATIC ($1))
1138		    warning ("`%s' is not at beginning of declaration",
1139			     IDENTIFIER_POINTER ($2));
1140		  $$ = tree_cons (NULL_TREE, $2, $1);
1141		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1142	| declspecs_nosc_ts_sa_ea scspec
1143		{ if (extra_warnings && TREE_STATIC ($1))
1144		    warning ("`%s' is not at beginning of declaration",
1145			     IDENTIFIER_POINTER ($2));
1146		  $$ = tree_cons (NULL_TREE, $2, $1);
1147		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1148	| declspecs_sc_ts_sa_noea scspec
1149		{ if (extra_warnings && TREE_STATIC ($1))
1150		    warning ("`%s' is not at beginning of declaration",
1151			     IDENTIFIER_POINTER ($2));
1152		  $$ = tree_cons (NULL_TREE, $2, $1);
1153		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1154	| declspecs_sc_ts_sa_ea scspec
1155		{ if (extra_warnings && TREE_STATIC ($1))
1156		    warning ("`%s' is not at beginning of declaration",
1157			     IDENTIFIER_POINTER ($2));
1158		  $$ = tree_cons (NULL_TREE, $2, $1);
1159		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1160	;
1161
1162declspecs_sc_ts_sa_ea:
1163	  declspecs_sc_ts_sa_noea attributes
1164		{ $$ = tree_cons ($2, NULL_TREE, $1);
1165		  TREE_STATIC ($$) = TREE_STATIC ($1); }
1166	| declspecs_sc_ts_sa_noea typespec_reserved_attr
1167		{ $$ = tree_cons (NULL_TREE, $2, $1);
1168		  TREE_STATIC ($$) = 1; }
1169	| declspecs_sc_ts_sa_ea typespec_reserved_attr
1170		{ $$ = tree_cons (NULL_TREE, $2, $1);
1171		  TREE_STATIC ($$) = 1; }
1172	| declspecs_sc_nots_sa_noea typespec_attr
1173		{ $$ = tree_cons (NULL_TREE, $2, $1);
1174		  TREE_STATIC ($$) = 1; }
1175	| declspecs_sc_nots_sa_ea typespec_attr
1176		{ $$ = tree_cons (NULL_TREE, $2, $1);
1177		  TREE_STATIC ($$) = 1; }
1178	;
1179
1180/* Particular useful classes of declspecs.  */
1181declspecs_ts:
1182	  declspecs_nosc_ts_nosa_noea
1183	| declspecs_nosc_ts_nosa_ea
1184	| declspecs_nosc_ts_sa_noea
1185	| declspecs_nosc_ts_sa_ea
1186	| declspecs_sc_ts_nosa_noea
1187	| declspecs_sc_ts_nosa_ea
1188	| declspecs_sc_ts_sa_noea
1189	| declspecs_sc_ts_sa_ea
1190	;
1191
1192declspecs_nots:
1193	  declspecs_nosc_nots_nosa_noea
1194	| declspecs_nosc_nots_nosa_ea
1195	| declspecs_nosc_nots_sa_noea
1196	| declspecs_nosc_nots_sa_ea
1197	| declspecs_sc_nots_nosa_noea
1198	| declspecs_sc_nots_nosa_ea
1199	| declspecs_sc_nots_sa_noea
1200	| declspecs_sc_nots_sa_ea
1201	;
1202
1203declspecs_ts_nosa:
1204	  declspecs_nosc_ts_nosa_noea
1205	| declspecs_nosc_ts_nosa_ea
1206	| declspecs_sc_ts_nosa_noea
1207	| declspecs_sc_ts_nosa_ea
1208	;
1209
1210declspecs_nots_nosa:
1211	  declspecs_nosc_nots_nosa_noea
1212	| declspecs_nosc_nots_nosa_ea
1213	| declspecs_sc_nots_nosa_noea
1214	| declspecs_sc_nots_nosa_ea
1215	;
1216
1217declspecs_nosc_ts:
1218	  declspecs_nosc_ts_nosa_noea
1219	| declspecs_nosc_ts_nosa_ea
1220	| declspecs_nosc_ts_sa_noea
1221	| declspecs_nosc_ts_sa_ea
1222	;
1223
1224declspecs_nosc_nots:
1225	  declspecs_nosc_nots_nosa_noea
1226	| declspecs_nosc_nots_nosa_ea
1227	| declspecs_nosc_nots_sa_noea
1228	| declspecs_nosc_nots_sa_ea
1229	;
1230
1231declspecs_nosc:
1232	  declspecs_nosc_ts_nosa_noea
1233	| declspecs_nosc_ts_nosa_ea
1234	| declspecs_nosc_ts_sa_noea
1235	| declspecs_nosc_ts_sa_ea
1236	| declspecs_nosc_nots_nosa_noea
1237	| declspecs_nosc_nots_nosa_ea
1238	| declspecs_nosc_nots_sa_noea
1239	| declspecs_nosc_nots_sa_ea
1240	;
1241
1242declspecs:
1243	  declspecs_nosc_nots_nosa_noea
1244	| declspecs_nosc_nots_nosa_ea
1245	| declspecs_nosc_nots_sa_noea
1246	| declspecs_nosc_nots_sa_ea
1247	| declspecs_nosc_ts_nosa_noea
1248	| declspecs_nosc_ts_nosa_ea
1249	| declspecs_nosc_ts_sa_noea
1250	| declspecs_nosc_ts_sa_ea
1251	| declspecs_sc_nots_nosa_noea
1252	| declspecs_sc_nots_nosa_ea
1253	| declspecs_sc_nots_sa_noea
1254	| declspecs_sc_nots_sa_ea
1255	| declspecs_sc_ts_nosa_noea
1256	| declspecs_sc_ts_nosa_ea
1257	| declspecs_sc_ts_sa_noea
1258	| declspecs_sc_ts_sa_ea
1259	;
1260
1261/* A (possibly empty) sequence of type qualifiers and attributes.  */
1262maybe_type_quals_attrs:
1263	  /* empty */
1264		{ $$ = NULL_TREE; }
1265	| declspecs_nosc_nots
1266		{ $$ = $1; }
1267	;
1268
1269/* A type specifier (but not a type qualifier).
1270   Once we have seen one of these in a declaration,
1271   if a typedef name appears then it is being redeclared.
1272
1273   The _reserved versions start with a reserved word and may appear anywhere
1274   in the declaration specifiers; the _nonreserved versions may only
1275   appear before any other type specifiers, and after that are (if names)
1276   being redeclared.
1277
1278   FIXME: should the _nonreserved version be restricted to names being
1279   redeclared only?  The other entries there relate only the GNU extensions
1280   and Objective C, and are historically parsed thus, and don't make sense
1281   after other type specifiers, but it might be cleaner to count them as
1282   _reserved.
1283
1284   _attr means: specifiers that either end with attributes,
1285   or are such that any following attributes would
1286   be parsed as part of the specifier.
1287
1288   _nonattr: specifiers.  */
1289
1290typespec_nonattr:
1291	  typespec_reserved_nonattr
1292	| typespec_nonreserved_nonattr
1293	;
1294
1295typespec_attr:
1296	  typespec_reserved_attr
1297	;
1298
1299typespec_reserved_nonattr:
1300	  TYPESPEC
1301		{ OBJC_NEED_RAW_IDENTIFIER (1);	}
1302	| structsp_nonattr
1303	;
1304
1305typespec_reserved_attr:
1306	  structsp_attr
1307	;
1308
1309typespec_nonreserved_nonattr:
1310	  TYPENAME
1311		{ /* For a typedef name, record the meaning, not the name.
1312		     In case of `foo foo, bar;'.  */
1313		  $$ = lookup_name ($1); }
1314	| typeof '(' expr ')'
1315		{ skip_evaluation--; $$ = TREE_TYPE ($3); }
1316	| typeof '(' typename ')'
1317		{ skip_evaluation--; $$ = groktypename ($3); }
1318	;
1319
1320/* typespec_nonreserved_attr does not exist.  */
1321
1322initdecls:
1323	initdcl
1324	| initdecls ',' maybe_resetattrs initdcl
1325	;
1326
1327notype_initdecls:
1328	notype_initdcl
1329	| notype_initdecls ',' maybe_resetattrs notype_initdcl
1330	;
1331
1332maybeasm:
1333	  /* empty */
1334		{ $$ = NULL_TREE; }
1335	| ASM_KEYWORD '(' STRING ')'
1336		{ $$ = $3; }
1337	;
1338
1339initdcl:
1340	  declarator maybeasm maybe_attribute '='
1341		{ $<ttype>$ = start_decl ($1, current_declspecs, 1,
1342					  chainon ($3, all_prefix_attributes));
1343		  start_init ($<ttype>$, $2, global_bindings_p ()); }
1344	  init
1345/* Note how the declaration of the variable is in effect while its init is parsed! */
1346		{ finish_init ();
1347		  finish_decl ($<ttype>5, $6, $2); }
1348	| declarator maybeasm maybe_attribute
1349		{ tree d = start_decl ($1, current_declspecs, 0,
1350				       chainon ($3, all_prefix_attributes));
1351		  finish_decl (d, NULL_TREE, $2);
1352                }
1353	;
1354
1355notype_initdcl:
1356	  notype_declarator maybeasm maybe_attribute '='
1357		{ $<ttype>$ = start_decl ($1, current_declspecs, 1,
1358					  chainon ($3, all_prefix_attributes));
1359		  start_init ($<ttype>$, $2, global_bindings_p ()); }
1360	  init
1361/* Note how the declaration of the variable is in effect while its init is parsed! */
1362		{ finish_init ();
1363		  finish_decl ($<ttype>5, $6, $2); }
1364	| notype_declarator maybeasm maybe_attribute
1365		{ tree d = start_decl ($1, current_declspecs, 0,
1366				       chainon ($3, all_prefix_attributes));
1367		  finish_decl (d, NULL_TREE, $2); }
1368	;
1369/* the * rules are dummies to accept the Apollo extended syntax
1370   so that the header files compile. */
1371maybe_attribute:
1372      /* empty */
1373  		{ $$ = NULL_TREE; }
1374	| attributes
1375		{ $$ = $1; }
1376	;
1377
1378attributes:
1379      attribute
1380		{ $$ = $1; }
1381	| attributes attribute
1382		{ $$ = chainon ($1, $2); }
1383	;
1384
1385attribute:
1386      ATTRIBUTE '(' '(' attribute_list ')' ')'
1387		{ $$ = $4; }
1388	;
1389
1390attribute_list:
1391      attrib
1392		{ $$ = $1; }
1393	| attribute_list ',' attrib
1394		{ $$ = chainon ($1, $3); }
1395	;
1396
1397attrib:
1398    /* empty */
1399		{ $$ = NULL_TREE; }
1400	| any_word
1401		{ $$ = build_tree_list ($1, NULL_TREE); }
1402	| any_word '(' IDENTIFIER ')'
1403		{ $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1404	| any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1405		{ $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1406	| any_word '(' exprlist ')'
1407		{ $$ = build_tree_list ($1, $3); }
1408	;
1409
1410/* This still leaves out most reserved keywords,
1411   shouldn't we include them?  */
1412
1413any_word:
1414	  identifier
1415	| scspec
1416	| TYPESPEC
1417	| TYPE_QUAL
1418	;
1419
1420scspec:
1421	  STATIC
1422	| SCSPEC
1423	;
1424
1425/* Initializers.  `init' is the entry point.  */
1426
1427init:
1428	expr_no_commas
1429	| '{'
1430		{ really_start_incremental_init (NULL_TREE); }
1431	  initlist_maybe_comma '}'
1432		{ $$ = pop_init_level (0); }
1433	| error
1434		{ $$ = error_mark_node; }
1435	;
1436
1437/* `initlist_maybe_comma' is the guts of an initializer in braces.  */
1438initlist_maybe_comma:
1439	  /* empty */
1440		{ if (pedantic)
1441		    pedwarn ("ISO C forbids empty initializer braces"); }
1442	| initlist1 maybecomma
1443	;
1444
1445initlist1:
1446	  initelt
1447	| initlist1 ',' initelt
1448	;
1449
1450/* `initelt' is a single element of an initializer.
1451   It may use braces.  */
1452initelt:
1453	  designator_list '=' initval
1454		{ if (pedantic && ! flag_isoc99)
1455		    pedwarn ("ISO C89 forbids specifying subobject to initialize"); }
1456	| designator initval
1457		{ if (pedantic)
1458		    pedwarn ("obsolete use of designated initializer without `='"); }
1459	| identifier ':'
1460		{ set_init_label ($1);
1461		  if (pedantic)
1462		    pedwarn ("obsolete use of designated initializer with `:'"); }
1463	  initval
1464		{}
1465	| initval
1466	;
1467
1468initval:
1469	  '{'
1470		{ push_init_level (0); }
1471	  initlist_maybe_comma '}'
1472		{ process_init_element (pop_init_level (0)); }
1473	| expr_no_commas
1474		{ process_init_element ($1); }
1475	| error
1476	;
1477
1478designator_list:
1479	  designator
1480	| designator_list designator
1481	;
1482
1483designator:
1484	  '.' identifier
1485		{ set_init_label ($2); }
1486	| '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1487		{ set_init_index ($2, $4);
1488		  if (pedantic)
1489		    pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1490	| '[' expr_no_commas ']'
1491		{ set_init_index ($2, NULL_TREE); }
1492	;
1493
1494nested_function:
1495	  declarator
1496		{ if (pedantic)
1497		    pedwarn ("ISO C forbids nested functions");
1498
1499		  push_function_context ();
1500		  if (! start_function (current_declspecs, $1,
1501					all_prefix_attributes))
1502		    {
1503		      pop_function_context ();
1504		      YYERROR1;
1505		    }
1506		  parsing_iso_function_signature = false; /* Don't warn about nested functions.  */
1507		}
1508	   old_style_parm_decls
1509		{ store_parm_decls (); }
1510/* This used to use compstmt_or_error.
1511   That caused a bug with input `f(g) int g {}',
1512   where the use of YYERROR1 above caused an error
1513   which then was handled by compstmt_or_error.
1514   There followed a repeated execution of that same rule,
1515   which called YYERROR1 again, and so on.  */
1516	  save_filename save_lineno compstmt
1517		{ tree decl = current_function_decl;
1518		  DECL_SOURCE_FILE (decl) = $5;
1519		  DECL_SOURCE_LINE (decl) = $6;
1520		  finish_function (1, 1);
1521		  pop_function_context ();
1522		  add_decl_stmt (decl); }
1523	;
1524
1525notype_nested_function:
1526	  notype_declarator
1527		{ if (pedantic)
1528		    pedwarn ("ISO C forbids nested functions");
1529
1530		  push_function_context ();
1531		  if (! start_function (current_declspecs, $1,
1532					all_prefix_attributes))
1533		    {
1534		      pop_function_context ();
1535		      YYERROR1;
1536		    }
1537		  parsing_iso_function_signature = false; /* Don't warn about nested functions.  */
1538		}
1539	  old_style_parm_decls
1540		{ store_parm_decls (); }
1541/* This used to use compstmt_or_error.
1542   That caused a bug with input `f(g) int g {}',
1543   where the use of YYERROR1 above caused an error
1544   which then was handled by compstmt_or_error.
1545   There followed a repeated execution of that same rule,
1546   which called YYERROR1 again, and so on.  */
1547	  save_filename save_lineno compstmt
1548		{ tree decl = current_function_decl;
1549		  DECL_SOURCE_FILE (decl) = $5;
1550		  DECL_SOURCE_LINE (decl) = $6;
1551		  finish_function (1, 1);
1552		  pop_function_context ();
1553		  add_decl_stmt (decl); }
1554	;
1555
1556/* Any kind of declarator (thus, all declarators allowed
1557   after an explicit typespec).  */
1558
1559declarator:
1560	  after_type_declarator
1561	| notype_declarator
1562	;
1563
1564/* A declarator that is allowed only after an explicit typespec.  */
1565
1566after_type_declarator:
1567	  '(' maybe_attribute after_type_declarator ')'
1568		{ $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1569	| after_type_declarator '(' parmlist_or_identifiers  %prec '.'
1570		{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1571/*	| after_type_declarator '(' error ')'  %prec '.'
1572		{ $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1573		  poplevel (0, 0, 0); }  */
1574	| after_type_declarator array_declarator  %prec '.'
1575		{ $$ = set_array_declarator_type ($2, $1, 0); }
1576	| '*' maybe_type_quals_attrs after_type_declarator  %prec UNARY
1577		{ $$ = make_pointer_declarator ($2, $3); }
1578	| TYPENAME
1579	;
1580
1581/* Kinds of declarator that can appear in a parameter list
1582   in addition to notype_declarator.  This is like after_type_declarator
1583   but does not allow a typedef name in parentheses as an identifier
1584   (because it would conflict with a function with that typedef as arg).  */
1585parm_declarator:
1586	  parm_declarator_starttypename
1587	| parm_declarator_nostarttypename
1588	;
1589
1590parm_declarator_starttypename:
1591	  parm_declarator_starttypename '(' parmlist_or_identifiers  %prec '.'
1592		{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1593/*	| parm_declarator_starttypename '(' error ')'  %prec '.'
1594		{ $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1595		  poplevel (0, 0, 0); }  */
1596	| parm_declarator_starttypename array_declarator  %prec '.'
1597		{ $$ = set_array_declarator_type ($2, $1, 0); }
1598	| TYPENAME
1599	;
1600
1601parm_declarator_nostarttypename:
1602	  parm_declarator_nostarttypename '(' parmlist_or_identifiers  %prec '.'
1603		{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1604/*	| parm_declarator_nostarttypename '(' error ')'  %prec '.'
1605		{ $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1606		  poplevel (0, 0, 0); }  */
1607	| parm_declarator_nostarttypename array_declarator…

Large files files are truncated, but you can click here to view the full file