PageRenderTime 69ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/osprey/kgccfe/gnu/c-parse.y

https://bitbucket.org/osunix/open64
Happy | 4011 lines | 3598 code | 413 blank | 0 comment | 0 complexity | 096dadafdb13c294c10f26603605c22d MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0, GPL-3.0
  1. /*
  2. * Copyright (C) 2006. QLogic Corporation. All Rights Reserved.
  3. */
  4. /*WARNING: This file is automatically generated from kgccfe/gnu/c-parse.in!
  5. ***WARNING***: And then modified to handle OpenMP constructs!*/
  6. /*
  7. Copyright 2004, 2005, 2006 PathScale, Inc. All Rights Reserved.
  8. File modified February 17, 2005 by PathScale, Inc. to add OpenMP support.
  9. */
  10. /* YACC parser for C syntax and for Objective C. -*-c-*-
  11. Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996,
  12. 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  13. This file is part of GCC.
  14. GCC is free software; you can redistribute it and/or modify it under
  15. the terms of the GNU General Public License as published by the Free
  16. Software Foundation; either version 2, or (at your option) any later
  17. version.
  18. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  19. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  20. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  21. for more details.
  22. You should have received a copy of the GNU General Public License
  23. along with GCC; see the file COPYING. If not, write to the Free
  24. Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  25. 02111-1307, USA. */
  26. /* This file defines the grammar of C and that of Objective C.
  27. ifobjc ... end ifobjc conditionals contain code for Objective C only.
  28. ifc ... end ifc conditionals contain code for C only.
  29. Sed commands in Makefile.in are used to convert this file into
  30. c-parse.y and into objc-parse.y. */
  31. /* To whomever it may concern: I have heard that such a thing was once
  32. written by AT&T, but I have never seen it. */
  33. %expect 10 /* shift/reduce conflicts, and no reduce/reduce conflicts. */
  34. %{
  35. #include "config.h"
  36. #include "system.h"
  37. #include "tree.h"
  38. #include "omp_types.h"
  39. #include "omp_directive.h"
  40. #include "input.h"
  41. #include "cpplib.h"
  42. #include "intl.h"
  43. #include "timevar.h"
  44. #include "c-pragma.h" /* For YYDEBUG definition, and parse_in. */
  45. #include "c-tree.h"
  46. #include "flags.h"
  47. #include "output.h"
  48. #include "toplev.h"
  49. #include "ggc.h"
  50. #ifdef MULTIBYTE_CHARS
  51. #include <locale.h>
  52. #endif
  53. /* Like YYERROR but do call yyerror. */
  54. #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
  55. /* Like the default stack expander, except (1) use realloc when possible,
  56. (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
  57. Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
  58. give malloced_yyvs its proper type. This is ok since all we need from
  59. it is to be able to free it. */
  60. static short *malloced_yyss;
  61. static void *malloced_yyvs;
  62. #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
  63. do { \
  64. size_t newsize; \
  65. short *newss; \
  66. YYSTYPE *newvs; \
  67. newsize = *(YYSSZ) *= 2; \
  68. if (malloced_yyss) \
  69. { \
  70. newss = (short *) \
  71. really_call_realloc (*(SS), newsize * sizeof (short)); \
  72. newvs = (YYSTYPE *) \
  73. really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
  74. } \
  75. else \
  76. { \
  77. newss = (short *) really_call_malloc (newsize * sizeof (short)); \
  78. newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
  79. if (newss) \
  80. memcpy (newss, *(SS), (SSSIZE)); \
  81. if (newvs) \
  82. memcpy (newvs, *(VS), (VSSIZE)); \
  83. } \
  84. if (!newss || !newvs) \
  85. { \
  86. yyerror (MSG); \
  87. return 2; \
  88. } \
  89. *(SS) = newss; \
  90. *(VS) = newvs; \
  91. malloced_yyss = newss; \
  92. malloced_yyvs = (void *) newvs; \
  93. } while (0)
  94. %}
  95. %start program
  96. %union {long itype; tree ttype; enum tree_code code;
  97. const char *filename; int lineno;
  98. enum reduction_op_type red_op_type;
  99. enum schedule_kind_type sch_k_type;
  100. struct parallel_clause_list * pclause_type;
  101. struct for_clause_list * for_clause_type;
  102. struct sections_clause_list * sections_clause_type;
  103. struct single_clause_list * single_clause_type;
  104. struct parallel_for_clause_list * parallel_for_clause_type;
  105. struct parallel_sections_clause_list * parallel_sections_clause_type;
  106. }
  107. /* All identifiers that are not reserved words
  108. and are not declared typedefs in the current block */
  109. %token IDENTIFIER
  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. /* Reserved words that specify storage class.
  115. yylval contains an IDENTIFIER_NODE which indicates which one. */
  116. %token SCSPEC /* Storage class other than static. */
  117. %token STATIC /* Static storage class. */
  118. /* Reserved words that specify type.
  119. yylval contains an IDENTIFIER_NODE which indicates which one. */
  120. %token TYPESPEC
  121. /* Reserved words that qualify type: "const", "volatile", or "restrict".
  122. yylval contains an IDENTIFIER_NODE which indicates which one. */
  123. %token TYPE_QUAL
  124. /* Character or numeric constants.
  125. yylval is the node for the constant. */
  126. %token CONSTANT
  127. /* String constants in raw form.
  128. yylval is a STRING_CST node. */
  129. %token STRING
  130. /* "...", used for functions with variable arglists. */
  131. %token ELLIPSIS
  132. %token PRAGMA_OPTIONS PRAGMA_EXEC_FREQ FREQ_NEVER FREQ_INIT FREQ_FREQUENT
  133. %token PRAGMA_UNROLL
  134. %token PRIVATE COPYPRIVATE FIRSTPRIVATE LASTPRIVATE SHARED DEFAULT NONE
  135. %token REDUCTION COPYIN DYNAMIC GUIDED RUNTIME ORDERED SCHEDULE
  136. %token NOWAIT PRAGMA_OMP PARALLEL NUM_THREADS SECTIONS SECTION
  137. %token SINGLE MASTER CRITICAL BARRIER
  138. %token ATOMIC FLUSH THREADPRIVATE
  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. /* function name can be a string const or a var decl. */
  147. %token STRING_FUNC_NAME VAR_FUNC_NAME
  148. /* Add precedence rules to solve dangling else s/r conflict */
  149. %nonassoc IF
  150. %nonassoc ELSE
  151. /* Define the operator tokens and their precedences.
  152. The value is an integer because, if used, it is the tree code
  153. to use in the expression made from the operator. */
  154. %right <code> ASSIGN '='
  155. %right <code> '?' ':'
  156. %left <code> OROR
  157. %left <code> ANDAND
  158. %left <code> '|'
  159. %left <code> '^'
  160. %left <code> '&'
  161. %left <code> EQCOMPARE
  162. %left <code> ARITHCOMPARE
  163. %left <code> LSHIFT RSHIFT
  164. %left <code> '+' '-'
  165. %left <code> '*' '/' '%'
  166. %right <code> UNARY PLUSPLUS MINUSMINUS
  167. %left HYPERUNARY
  168. %left <code> POINTSAT '.' '(' '['
  169. /* The Objective-C keywords. These are included in C and in
  170. Objective C, so that the token codes are the same in both. */
  171. %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
  172. %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
  173. %type <code> unop
  174. %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
  175. %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
  176. %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
  177. %type <ttype> expr_no_commas cast_expr unary_expr primary STRING
  178. %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
  179. %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
  180. %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
  181. %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
  182. %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
  183. %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
  184. %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
  185. %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
  186. %type <ttype> declspecs_ts declspecs_nots
  187. %type <ttype> declspecs_ts_nosa declspecs_nots_nosa
  188. %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
  189. %type <ttype> maybe_type_quals_attrs typespec_nonattr typespec_attr
  190. %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
  191. %type <ttype> typespec_nonreserved_nonattr
  192. %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_type_qual
  193. %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
  194. %type <ttype> init maybeasm
  195. %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
  196. %type <ttype> maybe_attribute attributes attribute attribute_list attrib
  197. %type <ttype> any_word extension
  198. %type <ttype> compstmt compstmt_start compstmt_nostart compstmt_primary_start
  199. %type <ttype> do_stmt_start poplevel stmt label structured_block
  200. %type <ttype> c99_block_start c99_block_end
  201. %type <ttype> declarator
  202. %type <ttype> notype_declarator after_type_declarator
  203. %type <ttype> parm_declarator
  204. %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
  205. %type <ttype> array_declarator
  206. %type <ttype> structsp_attr structsp_nonattr
  207. %type <ttype> component_decl_list component_decl_list2
  208. %type <ttype> component_decl components components_notype component_declarator
  209. %type <ttype> component_notype_declarator
  210. %type <ttype> enumlist enumerator
  211. %type <ttype> struct_head union_head enum_head
  212. %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
  213. %type <ttype> direct_absdcl1 absdcl_maybe_attribute
  214. %type <ttype> xexpr parms parm firstparm identifiers
  215. %type <ttype> parmlist parmlist_1 parmlist_2
  216. %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
  217. %type <ttype> identifiers_or_typenames
  218. %type <itype> setspecs setspecs_fp
  219. %type <filename> save_filename
  220. %type <lineno> save_lineno
  221. %type <ttype> options_directive pragma_directives exec_freq_directive
  222. %type <ttype> exec_freq_directive_ignore
  223. %type <ttype> unroll_directive
  224. %type <ttype> freq_hint
  225. %type <ttype> variable_list critical_directive region_phrase
  226. %type <red_op_type> reduction_operator
  227. %type <sch_k_type> schedule_kind
  228. %type <pclause_type> parallel_clause_list parallel_clause parallel_directive
  229. %type <ttype> openmp_construct parallel_construct for_construct sections_construct
  230. %type <ttype> single_construct parallel_for_construct parallel_sections_construct
  231. %type <ttype> master_construct critical_construct atomic_construct
  232. %type <ttype> ordered_construct
  233. %type <ttype> barrier_directive flush_directive
  234. %type <for_clause_type> for_clause_list for_clause for_directive
  235. %type <sections_clause_type> sections_clause_list sections_clause sections_directive
  236. %type <single_clause_type> single_clause single_clause_list single_directive
  237. %type <parallel_for_clause_type> parallel_for_clause parallel_for_clause_list parallel_for_directive
  238. %type <parallel_sections_clause_type> parallel_sections_clause parallel_sections_clause_list parallel_sections_directive
  239. /* sl2 fork_joint */
  240. %token SL2_SECTIONS SL2_MINOR_SECTIONS SL2_SECTION PRAGMA_SL2 SL2_MINOR_SECTION
  241. %type <ttype> sl2_sections_construct sl2_section_scope sl2_maybe_section_sequence
  242. %type <ttype> sl2_section_sequence sl2_maybe_structured_block sl2_section_construct
  243. %{
  244. /* Number of statements (loosely speaking) and compound statements
  245. seen so far. */
  246. static int stmt_count;
  247. static int compstmt_count;
  248. /* Input file and line number of the end of the body of last simple_if;
  249. used by the stmt-rule immediately after simple_if returns. */
  250. static const char *if_stmt_file;
  251. static int if_stmt_line;
  252. /* List of types and structure classes of the current declaration. */
  253. static GTY(()) tree current_declspecs;
  254. static GTY(()) tree prefix_attributes;
  255. /* List of all the attributes applying to the identifier currently being
  256. declared; includes prefix_attributes and possibly some more attributes
  257. just after a comma. */
  258. static GTY(()) tree all_prefix_attributes;
  259. /* Stack of saved values of current_declspecs, prefix_attributes and
  260. all_prefix_attributes. */
  261. static GTY(()) tree declspec_stack;
  262. /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
  263. should be called from the productions making use of setspecs. */
  264. #define PUSH_DECLSPEC_STACK \
  265. do { \
  266. declspec_stack = tree_cons (build_tree_list (prefix_attributes, \
  267. all_prefix_attributes), \
  268. current_declspecs, \
  269. declspec_stack); \
  270. } while (0)
  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. /* For __extension__, save/restore the warning flags which are
  279. controlled by __extension__. */
  280. #define SAVE_EXT_FLAGS() \
  281. size_int (pedantic \
  282. | (warn_pointer_arith << 1) \
  283. | (warn_traditional << 2) \
  284. | (flag_iso << 3))
  285. #define RESTORE_EXT_FLAGS(tval) \
  286. do { \
  287. int val = tree_low_cst (tval, 0); \
  288. pedantic = val & 1; \
  289. warn_pointer_arith = (val >> 1) & 1; \
  290. warn_traditional = (val >> 2) & 1; \
  291. flag_iso = (val >> 3) & 1; \
  292. } while (0)
  293. #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */
  294. static bool parsing_iso_function_signature;
  295. static bool In_MP_Region = false;
  296. static bool In_MP_Section = false;
  297. #define MAX_MP_NESTING 10
  298. static GTY(()) tree mp_locals[MAX_MP_NESTING];
  299. static int mp_nesting = -1;
  300. extern bool Is_shared_mp_var (tree);
  301. /* Tell yyparse how to print a token's value, if yydebug is set. */
  302. #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
  303. static void yyprint PARAMS ((FILE *, int, YYSTYPE));
  304. static void yyerror PARAMS ((const char *));
  305. static int yylexname PARAMS ((void));
  306. static int yylexstring PARAMS ((void));
  307. static inline int _yylex PARAMS ((void));
  308. static int yylex PARAMS ((void));
  309. static void init_reswords PARAMS ((void));
  310. /* Initialisation routine for this file. */
  311. void
  312. c_parse_init ()
  313. {
  314. init_reswords ();
  315. }
  316. %}
  317. %%
  318. program: /* empty */
  319. { if (pedantic)
  320. pedwarn ("ISO C forbids an empty source file");
  321. finish_file ();
  322. }
  323. | extdefs
  324. {
  325. /* In case there were missing closebraces,
  326. get us back to the global binding level. */
  327. while (! global_bindings_p ())
  328. poplevel (0, 0, 0);
  329. /* __FUNCTION__ is defined at file scope (""). This
  330. call may not be necessary as my tests indicate it
  331. still works without it. */
  332. finish_fname_decls ();
  333. finish_file ();
  334. }
  335. ;
  336. /* the reason for the strange actions in this rule
  337. is so that notype_initdecls when reached via datadef
  338. can find a valid list of type and sc specs in $0. */
  339. extdefs:
  340. {$<ttype>$ = NULL_TREE; } extdef
  341. | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
  342. ;
  343. extdef:
  344. extdef_1
  345. { parsing_iso_function_signature = false; } /* Reset after any external definition. */
  346. ;
  347. extdef_1:
  348. fndef
  349. | datadef
  350. | ASM_KEYWORD '(' expr ')' ';'
  351. { STRIP_NOPS ($3);
  352. if ((TREE_CODE ($3) == ADDR_EXPR
  353. && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
  354. || TREE_CODE ($3) == STRING_CST)
  355. assemble_asm ($3);
  356. else
  357. error ("argument of `asm' is not a constant string"); }
  358. | extension extdef
  359. { RESTORE_EXT_FLAGS ($1); }
  360. | threadprivate_directive
  361. | exec_freq_directive_ignore
  362. {}
  363. ;
  364. datadef:
  365. setspecs notype_initdecls ';'
  366. { if (pedantic)
  367. error ("ISO C forbids data definition with no type or storage class");
  368. else
  369. warning ("data definition has no type or storage class");
  370. POP_DECLSPEC_STACK; }
  371. | declspecs_nots setspecs notype_initdecls ';'
  372. { POP_DECLSPEC_STACK; }
  373. | declspecs_ts setspecs initdecls ';'
  374. { POP_DECLSPEC_STACK; }
  375. | declspecs ';'
  376. { shadow_tag ($1); }
  377. | error ';'
  378. | error '}'
  379. | ';'
  380. { if (pedantic)
  381. pedwarn ("ISO C does not allow extra `;' outside of a function"); }
  382. ;
  383. fndef:
  384. declspecs_ts setspecs declarator
  385. { if (! start_function (current_declspecs, $3,
  386. all_prefix_attributes))
  387. YYERROR1;
  388. }
  389. old_style_parm_decls
  390. { store_parm_decls (); }
  391. save_filename save_lineno compstmt_or_error
  392. { DECL_SOURCE_FILE (current_function_decl) = $7;
  393. DECL_SOURCE_LINE (current_function_decl) = $8;
  394. finish_function (0, 1);
  395. POP_DECLSPEC_STACK; }
  396. | declspecs_ts setspecs declarator error
  397. { POP_DECLSPEC_STACK; }
  398. | declspecs_nots setspecs notype_declarator
  399. { if (! start_function (current_declspecs, $3,
  400. all_prefix_attributes))
  401. YYERROR1;
  402. }
  403. old_style_parm_decls
  404. { store_parm_decls (); }
  405. save_filename save_lineno compstmt_or_error
  406. { DECL_SOURCE_FILE (current_function_decl) = $7;
  407. DECL_SOURCE_LINE (current_function_decl) = $8;
  408. finish_function (0, 1);
  409. POP_DECLSPEC_STACK; }
  410. | declspecs_nots setspecs notype_declarator error
  411. { POP_DECLSPEC_STACK; }
  412. | setspecs notype_declarator
  413. { if (! start_function (NULL_TREE, $2,
  414. all_prefix_attributes))
  415. YYERROR1;
  416. }
  417. old_style_parm_decls
  418. { store_parm_decls (); }
  419. save_filename save_lineno compstmt_or_error
  420. { DECL_SOURCE_FILE (current_function_decl) = $6;
  421. DECL_SOURCE_LINE (current_function_decl) = $7;
  422. finish_function (0, 1);
  423. POP_DECLSPEC_STACK; }
  424. | setspecs notype_declarator error
  425. { POP_DECLSPEC_STACK; }
  426. ;
  427. identifier:
  428. IDENTIFIER
  429. | TYPENAME
  430. ;
  431. unop: '&'
  432. { $$ = ADDR_EXPR; }
  433. | '-'
  434. { $$ = NEGATE_EXPR; }
  435. | '+'
  436. { $$ = CONVERT_EXPR;
  437. if (warn_traditional && !in_system_header)
  438. warning ("traditional C rejects the unary plus operator");
  439. }
  440. | PLUSPLUS
  441. { $$ = PREINCREMENT_EXPR; }
  442. | MINUSMINUS
  443. { $$ = PREDECREMENT_EXPR; }
  444. | '~'
  445. { $$ = BIT_NOT_EXPR; }
  446. | '!'
  447. { $$ = TRUTH_NOT_EXPR; }
  448. ;
  449. expr: nonnull_exprlist
  450. { $$ = build_compound_expr ($1); }
  451. ;
  452. exprlist:
  453. /* empty */
  454. { $$ = NULL_TREE; }
  455. | nonnull_exprlist
  456. ;
  457. nonnull_exprlist:
  458. expr_no_commas
  459. { $$ = build_tree_list (NULL_TREE, $1); }
  460. | nonnull_exprlist ',' expr_no_commas
  461. { chainon ($1, build_tree_list (NULL_TREE, $3)); }
  462. ;
  463. unary_expr:
  464. primary
  465. | '*' cast_expr %prec UNARY
  466. { $$ = build_indirect_ref ($2, "unary *"); }
  467. /* __extension__ turns off -pedantic for following primary. */
  468. | extension cast_expr %prec UNARY
  469. { $$ = $2;
  470. RESTORE_EXT_FLAGS ($1); }
  471. | unop cast_expr %prec UNARY
  472. { $$ = build_unary_op ($1, $2, 0);
  473. overflow_warning ($$); }
  474. /* Refer to the address of a label as a pointer. */
  475. | ANDAND identifier
  476. { $$ = finish_label_address_expr ($2); }
  477. | sizeof unary_expr %prec UNARY
  478. { skip_evaluation--;
  479. if (TREE_CODE ($2) == COMPONENT_REF
  480. && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
  481. error ("`sizeof' applied to a bit-field");
  482. $$ = c_sizeof (TREE_TYPE ($2)); }
  483. | sizeof '(' typename ')' %prec HYPERUNARY
  484. { skip_evaluation--;
  485. $$ = c_sizeof (groktypename ($3)); }
  486. | alignof unary_expr %prec UNARY
  487. { skip_evaluation--;
  488. $$ = c_alignof_expr ($2); }
  489. | alignof '(' typename ')' %prec HYPERUNARY
  490. { skip_evaluation--;
  491. $$ = c_alignof (groktypename ($3)); }
  492. | REALPART cast_expr %prec UNARY
  493. { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
  494. | IMAGPART cast_expr %prec UNARY
  495. { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
  496. ;
  497. sizeof:
  498. SIZEOF { skip_evaluation++; }
  499. ;
  500. alignof:
  501. ALIGNOF { skip_evaluation++; }
  502. ;
  503. typeof:
  504. TYPEOF { skip_evaluation++; }
  505. ;
  506. cast_expr:
  507. unary_expr
  508. | '(' typename ')' cast_expr %prec UNARY
  509. { $$ = c_cast_expr ($2, $4); }
  510. ;
  511. expr_no_commas:
  512. cast_expr
  513. | expr_no_commas '+' expr_no_commas
  514. { $$ = parser_build_binary_op ($2, $1, $3); }
  515. | expr_no_commas '-' expr_no_commas
  516. { $$ = parser_build_binary_op ($2, $1, $3); }
  517. | expr_no_commas '*' expr_no_commas
  518. { $$ = parser_build_binary_op ($2, $1, $3); }
  519. | expr_no_commas '/' expr_no_commas
  520. { $$ = parser_build_binary_op ($2, $1, $3); }
  521. | expr_no_commas '%' expr_no_commas
  522. { $$ = parser_build_binary_op ($2, $1, $3); }
  523. | expr_no_commas LSHIFT expr_no_commas
  524. { $$ = parser_build_binary_op ($2, $1, $3); }
  525. | expr_no_commas RSHIFT expr_no_commas
  526. { $$ = parser_build_binary_op ($2, $1, $3); }
  527. | expr_no_commas ARITHCOMPARE expr_no_commas
  528. { $$ = parser_build_binary_op ($2, $1, $3); }
  529. | expr_no_commas EQCOMPARE expr_no_commas
  530. { $$ = parser_build_binary_op ($2, $1, $3); }
  531. | expr_no_commas '&' expr_no_commas
  532. { $$ = parser_build_binary_op ($2, $1, $3); }
  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 ANDAND
  538. { $1 = c_common_truthvalue_conversion
  539. (default_conversion ($1));
  540. skip_evaluation += $1 == boolean_false_node; }
  541. expr_no_commas
  542. { skip_evaluation -= $1 == boolean_false_node;
  543. $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
  544. | expr_no_commas OROR
  545. { $1 = c_common_truthvalue_conversion
  546. (default_conversion ($1));
  547. skip_evaluation += $1 == boolean_true_node; }
  548. expr_no_commas
  549. { skip_evaluation -= $1 == boolean_true_node;
  550. $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
  551. | expr_no_commas '?'
  552. { $1 = c_common_truthvalue_conversion
  553. (default_conversion ($1));
  554. skip_evaluation += $1 == boolean_false_node; }
  555. expr ':'
  556. { skip_evaluation += (($1 == boolean_true_node)
  557. - ($1 == boolean_false_node)); }
  558. expr_no_commas
  559. { skip_evaluation -= $1 == boolean_true_node;
  560. $$ = build_conditional_expr ($1, $4, $7); }
  561. | expr_no_commas '?'
  562. { if (pedantic)
  563. pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
  564. /* Make sure first operand is calculated only once. */
  565. $<ttype>2 = save_expr ($1);
  566. $1 = c_common_truthvalue_conversion
  567. (default_conversion ($<ttype>2));
  568. skip_evaluation += $1 == boolean_true_node; }
  569. ':' expr_no_commas
  570. { skip_evaluation -= $1 == boolean_true_node;
  571. $$ = build_conditional_expr ($1, $<ttype>2, $5); }
  572. | expr_no_commas '=' expr_no_commas
  573. { char class;
  574. $$ = build_modify_expr ($1, NOP_EXPR, $3);
  575. class = TREE_CODE_CLASS (TREE_CODE ($$));
  576. if (IS_EXPR_CODE_CLASS (class))
  577. C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
  578. }
  579. | expr_no_commas ASSIGN expr_no_commas
  580. { char class;
  581. $$ = build_modify_expr ($1, $2, $3);
  582. /* This inhibits warnings in
  583. c_common_truthvalue_conversion. */
  584. class = TREE_CODE_CLASS (TREE_CODE ($$));
  585. if (IS_EXPR_CODE_CLASS (class))
  586. C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
  587. }
  588. ;
  589. primary:
  590. IDENTIFIER
  591. {
  592. if (yychar == YYEMPTY)
  593. yychar = YYLEX;
  594. $$ = build_external_ref ($1, yychar == '(');
  595. }
  596. | CONSTANT
  597. | STRING
  598. { $$ = fix_string_type ($$); }
  599. | VAR_FUNC_NAME
  600. { $$ = fname_decl (C_RID_CODE ($$), $$); }
  601. | '(' typename ')' '{'
  602. { start_init (NULL_TREE, NULL, 0);
  603. $2 = groktypename ($2);
  604. really_start_incremental_init ($2); }
  605. initlist_maybe_comma '}' %prec UNARY
  606. { tree constructor = pop_init_level (0);
  607. tree type = $2;
  608. finish_init ();
  609. if (pedantic && ! flag_isoc99)
  610. pedwarn ("ISO C89 forbids compound literals");
  611. $$ = build_compound_literal (type, constructor);
  612. }
  613. | '(' expr ')'
  614. { char class = TREE_CODE_CLASS (TREE_CODE ($2));
  615. if (IS_EXPR_CODE_CLASS (class))
  616. C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
  617. $$ = $2; }
  618. | '(' error ')'
  619. { $$ = error_mark_node; }
  620. | compstmt_primary_start compstmt_nostart ')'
  621. { tree saved_last_tree;
  622. if (pedantic)
  623. pedwarn ("ISO C forbids braced-groups within expressions");
  624. pop_label_level ();
  625. saved_last_tree = COMPOUND_BODY ($1);
  626. RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
  627. last_tree = saved_last_tree;
  628. TREE_CHAIN (last_tree) = NULL_TREE;
  629. if (!last_expr_type)
  630. last_expr_type = void_type_node;
  631. $$ = build1 (STMT_EXPR, last_expr_type, $1);
  632. TREE_SIDE_EFFECTS ($$) = 1;
  633. }
  634. | compstmt_primary_start error ')'
  635. {
  636. pop_label_level ();
  637. last_tree = COMPOUND_BODY ($1);
  638. TREE_CHAIN (last_tree) = NULL_TREE;
  639. $$ = error_mark_node;
  640. }
  641. | primary '(' exprlist ')' %prec '.'
  642. { $$ = build_function_call ($1, $3); }
  643. | VA_ARG '(' expr_no_commas ',' typename ')'
  644. { $$ = build_va_arg ($3, groktypename ($5)); }
  645. | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ',' expr_no_commas ')'
  646. {
  647. tree c;
  648. c = fold ($3);
  649. STRIP_NOPS (c);
  650. if (TREE_CODE (c) != INTEGER_CST)
  651. error ("first argument to __builtin_choose_expr not a constant");
  652. $$ = integer_zerop (c) ? $7 : $5;
  653. }
  654. | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
  655. {
  656. tree e1, e2;
  657. e1 = TYPE_MAIN_VARIANT (groktypename ($3));
  658. e2 = TYPE_MAIN_VARIANT (groktypename ($5));
  659. $$ = comptypes (e1, e2)
  660. ? build_int_2 (1, 0) : build_int_2 (0, 0);
  661. }
  662. | primary '[' expr ']' %prec '.'
  663. { $$ = build_array_ref ($1, $3); }
  664. | primary '.' identifier
  665. {
  666. $$ = build_component_ref ($1, $3);
  667. }
  668. | primary POINTSAT identifier
  669. {
  670. tree expr = build_indirect_ref ($1, "->");
  671. $$ = build_component_ref (expr, $3);
  672. }
  673. | primary PLUSPLUS
  674. { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
  675. | primary MINUSMINUS
  676. { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
  677. ;
  678. old_style_parm_decls:
  679. old_style_parm_decls_1
  680. {
  681. parsing_iso_function_signature = false; /* Reset after decls. */
  682. }
  683. ;
  684. old_style_parm_decls_1:
  685. /* empty */
  686. {
  687. if (warn_traditional && !in_system_header
  688. && parsing_iso_function_signature)
  689. warning ("traditional C rejects ISO C style function definitions");
  690. parsing_iso_function_signature = false; /* Reset after warning. */
  691. }
  692. | datadecls
  693. ;
  694. /* The following are analogous to lineno_decl, decls and decl
  695. except that they do not allow nested functions.
  696. They are used for old-style parm decls. */
  697. lineno_datadecl:
  698. save_filename save_lineno datadecl
  699. { }
  700. ;
  701. datadecls:
  702. lineno_datadecl
  703. | errstmt
  704. | datadecls lineno_datadecl
  705. | lineno_datadecl errstmt
  706. ;
  707. /* We don't allow prefix attributes here because they cause reduce/reduce
  708. conflicts: we can't know whether we're parsing a function decl with
  709. attribute suffix, or function defn with attribute prefix on first old
  710. style parm. */
  711. datadecl:
  712. declspecs_ts_nosa setspecs initdecls ';'
  713. { POP_DECLSPEC_STACK; }
  714. | declspecs_nots_nosa setspecs notype_initdecls ';'
  715. { POP_DECLSPEC_STACK; }
  716. | declspecs_ts_nosa ';'
  717. { shadow_tag_warned ($1, 1);
  718. pedwarn ("empty declaration"); }
  719. | declspecs_nots_nosa ';'
  720. { pedwarn ("empty declaration"); }
  721. ;
  722. /* This combination which saves a lineno before a decl
  723. is the normal thing to use, rather than decl itself.
  724. This is to avoid shift/reduce conflicts in contexts
  725. where statement labels are allowed. */
  726. lineno_decl:
  727. save_filename save_lineno decl
  728. { }
  729. ;
  730. /* records the type and storage class specs to use for processing
  731. the declarators that follow.
  732. Maintains a stack of outer-level values of current_declspecs,
  733. for the sake of parm declarations nested in function declarators. */
  734. setspecs: /* empty */
  735. { pending_xref_error ();
  736. PUSH_DECLSPEC_STACK;
  737. split_specs_attrs ($<ttype>0,
  738. &current_declspecs, &prefix_attributes);
  739. all_prefix_attributes = prefix_attributes; }
  740. ;
  741. /* Possibly attributes after a comma, which should reset all_prefix_attributes
  742. to prefix_attributes with these ones chained on the front. */
  743. maybe_resetattrs:
  744. maybe_attribute
  745. { all_prefix_attributes = chainon ($1, prefix_attributes); }
  746. ;
  747. decl:
  748. declspecs_ts setspecs initdecls ';'
  749. { POP_DECLSPEC_STACK; }
  750. | declspecs_nots setspecs notype_initdecls ';'
  751. { POP_DECLSPEC_STACK; }
  752. | declspecs_ts setspecs nested_function
  753. { POP_DECLSPEC_STACK; }
  754. | declspecs_nots setspecs notype_nested_function
  755. { POP_DECLSPEC_STACK; }
  756. | declspecs ';'
  757. { shadow_tag ($1); }
  758. | extension decl
  759. { RESTORE_EXT_FLAGS ($1); }
  760. ;
  761. /* A list of declaration specifiers. These are:
  762. - Storage class specifiers (scspec), which for GCC currently includes
  763. function specifiers ("inline").
  764. - Type specifiers (typespec_*).
  765. - Type qualifiers (TYPE_QUAL).
  766. - Attribute specifier lists (attributes).
  767. These are stored as a TREE_LIST; the head of the list is the last
  768. item in the specifier list. Each entry in the list has either a
  769. TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
  770. is a single other specifier or qualifier; and a TREE_CHAIN that is the
  771. rest of the list. TREE_STATIC is set on the list if something other
  772. than a storage class specifier or attribute has been seen; this is used
  773. to warn for the obsolescent usage of storage class specifiers other than
  774. at the start of the list. (Doing this properly would require function
  775. specifiers to be handled separately from storage class specifiers.)
  776. The various cases below are classified according to:
  777. (a) Whether a storage class specifier is included or not; some
  778. places in the grammar disallow storage class specifiers (_sc or _nosc).
  779. (b) Whether a type specifier has been seen; after a type specifier,
  780. a typedef name is an identifier to redeclare (_ts or _nots).
  781. (c) Whether the list starts with an attribute; in certain places,
  782. the grammar requires specifiers that don't start with an attribute
  783. (_sa or _nosa).
  784. (d) Whether the list ends with an attribute (or a specifier such that
  785. any following attribute would have been parsed as part of that specifier);
  786. this avoids shift-reduce conflicts in the parsing of attributes
  787. (_ea or _noea).
  788. TODO:
  789. (i) Distinguish between function specifiers and storage class specifiers,
  790. at least for the purpose of warnings about obsolescent usage.
  791. (ii) Halve the number of productions here by eliminating the _sc/_nosc
  792. distinction and instead checking where required that storage class
  793. specifiers aren't present. */
  794. /* Declspecs which contain at least one type specifier or typedef name.
  795. (Just `const' or `volatile' is not enough.)
  796. A typedef'd name following these is taken as a name to be declared.
  797. Declspecs have a non-NULL TREE_VALUE, attributes do not. */
  798. declspecs_nosc_nots_nosa_noea:
  799. TYPE_QUAL
  800. { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  801. TREE_STATIC ($$) = 1; }
  802. | declspecs_nosc_nots_nosa_noea TYPE_QUAL
  803. { $$ = tree_cons (NULL_TREE, $2, $1);
  804. TREE_STATIC ($$) = 1; }
  805. | declspecs_nosc_nots_nosa_ea TYPE_QUAL
  806. { $$ = tree_cons (NULL_TREE, $2, $1);
  807. TREE_STATIC ($$) = 1; }
  808. ;
  809. declspecs_nosc_nots_nosa_ea:
  810. declspecs_nosc_nots_nosa_noea attributes
  811. { $$ = tree_cons ($2, NULL_TREE, $1);
  812. TREE_STATIC ($$) = TREE_STATIC ($1); }
  813. ;
  814. declspecs_nosc_nots_sa_noea:
  815. declspecs_nosc_nots_sa_noea TYPE_QUAL
  816. { $$ = tree_cons (NULL_TREE, $2, $1);
  817. TREE_STATIC ($$) = 1; }
  818. | declspecs_nosc_nots_sa_ea TYPE_QUAL
  819. { $$ = tree_cons (NULL_TREE, $2, $1);
  820. TREE_STATIC ($$) = 1; }
  821. ;
  822. declspecs_nosc_nots_sa_ea:
  823. attributes
  824. { $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
  825. TREE_STATIC ($$) = 0; }
  826. | declspecs_nosc_nots_sa_noea attributes
  827. { $$ = tree_cons ($2, NULL_TREE, $1);
  828. TREE_STATIC ($$) = TREE_STATIC ($1); }
  829. ;
  830. declspecs_nosc_ts_nosa_noea:
  831. typespec_nonattr
  832. { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  833. TREE_STATIC ($$) = 1; }
  834. | declspecs_nosc_ts_nosa_noea TYPE_QUAL
  835. { $$ = tree_cons (NULL_TREE, $2, $1);
  836. TREE_STATIC ($$) = 1; }
  837. | declspecs_nosc_ts_nosa_ea TYPE_QUAL
  838. { $$ = tree_cons (NULL_TREE, $2, $1);
  839. TREE_STATIC ($$) = 1; }
  840. | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
  841. { $$ = tree_cons (NULL_TREE, $2, $1);
  842. TREE_STATIC ($$) = 1; }
  843. | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
  844. { $$ = tree_cons (NULL_TREE, $2, $1);
  845. TREE_STATIC ($$) = 1; }
  846. | declspecs_nosc_nots_nosa_noea typespec_nonattr
  847. { $$ = tree_cons (NULL_TREE, $2, $1);
  848. TREE_STATIC ($$) = 1; }
  849. | declspecs_nosc_nots_nosa_ea typespec_nonattr
  850. { $$ = tree_cons (NULL_TREE, $2, $1);
  851. TREE_STATIC ($$) = 1; }
  852. ;
  853. declspecs_nosc_ts_nosa_ea:
  854. typespec_attr
  855. { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  856. TREE_STATIC ($$) = 1; }
  857. | declspecs_nosc_ts_nosa_noea attributes
  858. { $$ = tree_cons ($2, NULL_TREE, $1);
  859. TREE_STATIC ($$) = TREE_STATIC ($1); }
  860. | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
  861. { $$ = tree_cons (NULL_TREE, $2, $1);
  862. TREE_STATIC ($$) = 1; }
  863. | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
  864. { $$ = tree_cons (NULL_TREE, $2, $1);
  865. TREE_STATIC ($$) = 1; }
  866. | declspecs_nosc_nots_nosa_noea typespec_attr
  867. { $$ = tree_cons (NULL_TREE, $2, $1);
  868. TREE_STATIC ($$) = 1; }
  869. | declspecs_nosc_nots_nosa_ea typespec_attr
  870. { $$ = tree_cons (NULL_TREE, $2, $1);
  871. TREE_STATIC ($$) = 1; }
  872. ;
  873. declspecs_nosc_ts_sa_noea:
  874. declspecs_nosc_ts_sa_noea TYPE_QUAL
  875. { $$ = tree_cons (NULL_TREE, $2, $1);
  876. TREE_STATIC ($$) = 1; }
  877. | declspecs_nosc_ts_sa_ea TYPE_QUAL
  878. { $$ = tree_cons (NULL_TREE, $2, $1);
  879. TREE_STATIC ($$) = 1; }
  880. | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
  881. { $$ = tree_cons (NULL_TREE, $2, $1);
  882. TREE_STATIC ($$) = 1; }
  883. | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
  884. { $$ = tree_cons (NULL_TREE, $2, $1);
  885. TREE_STATIC ($$) = 1; }
  886. | declspecs_nosc_nots_sa_noea typespec_nonattr
  887. { $$ = tree_cons (NULL_TREE, $2, $1);
  888. TREE_STATIC ($$) = 1; }
  889. | declspecs_nosc_nots_sa_ea typespec_nonattr
  890. { $$ = tree_cons (NULL_TREE, $2, $1);
  891. TREE_STATIC ($$) = 1; }
  892. ;
  893. declspecs_nosc_ts_sa_ea:
  894. declspecs_nosc_ts_sa_noea attributes
  895. { $$ = tree_cons ($2, NULL_TREE, $1);
  896. TREE_STATIC ($$) = TREE_STATIC ($1); }
  897. | declspecs_nosc_ts_sa_noea typespec_reserved_attr
  898. { $$ = tree_cons (NULL_TREE, $2, $1);
  899. TREE_STATIC ($$) = 1; }
  900. | declspecs_nosc_ts_sa_ea typespec_reserved_attr
  901. { $$ = tree_cons (NULL_TREE, $2, $1);
  902. TREE_STATIC ($$) = 1; }
  903. | declspecs_nosc_nots_sa_noea typespec_attr
  904. { $$ = tree_cons (NULL_TREE, $2, $1);
  905. TREE_STATIC ($$) = 1; }
  906. | declspecs_nosc_nots_sa_ea typespec_attr
  907. { $$ = tree_cons (NULL_TREE, $2, $1);
  908. TREE_STATIC ($$) = 1; }
  909. ;
  910. declspecs_sc_nots_nosa_noea:
  911. scspec
  912. { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  913. TREE_STATIC ($$) = 0; }
  914. | declspecs_sc_nots_nosa_noea TYPE_QUAL
  915. { $$ = tree_cons (NULL_TREE, $2, $1);
  916. TREE_STATIC ($$) = 1; }
  917. | declspecs_sc_nots_nosa_ea TYPE_QUAL
  918. { $$ = tree_cons (NULL_TREE, $2, $1);
  919. TREE_STATIC ($$) = 1; }
  920. | declspecs_nosc_nots_nosa_noea scspec
  921. { if (extra_warnings && TREE_STATIC ($1))
  922. warning ("`%s' is not at beginning of declaration",
  923. IDENTIFIER_POINTER ($2));
  924. $$ = tree_cons (NULL_TREE, $2, $1);
  925. TREE_STATIC ($$) = TREE_STATIC ($1); }
  926. | declspecs_nosc_nots_nosa_ea scspec
  927. { if (extra_warnings && TREE_STATIC ($1))
  928. warning ("`%s' is not at beginning of declaration",
  929. IDENTIFIER_POINTER ($2));
  930. $$ = tree_cons (NULL_TREE, $2, $1);
  931. TREE_STATIC ($$) = TREE_STATIC ($1); }
  932. | declspecs_sc_nots_nosa_noea scspec
  933. { if (extra_warnings && TREE_STATIC ($1))
  934. warning ("`%s' is not at beginning of declaration",
  935. IDENTIFIER_POINTER ($2));
  936. $$ = tree_cons (NULL_TREE, $2, $1);
  937. TREE_STATIC ($$) = TREE_STATIC ($1); }
  938. | declspecs_sc_nots_nosa_ea scspec
  939. { if (extra_warnings && TREE_STATIC ($1))
  940. warning ("`%s' is not at beginning of declaration",
  941. IDENTIFIER_POINTER ($2));
  942. $$ = tree_cons (NULL_TREE, $2, $1);
  943. TREE_STATIC ($$) = TREE_STATIC ($1); }
  944. ;
  945. declspecs_sc_nots_nosa_ea:
  946. declspecs_sc_nots_nosa_noea attributes
  947. { $$ = tree_cons ($2, NULL_TREE, $1);
  948. TREE_STATIC ($$) = TREE_STATIC ($1); }
  949. ;
  950. declspecs_sc_nots_sa_noea:
  951. declspecs_sc_nots_sa_noea TYPE_QUAL
  952. { $$ = tree_cons (NULL_TREE, $2, $1);
  953. TREE_STATIC ($$) = 1; }
  954. | declspecs_sc_nots_sa_ea TYPE_QUAL
  955. { $$ = tree_cons (NULL_TREE, $2, $1);
  956. TREE_STATIC ($$) = 1; }
  957. | declspecs_nosc_nots_sa_noea scspec
  958. { if (extra_warnings && TREE_STATIC ($1))
  959. warning ("`%s' is not at beginning of declaration",
  960. IDENTIFIER_POINTER ($2));
  961. $$ = tree_cons (NULL_TREE, $2, $1);
  962. TREE_STATIC ($$) = TREE_STATIC ($1); }
  963. | declspecs_nosc_nots_sa_ea scspec
  964. { if (extra_warnings && TREE_STATIC ($1))
  965. warning ("`%s' is not at beginning of declaration",
  966. IDENTIFIER_POINTER ($2));
  967. $$ = tree_cons (NULL_TREE, $2, $1);
  968. TREE_STATIC ($$) = TREE_STATIC ($1); }
  969. | declspecs_sc_nots_sa_noea scspec
  970. { if (extra_warnings && TREE_STATIC ($1))
  971. warning ("`%s' is not at beginning of declaration",
  972. IDENTIFIER_POINTER ($2));
  973. $$ = tree_cons (NULL_TREE, $2, $1);
  974. TREE_STATIC ($$) = TREE_STATIC ($1); }
  975. | declspecs_sc_nots_sa_ea scspec
  976. { if (extra_warnings && TREE_STATIC ($1))
  977. warning ("`%s' is not at beginning of declaration",
  978. IDENTIFIER_POINTER ($2));
  979. $$ = tree_cons (NULL_TREE, $2, $1);
  980. TREE_STATIC ($$) = TREE_STATIC ($1); }
  981. ;
  982. declspecs_sc_nots_sa_ea:
  983. declspecs_sc_nots_sa_noea attributes
  984. { $$ = tree_cons ($2, NULL_TREE, $1);
  985. TREE_STATIC ($$) = TREE_STATIC ($1); }
  986. ;
  987. declspecs_sc_ts_nosa_noea:
  988. declspecs_sc_ts_nosa_noea TYPE_QUAL
  989. { $$ = tree_cons (NULL_TREE, $2, $1);
  990. TREE_STATIC ($$) = 1; }
  991. | declspecs_sc_ts_nosa_ea TYPE_QUAL
  992. { $$ = tree_cons (NULL_TREE, $2, $1);
  993. TREE_STATIC ($$) = 1; }
  994. | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
  995. { $$ = tree_cons (NULL_TREE, $2, $1);
  996. TREE_STATIC ($$) = 1; }
  997. | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
  998. { $$ = tree_cons (NULL_TREE, $2, $1);
  999. TREE_STATIC ($$) = 1; }
  1000. | declspecs_sc_nots_nosa_noea typespec_nonattr
  1001. { $$ = tree_cons (NULL_TREE, $2, $1);
  1002. TREE_STATIC ($$) = 1; }
  1003. | declspecs_sc_nots_nosa_ea typespec_nonattr
  1004. { $$ = tree_cons (NULL_TREE, $2, $1);
  1005. TREE_STATIC ($$) = 1; }
  1006. | declspecs_nosc_ts_nosa_noea scspec
  1007. { if (extra_warnings && TREE_STATIC ($1))
  1008. warning ("`%s' is not at beginning of declaration",
  1009. IDENTIFIER_POINTER ($2));
  1010. $$ = tree_cons (NULL_TREE, $2, $1);
  1011. TREE_STATIC ($$) = TREE_STATIC ($1); }
  1012. | declspecs_nosc_ts_nosa_ea scspec
  1013. { if (extra_warnings && TREE_STATIC ($1))
  1014. warning ("`%s' is not at beginning of declaration",
  1015. IDENTIFIER_POINTER ($2));
  1016. $$ = tree_cons (NULL_TREE, $2, $1);
  1017. TREE_STATIC ($$) = TREE_STATIC ($1); }
  1018. | declspecs_sc_ts_nosa_noea scspec
  1019. { if (extra_warnings && TREE_STATIC ($1))
  1020. warning ("`%s' is not at beginning of declaration",
  1021. IDENTIFIER_POINTER ($2));
  1022. $$ = tree_cons (NULL_TREE, $2, $1);
  1023. TREE_STATIC ($$) = TREE_STATIC ($1); }
  1024. | declspecs_sc_ts_nosa_ea scspec
  1025. { if (extra_warnings && TREE_STATIC ($1))
  1026. warning ("`%s' is not at beginning of declaration",
  1027. IDENTIFIER_POINTER ($2));
  1028. $$ = tree_cons (NULL_TREE, $2, $1);
  1029. TREE_STATIC ($$) = TREE_STATIC ($1); }
  1030. ;
  1031. declspecs_sc_ts_nosa_ea:
  1032. declspecs_sc_ts_nosa_noea attributes
  1033. { $$ = tree_cons ($2, NULL_TREE, $1);
  1034. TREE_STATIC ($$) = TREE_STATIC ($1); }
  1035. | declspecs_sc_ts_nosa_noea typespec_reserved_attr
  1036. { $$ = tree_cons (NULL_TREE, $2, $1);
  1037. TREE_STATIC ($$) = 1; }
  1038. | declspecs_sc_ts_nosa_ea typespec_reserved_attr
  1039. { $$ = tree_cons (NULL_TREE, $2, $1);
  1040. TREE_STATIC ($$) = 1; }
  1041. | declspecs_sc_nots_nosa_noea typespec_attr
  1042. { $$ = tree_cons (NULL_TREE, $2, $1);
  1043. TREE_STATIC ($$) = 1; }
  1044. | declspecs_sc_nots_nosa_ea typespec_attr
  1045. { $$ = tree_cons (NULL_TREE, $2, $1);
  1046. TREE_STATIC ($$) = 1; }
  1047. ;
  1048. declspecs_sc_ts_sa_noea:
  1049. declspecs_sc_ts_sa_noea TYPE_QUAL
  1050. { $$ = tree_cons (NULL_TREE, $2, $1);
  1051. TREE_STATIC ($$) = 1; }
  1052. | declspecs_sc_ts_sa_ea TYPE_QUAL
  1053. { $$ = tree_cons (NULL_TREE, $2, $1);
  1054. TREE_STATIC ($$) = 1; }
  1055. | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
  1056. { $$ = tree_cons (NULL_TREE, $2, $1);
  1057. TREE_STATIC ($$) = 1; }
  1058. | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
  1059. { $$ = tree_cons (NULL_TREE, $2, $1);
  1060. TREE_STATIC ($$) = 1; }
  1061. | declspecs_sc_nots_sa_noea typespec_nonattr
  1062. { $$ = tree_cons (NULL_TREE, $2, $1);
  1063. TREE_STATIC ($$) = 1; }
  1064. | declspecs_sc_nots_sa_ea typespec_nonattr
  1065. { $$ = tree_cons (NULL_TREE, $2, $1);
  1066. TREE_STATIC ($$) = 1; }
  1067. | declspecs_nosc_ts_sa_noea scspec
  1068. { if (extra_warnings && TREE_STATIC ($1))
  1069. warning ("`%s' is not at beginning of declaration",
  1070. IDENTIFIER_POINTER ($2));
  1071. $$ = tree_cons (NULL_TREE, $2, $1);
  1072. TREE_STATIC ($$) = TREE_STATIC ($1); }
  1073. | declspecs_nosc_ts_sa_ea 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_sc_ts_sa_noea 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_sa_ea 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. ;
  1092. declspecs_sc_ts_sa_ea:
  1093. declspecs_sc_ts_sa_noea attributes
  1094. { $$ = tree_cons ($2, NULL_TREE, $1);
  1095. TREE_STATIC ($$) = TREE_STATIC ($1); }
  1096. | declspecs_sc_ts_sa_noea typespec_reserved_attr
  1097. { $$ = tree_cons (NULL_TREE, $2, $1);
  1098. TREE_STATIC ($$) = 1; }
  1099. | declspecs_sc_ts_sa_ea typespec_reserved_attr
  1100. { $$ = tree_cons (NULL_TREE, $2, $1);
  1101. TREE_STATIC ($$) = 1; }
  1102. | declspecs_sc_nots_sa_noea typespec_attr
  1103. { $$ = tree_cons (NULL_TREE, $2, $1);
  1104. TREE_STATIC ($$) = 1; }
  1105. | declspecs_sc_nots_sa_ea typespec_attr
  1106. { $$ = tree_cons (NULL_TREE, $2, $1);
  1107. TREE_STATIC ($$) = 1; }
  1108. ;
  1109. /* Particular useful classes of declspecs. */
  1110. declspecs_ts:
  1111. declspecs_nosc_ts_nosa_noea
  1112. | declspecs_nosc_ts_nosa_ea
  1113. | declspecs_nosc_ts_sa_noea
  1114. | declspecs_nosc_ts_sa_ea
  1115. | declspecs_sc_ts_nosa_noea
  1116. | declspecs_sc_ts_nosa_ea
  1117. | declspecs_sc_ts_sa_noea
  1118. | declspecs_sc_ts_sa_ea
  1119. ;
  1120. declspecs_nots:
  1121. declspecs_nosc_nots_nosa_noea
  1122. | declspecs_nosc_nots_nosa_ea
  1123. | declspecs_nosc_nots_sa_noea
  1124. | declspecs_nosc_nots_sa_ea
  1125. | declspecs_sc_nots_nosa_noea
  1126. | declspecs_sc_nots_nosa_ea
  1127. | declspecs_sc_nots_sa_noea
  1128. | declspecs_sc_nots_sa_ea
  1129. ;
  1130. declspecs_ts_nosa:
  1131. declspecs_nosc_ts_nosa_noea
  1132. | declspecs_nosc_ts_nosa_ea
  1133. | declspecs_sc_ts_nosa_noea
  1134. | declspecs_sc_ts_nosa_ea
  1135. ;
  1136. declspecs_nots_nosa:
  1137. declspecs_nosc_nots_nosa_noea
  1138. | declspecs_nosc_nots_nosa_ea
  1139. | declspecs_sc_nots_nosa_noea
  1140. | declspecs_sc_nots_nosa_ea
  1141. ;
  1142. declspecs_nosc_ts:
  1143. declspecs_nosc_ts_nosa_noea
  1144. | declspecs_nosc_ts_nosa_ea
  1145. | declspecs_nosc_ts_sa_noea
  1146. | declspecs_nosc_ts_sa_ea
  1147. ;
  1148. declspecs_nosc_nots:
  1149. declspecs_nosc_nots_nosa_noea
  1150. | declspecs_nosc_nots_nosa_ea
  1151. | declspecs_nosc_nots_sa_noea
  1152. | declspecs_nosc_nots_sa_ea
  1153. ;
  1154. declspecs_nosc:
  1155. declspecs_nosc_ts_nosa_noea
  1156. | declspecs_nosc_ts_nosa_ea
  1157. | declspecs_nosc_ts_sa_noea
  1158. | declspecs_nosc_ts_sa_ea
  1159. | declspecs_nosc_nots_nosa_noea
  1160. | declspecs_nosc_nots_nosa_ea
  1161. | declspecs_nosc_nots_sa_noea
  1162. | declspecs_nosc_nots_sa_ea
  1163. ;
  1164. declspecs:
  1165. declspecs_nosc_nots_nosa_noea
  1166. | declspecs_nosc_nots_nosa_ea
  1167. | declspecs_nosc_nots_sa_noea
  1168. | declspecs_nosc_nots_sa_ea
  1169. | declspecs_nosc_ts_nosa_noea
  1170. | declspecs_nosc_ts_nosa_ea
  1171. | declspecs_nosc_ts_sa_noea
  1172. | declspecs_nosc_ts_sa_ea
  1173. | declspecs_sc_nots_nosa_noea
  1174. | declspecs_sc_nots_nosa_ea
  1175. | declspecs_sc_nots_sa_noea
  1176. | declspecs_sc_nots_sa_ea
  1177. | declspecs_sc_ts_nosa_noea
  1178. | declspecs_sc_ts_nosa_ea
  1179. | declspecs_sc_ts_sa_noea
  1180. | declspecs_sc_ts_sa_ea
  1181. ;
  1182. /* A (possibly empty) sequence of type qualifiers and attributes. */
  1183. maybe_type_quals_attrs:
  1184. /* empty */
  1185. { $$ = NULL_TREE; }
  1186. | declspecs_nosc_nots
  1187. { $$ = $1; }
  1188. ;
  1189. /* A type specifier (but not a type qualifier).
  1190. Once we have seen one of these in a declaration,
  1191. if a typedef name appears then it is being redeclared.
  1192. The _reserved versions start with a reserved word and may appear anywhere
  1193. in the declaration specifiers; the _nonreserved versions may only
  1194. appear before any other type specifiers, and after that are (if names)
  1195. being redeclared.
  1196. FIXME: should the _nonreserved version be restricted to names being
  1197. redeclared only? The other entries there relate only the GNU extensions
  1198. and Objective C, and are historically parsed thus, and don't make sense
  1199. after other type specifiers, but it might be cleaner to count them as
  1200. _reserved.
  1201. _attr means: specifiers that either end with attributes,
  1202. or are such that any following attributes would
  1203. be parsed as part of the specifier.
  1204. _nonattr: specifiers. */
  1205. typespec_nonattr:
  1206. typespec_reserved_nonattr
  1207. | typespec_nonreserved_nonattr
  1208. ;
  1209. typespec_attr:
  1210. typespec_reserved_attr
  1211. ;
  1212. typespec_reserved_nonattr:
  1213. TYPESPEC
  1214. { OBJC_NEED_RAW_IDENTIFIER (1); }
  1215. | structsp_nonattr
  1216. ;
  1217. typespec_reserved_attr:
  1218. structsp_attr
  1219. ;
  1220. typespec_nonreserved_nonattr:
  1221. TYPENAME
  1222. { /* For a typedef name, record the meaning, not the name.
  1223. In case of `foo foo, bar;'. */
  1224. $$ = lookup_name ($1); }
  1225. | typeof '(' expr ')'
  1226. { skip_evaluation--; $$ = TREE_TYPE ($3); }
  1227. | typeof '(' typename ')'
  1228. { skip_evaluation--; $$ = groktypename ($3); }
  1229. ;
  1230. /* typespec_nonreserved_attr does not exist. */
  1231. initdecls:
  1232. initdcl
  1233. | initdecls ',' maybe_resetattrs initdcl
  1234. ;
  1235. notype_initdecls:
  1236. notype_initdcl
  1237. | notype_initdecls ',' maybe_resetattrs notype_initdcl
  1238. ;
  1239. maybeasm:
  1240. /* empty */
  1241. { $$ = NULL_TREE; }
  1242. | ASM_KEYWORD '(' STRING ')'
  1243. { $$ = $3; }
  1244. ;
  1245. initdcl:
  1246. declarator maybeasm maybe_attribute '='
  1247. { $<ttype>$ = start_decl ($1, current_declspecs, 1,
  1248. chainon ($3, all_prefix_attributes));
  1249. start_init ($<ttype>$, $2, global_bindings_p ()); }
  1250. init
  1251. /* Note how the declaration of the variable is in effect while its init is parsed! */
  1252. { finish_init ();
  1253. finish_decl ($<ttype>5, $6, $2);
  1254. if (In_MP_Region && Is_shared_mp_var ($<ttype>5))
  1255. mp_locals[mp_nesting] = chainon (mp_locals[mp_nesting], build_tree_list (NULL, $<ttype>5));
  1256. }
  1257. | declarator maybeasm maybe_attribute
  1258. { tree d = start_decl ($1, current_declspecs, 0,
  1259. chainon ($3, all_prefix_attributes));
  1260. finish_decl (d, NULL_TREE, $2);
  1261. if (In_MP_Region && Is_shared_mp_var (d))
  1262. mp_locals[mp_nesting] = chainon (mp_locals[mp_nesting], build_tree_list (NULL, d));
  1263. }
  1264. ;
  1265. notype_initdcl:
  1266. notype_declarator maybeasm maybe_attribute '='
  1267. { $<ttype>$ = start_decl ($1, current_declspecs, 1,
  1268. chainon ($3, all_prefix_attributes));
  1269. start_init ($<ttype>$, $2, global_bindings_p ()); }
  1270. init
  1271. /* Note how the declaration of the variable is in effect while its init is parsed! */
  1272. { finish_init ();
  1273. finish_decl ($<ttype>5, $6, $2);
  1274. if (In_MP_Region && Is_shared_mp_var ($<ttype>5))
  1275. mp_locals[mp_nesting] = chainon (mp_locals[mp_nesting], build_tree_list (NULL, $<ttype>5));
  1276. }
  1277. | notype_declarator maybeasm maybe_attribute
  1278. { tree d = start_decl ($1, current_declspecs, 0,
  1279. chainon ($3, all_prefix_attributes));
  1280. finish_decl (d, NULL_TREE, $2);
  1281. if (In_MP_Region && Is_shared_mp_var (d))
  1282. mp_locals[mp_nesting] = chainon (mp_locals[mp_nesting], build_tree_list (NULL, d));
  1283. }
  1284. ;
  1285. /* the * rules are dummies to accept the Apollo extended syntax
  1286. so that the header files compile. */
  1287. maybe_attribute:
  1288. /* empty */
  1289. { $$ = NULL_TREE; }
  1290. | attributes
  1291. { $$ = $1; }
  1292. ;
  1293. attributes:
  1294. attribute
  1295. { $$ = $1; }
  1296. | attributes attribute
  1297. { $$ = chainon ($1, $2); }
  1298. ;
  1299. attribute:
  1300. ATTRIBUTE '(' '(' attribute_list ')' ')'
  1301. { $$ = $4; }
  1302. ;
  1303. attribute_list:
  1304. attrib
  1305. { $$ = $1; }
  1306. | attribute_list ',' attrib
  1307. { $$ = chainon ($1, $3); }
  1308. ;
  1309. attrib:
  1310. /* empty */
  1311. { $$ = NULL_TREE; }
  1312. | any_word
  1313. { $$ = build_tree_list ($1, NULL_TREE); }
  1314. | any_word '(' IDENTIFIER ')'
  1315. { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
  1316. | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
  1317. { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
  1318. | any_word '(' exprlist ')'
  1319. { $$ = build_tree_list ($1, $3); }
  1320. ;
  1321. /* This still leaves out most reserved keywords,
  1322. shouldn't we include them? */
  1323. any_word:
  1324. identifier
  1325. | scspec
  1326. | TYPESPEC
  1327. | TYPE_QUAL
  1328. ;
  1329. scspec:
  1330. STATIC
  1331. | SCSPEC
  1332. ;
  1333. /* Initializers. `init' is the entry point. */
  1334. init:
  1335. expr_no_commas
  1336. | '{'
  1337. { really_start_incremental_init (NULL_TREE); }
  1338. initlist_maybe_comma '}'
  1339. { $$ = pop_init_level (0); }
  1340. | error
  1341. { $$ = error_mark_node; }
  1342. ;
  1343. /* `initlist_maybe_comma' is the guts of an initializer in braces. */
  1344. initlist_maybe_comma:
  1345. /* empty */
  1346. { if (pedantic)
  1347. pedwarn ("ISO C forbids empty initializer braces"); }
  1348. | initlist1 maybecomma
  1349. ;
  1350. initlist1:
  1351. initelt
  1352. | initlist1 ',' initelt
  1353. ;
  1354. /* `initelt' is a single element of an initializer.
  1355. It may use braces. */
  1356. initelt:
  1357. designator_list '=' initval
  1358. { if (pedantic && ! flag_isoc99)
  1359. pedwarn ("ISO C89 forbids specifying subobject to initialize"); }
  1360. | designator initval
  1361. { if (pedantic)
  1362. pedwarn ("obsolete use of designated initializer without `='"); }
  1363. | identifier ':'
  1364. { set_init_label ($1);
  1365. if (pedantic)
  1366. pedwarn ("obsolete use of designated initializer with `:'"); }
  1367. initval
  1368. {}
  1369. | initval
  1370. ;
  1371. initval:
  1372. '{'
  1373. { push_init_level (0); }
  1374. initlist_maybe_comma '}'
  1375. { process_init_element (pop_init_level (0)); }
  1376. | expr_no_commas
  1377. { process_init_element ($1); }
  1378. | error
  1379. ;
  1380. designator_list:
  1381. designator
  1382. | designator_list designator
  1383. ;
  1384. designator:
  1385. '.' identifier
  1386. { set_init_label ($2); }
  1387. | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
  1388. { set_init_index ($2, $4);
  1389. if (pedantic)
  1390. pedwarn ("ISO C forbids specifying range of elements to initialize"); }
  1391. | '[' expr_no_commas ']'
  1392. { set_init_index ($2, NULL_TREE); }
  1393. ;
  1394. nested_function:
  1395. declarator
  1396. { if (pedantic)
  1397. pedwarn ("ISO C forbids nested functions");
  1398. push_function_context ();
  1399. if (! start_function (current_declspecs, $1,
  1400. all_prefix_attributes))
  1401. {
  1402. pop_function_context ();
  1403. YYERROR1;
  1404. }
  1405. parsing_iso_function_signature = false; /* Don't warn about nested functions. */
  1406. }
  1407. old_style_parm_decls
  1408. { store_parm_decls (); }
  1409. /* This used to use compstmt_or_error.
  1410. That caused a bug with input `f(g) int g {}',
  1411. where the use of YYERROR1 above caused an error
  1412. which then was handled by compstmt_or_error.
  1413. There followed a repeated execution of that same rule,
  1414. which called YYERROR1 again, and so on. */
  1415. save_filename save_lineno compstmt
  1416. { tree decl = current_function_decl;
  1417. DECL_SOURCE_FILE (decl) = $5;
  1418. DECL_SOURCE_LINE (decl) = $6;
  1419. finish_function (1, 1);
  1420. pop_function_context ();
  1421. add_decl_stmt (decl); }
  1422. ;
  1423. notype_nested_function:
  1424. notype_declarator
  1425. { if (pedantic)
  1426. pedwarn ("ISO C forbids nested functions");
  1427. push_function_context ();
  1428. if (! start_function (current_declspecs, $1,
  1429. all_prefix_attributes))
  1430. {
  1431. pop_function_context ();
  1432. YYERROR1;
  1433. }
  1434. parsing_iso_function_signature = false; /* Don't warn about nested functions. */
  1435. }
  1436. old_style_parm_decls
  1437. { store_parm_decls (); }
  1438. /* This used to use compstmt_or_error.
  1439. That caused a bug with input `f(g) int g {}',
  1440. where the use of YYERROR1 above caused an error
  1441. which then was handled by compstmt_or_error.
  1442. There followed a repeated execution of that same rule,
  1443. which called YYERROR1 again, and so on. */
  1444. save_filename save_lineno compstmt
  1445. { tree decl = current_function_decl;
  1446. DECL_SOURCE_FILE (decl) = $5;
  1447. DECL_SOURCE_LINE (decl) = $6;
  1448. finish_function (1, 1);
  1449. pop_function_context ();
  1450. add_decl_stmt (decl); }
  1451. ;
  1452. /* Any kind of declarator (thus, all declarators allowed
  1453. after an explicit typespec). */
  1454. declarator:
  1455. after_type_declarator
  1456. | notype_declarator
  1457. ;
  1458. /* A declarator that is allowed only after an explicit typespec. */
  1459. after_type_declarator:
  1460. '(' maybe_attribute after_type_declarator ')'
  1461. { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
  1462. | after_type_declarator '(' parmlist_or_identifiers %prec '.'
  1463. { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1464. /* | after_type_declarator '(' error ')' %prec '.'
  1465. { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1466. poplevel (0, 0, 0); } */
  1467. | after_type_declarator array_declarator %prec '.'
  1468. { $$ = set_array_declarator_type ($2, $1, 0); }
  1469. | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY
  1470. { $$ = make_pointer_declarator ($2, $3); }
  1471. | TYPENAME
  1472. ;
  1473. /* Kinds of declarator that can appear in a parameter list
  1474. in addition to notype_declarator. This is like after_type_declarator
  1475. but does not allow a typedef name in parentheses as an identifier
  1476. (because it would conflict with a function with that typedef as arg). */
  1477. parm_declarator:
  1478. parm_declarator_starttypename
  1479. | parm_declarator_nostarttypename
  1480. ;
  1481. parm_declarator_starttypename:
  1482. parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
  1483. { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1484. /* | parm_declarator_starttypename '(' error ')' %prec '.'
  1485. { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1486. poplevel (0, 0, 0); } */
  1487. | parm_declarator_starttypename array_declarator %prec '.'
  1488. { $$ = set_array_declarator_type ($2, $1, 0); }
  1489. | TYPENAME
  1490. ;
  1491. parm_declarator_nostarttypename:
  1492. parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
  1493. { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1494. /* | parm_declarator_nostarttypename '(' error ')' %prec '.'
  1495. { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1496. poplevel (0, 0, 0); } */
  1497. | parm_declarator_nostarttypename array_declarator %prec '.'
  1498. { $$ = set_array_declarator_type ($2, $1, 0); }
  1499. | '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY
  1500. { $$ = make_pointer_declarator ($2, $3); }
  1501. | '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY
  1502. { $$ = make_pointer_declarator ($2, $3); }
  1503. | '(' maybe_attribute parm_declarator_nostarttypename ')'
  1504. { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
  1505. ;
  1506. /* A declarator allowed whether or not there has been
  1507. an explicit typespec. These cannot redeclare a typedef-name. */
  1508. notype_declarator:
  1509. notype_declarator '(' parmlist_or_identifiers %prec '.'
  1510. { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1511. /* | notype_declarator '(' error ')' %prec '.'
  1512. { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1513. poplevel (0, 0, 0); } */
  1514. | '(' maybe_attribute notype_declarator ')'
  1515. { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
  1516. | '*' maybe_type_quals_attrs notype_declarator %prec UNARY
  1517. { $$ = make_pointer_declarator ($2, $3); }
  1518. | notype_declarator array_declarator %prec '.'
  1519. { $$ = set_array_declarator_type ($2, $1, 0); }
  1520. | IDENTIFIER
  1521. ;
  1522. struct_head:
  1523. STRUCT
  1524. { $$ = NULL_TREE; }
  1525. | STRUCT attributes
  1526. { $$ = $2; }
  1527. ;
  1528. union_head:
  1529. UNION
  1530. { $$ = NULL_TREE; }
  1531. | UNION attributes
  1532. { $$ = $2; }
  1533. ;
  1534. enum_head:
  1535. ENUM
  1536. { $$ = NULL_TREE; }
  1537. | ENUM attributes
  1538. { $$ = $2; }
  1539. ;
  1540. /* structsp_attr: struct/union/enum specifiers that either
  1541. end with attributes, or are such that any following attributes would
  1542. be parsed as part of the struct/union/enum specifier.
  1543. structsp_nonattr: other struct/union/enum specifiers. */
  1544. structsp_attr:
  1545. struct_head identifier '{'
  1546. { $<ttype>$ = start_struct (RECORD_TYPE, $2);
  1547. /* Start scope of tag before parsing components. */
  1548. }
  1549. component_decl_list '}' maybe_attribute
  1550. { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
  1551. | struct_head '{' component_decl_list '}' maybe_attribute
  1552. { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
  1553. $3, chainon ($1, $5));
  1554. }
  1555. | union_head identifier '{'
  1556. { $<ttype>$ = start_struct (UNION_TYPE, $2); }
  1557. component_decl_list '}' maybe_attribute
  1558. { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
  1559. | union_head '{' component_decl_list '}' maybe_attribute
  1560. { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
  1561. $3, chainon ($1, $5));
  1562. }
  1563. | enum_head identifier '{'
  1564. { $<ttype>$ = start_enum ($2); }
  1565. enumlist maybecomma_warn '}' maybe_attribute
  1566. { $$ = finish_enum ($<ttype>4, nreverse ($5),
  1567. chainon ($1, $8)); }
  1568. | enum_head '{'
  1569. { $<ttype>$ = start_enum (NULL_TREE); }
  1570. enumlist maybecomma_warn '}' maybe_attribute
  1571. { $$ = finish_enum ($<ttype>3, nreverse ($4),
  1572. chainon ($1, $7)); }
  1573. ;
  1574. structsp_nonattr:
  1575. struct_head identifier
  1576. { $$ = xref_tag (RECORD_TYPE, $2); }
  1577. | union_head identifier
  1578. { $$ = xref_tag (UNION_TYPE, $2); }
  1579. | enum_head identifier
  1580. { $$ = xref_tag (ENUMERAL_TYPE, $2);
  1581. /* In ISO C, enumerated types can be referred to
  1582. only if already defined. */
  1583. if (pedantic && !COMPLETE_TYPE_P ($$))
  1584. pedwarn ("ISO C forbids forward references to `enum' types"); }
  1585. ;
  1586. maybecomma:
  1587. /* empty */
  1588. | ','
  1589. ;
  1590. maybecomma_warn:
  1591. /* empty */
  1592. | ','
  1593. { if (pedantic && ! flag_isoc99)
  1594. pedwarn ("comma at end of enumerator list"); }
  1595. ;
  1596. component_decl_list:
  1597. component_decl_list2
  1598. { $$ = $1; }
  1599. | component_decl_list2 component_decl
  1600. { $$ = chainon ($1, $2);
  1601. pedwarn ("no semicolon at end of struct or union"); }
  1602. ;
  1603. component_decl_list2: /* empty */
  1604. { $$ = NULL_TREE; }
  1605. | component_decl_list2 component_decl ';'
  1606. { $$ = chainon ($1, $2); }
  1607. | component_decl_list2 ';'
  1608. { if (pedantic)
  1609. pedwarn ("extra semicolon in struct or union specified"); }
  1610. ;
  1611. component_decl:
  1612. declspecs_nosc_ts setspecs components
  1613. { $$ = $3;
  1614. POP_DECLSPEC_STACK; }
  1615. | declspecs_nosc_ts setspecs save_filename save_lineno
  1616. {
  1617. /* Support for unnamed structs or unions as members of
  1618. structs or unions (which is [a] useful and [b] supports
  1619. MS P-SDK). */
  1620. if (pedantic)
  1621. pedwarn ("ISO C doesn't support unnamed structs/unions");
  1622. $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
  1623. POP_DECLSPEC_STACK; }
  1624. | declspecs_nosc_nots setspecs components_notype
  1625. { $$ = $3;
  1626. POP_DECLSPEC_STACK; }
  1627. | declspecs_nosc_nots
  1628. { if (pedantic)
  1629. pedwarn ("ISO C forbids member declarations with no members");
  1630. shadow_tag($1);
  1631. $$ = NULL_TREE; }
  1632. | error
  1633. { $$ = NULL_TREE; }
  1634. | extension component_decl
  1635. { $$ = $2;
  1636. RESTORE_EXT_FLAGS ($1); }
  1637. ;
  1638. components:
  1639. component_declarator
  1640. | components ',' maybe_resetattrs component_declarator
  1641. { $$ = chainon ($1, $4); }
  1642. ;
  1643. components_notype:
  1644. component_notype_declarator
  1645. | components_notype ',' maybe_resetattrs component_notype_declarator
  1646. { $$ = chainon ($1, $4); }
  1647. ;
  1648. component_declarator:
  1649. save_filename save_lineno declarator maybe_attribute
  1650. { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
  1651. decl_attributes (&$$, chainon ($4, all_prefix_attributes), 0); }
  1652. | save_filename save_lineno
  1653. declarator ':' expr_no_commas maybe_attribute
  1654. { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
  1655. decl_attributes (&$$, chainon ($6, all_prefix_attributes), 0); }
  1656. | save_filename save_lineno ':' expr_no_commas maybe_attribute
  1657. { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
  1658. decl_attributes (&$$, chainon ($5, all_prefix_attributes), 0); }
  1659. ;
  1660. component_notype_declarator:
  1661. save_filename save_lineno notype_declarator maybe_attribute
  1662. { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
  1663. decl_attributes (&$$, chainon ($4, all_prefix_attributes), 0); }
  1664. | save_filename save_lineno
  1665. notype_declarator ':' expr_no_commas maybe_attribute
  1666. { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
  1667. decl_attributes (&$$, chainon ($6, all_prefix_attributes), 0); }
  1668. | save_filename save_lineno ':' expr_no_commas maybe_attribute
  1669. { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
  1670. decl_attributes (&$$, chainon ($5, all_prefix_attributes), 0); }
  1671. ;
  1672. /* We chain the enumerators in reverse order.
  1673. They are put in forward order where enumlist is used.
  1674. (The order used to be significant, but no longer is so.
  1675. However, we still maintain the order, just to be clean.) */
  1676. enumlist:
  1677. enumerator
  1678. | enumlist ',' enumerator
  1679. { if ($1 == error_mark_node)
  1680. $$ = $1;
  1681. else
  1682. $$ = chainon ($3, $1); }
  1683. | error
  1684. { $$ = error_mark_node; }
  1685. ;
  1686. enumerator:
  1687. identifier
  1688. { $$ = build_enumerator ($1, NULL_TREE); }
  1689. | identifier '=' expr_no_commas
  1690. { $$ = build_enumerator ($1, $3); }
  1691. ;
  1692. typename:
  1693. declspecs_nosc
  1694. { pending_xref_error ();
  1695. $<ttype>$ = $1; }
  1696. absdcl
  1697. { $$ = build_tree_list ($<ttype>2, $3); }
  1698. ;
  1699. absdcl: /* an absolute declarator */
  1700. /* empty */
  1701. { $$ = NULL_TREE; }
  1702. | absdcl1
  1703. ;
  1704. absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
  1705. /* empty */
  1706. { $$ = build_tree_list (build_tree_list (current_declspecs,
  1707. NULL_TREE),
  1708. all_prefix_attributes); }
  1709. | absdcl1
  1710. { $$ = build_tree_list (build_tree_list (current_declspecs,
  1711. $1),
  1712. all_prefix_attributes); }
  1713. | absdcl1_noea attributes
  1714. { $$ = build_tree_list (build_tree_list (current_declspecs,
  1715. $1),
  1716. chainon ($2, all_prefix_attributes)); }
  1717. ;
  1718. absdcl1: /* a nonempty absolute declarator */
  1719. absdcl1_ea
  1720. | absdcl1_noea
  1721. ;
  1722. absdcl1_noea:
  1723. direct_absdcl1
  1724. | '*' maybe_type_quals_attrs absdcl1_noea
  1725. { $$ = make_pointer_declarator ($2, $3); }
  1726. ;
  1727. absdcl1_ea:
  1728. '*' maybe_type_quals_attrs
  1729. { $$ = make_pointer_declarator ($2, NULL_TREE); }
  1730. | '*' maybe_type_quals_attrs absdcl1_ea
  1731. { $$ = make_pointer_declarator ($2, $3); }
  1732. ;
  1733. direct_absdcl1:
  1734. '(' maybe_attribute absdcl1 ')'
  1735. { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
  1736. | direct_absdcl1 '(' parmlist
  1737. { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1738. | direct_absdcl1 array_declarator
  1739. { $$ = set_array_declarator_type ($2, $1, 1); }
  1740. | '(' parmlist
  1741. { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
  1742. | array_declarator
  1743. { $$ = set_array_declarator_type ($1, NULL_TREE, 1); }
  1744. ;
  1745. /* The [...] part of a declarator for an array type. */
  1746. array_declarator:
  1747. '[' maybe_type_quals_attrs expr ']'
  1748. { $$ = build_array_declarator ($3, $2, 0, 0); }
  1749. | '[' maybe_type_quals_attrs ']'
  1750. { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
  1751. | '[' maybe_type_quals_attrs '*' ']'
  1752. { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
  1753. | '[' STATIC maybe_type_quals_attrs expr ']'
  1754. { $$ = build_array_declarator ($4, $3, 1, 0); }
  1755. /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
  1756. | '[' declspecs_nosc_nots STATIC expr ']'
  1757. { $$ = build_array_declarator ($4, $2, 1, 0); }
  1758. ;
  1759. /* A nonempty series of declarations and statements (possibly followed by
  1760. some labels) that can form the body of a compound statement.
  1761. NOTE: we don't allow labels on declarations; this might seem like a
  1762. natural extension, but there would be a conflict between attributes
  1763. on the label and prefix attributes on the declaration. */
  1764. stmts_and_decls:
  1765. lineno_stmt_decl_or_labels_ending_stmt
  1766. | lineno_stmt_decl_or_labels_ending_decl
  1767. | lineno_stmt_decl_or_labels_ending_label
  1768. {
  1769. pedwarn ("deprecated use of label at end of compound statement");
  1770. }
  1771. | lineno_stmt_decl_or_labels_ending_error
  1772. ;
  1773. lineno_stmt_decl_or_labels_ending_stmt:
  1774. lineno_stmt
  1775. | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
  1776. | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
  1777. | lineno_stmt_decl_or_labels_ending_label lineno_stmt
  1778. | lineno_stmt_decl_or_labels_ending_error lineno_stmt
  1779. ;
  1780. lineno_stmt_decl_or_labels_ending_decl:
  1781. lineno_decl
  1782. | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
  1783. {
  1784. if ((pedantic && !flag_isoc99)
  1785. || warn_declaration_after_statement)
  1786. pedwarn_c90 ("ISO C90 forbids mixed declarations and code");
  1787. }
  1788. | lineno_stmt_decl_or_labels_ending_decl lineno_decl
  1789. | lineno_stmt_decl_or_labels_ending_error lineno_decl
  1790. ;
  1791. lineno_stmt_decl_or_labels_ending_label:
  1792. lineno_label
  1793. | lineno_stmt_decl_or_labels_ending_stmt lineno_label
  1794. | lineno_stmt_decl_or_labels_ending_decl lineno_label
  1795. | lineno_stmt_decl_or_labels_ending_label lineno_label
  1796. | lineno_stmt_decl_or_labels_ending_error lineno_label
  1797. ;
  1798. lineno_stmt_decl_or_labels_ending_error:
  1799. errstmt
  1800. | lineno_stmt_decl_or_labels errstmt
  1801. ;
  1802. lineno_stmt_decl_or_labels:
  1803. lineno_stmt_decl_or_labels_ending_stmt
  1804. | lineno_stmt_decl_or_labels_ending_decl
  1805. | lineno_stmt_decl_or_labels_ending_label
  1806. | lineno_stmt_decl_or_labels_ending_error
  1807. ;
  1808. errstmt: error ';'
  1809. ;
  1810. pushlevel: /* empty */
  1811. { pushlevel (0);
  1812. clear_last_expr ();
  1813. add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
  1814. }
  1815. ;
  1816. poplevel: /* empty */
  1817. { $$ = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); }
  1818. ;
  1819. /* Start and end blocks created for the new scopes of C99. */
  1820. c99_block_start: /* empty */
  1821. { if (flag_isoc99)
  1822. {
  1823. $$ = c_begin_compound_stmt ();
  1824. pushlevel (0);
  1825. clear_last_expr ();
  1826. add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
  1827. }
  1828. else
  1829. $$ = NULL_TREE;
  1830. }
  1831. ;
  1832. /* Productions using c99_block_start and c99_block_end will need to do what's
  1833. in compstmt: RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); $$ = $2; where
  1834. $1 is the value of c99_block_start and $2 of c99_block_end. */
  1835. c99_block_end: /* empty */
  1836. { if (flag_isoc99)
  1837. {
  1838. tree scope_stmt = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
  1839. $$ = poplevel (kept_level_p (), 0, 0);
  1840. SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmt))
  1841. = SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmt))
  1842. = $$;
  1843. }
  1844. else
  1845. $$ = NULL_TREE; }
  1846. ;
  1847. /* Read zero or more forward-declarations for labels
  1848. that nested functions can jump to. */
  1849. maybe_label_decls:
  1850. /* empty */
  1851. | label_decls
  1852. { if (pedantic)
  1853. pedwarn ("ISO C forbids label declarations"); }
  1854. ;
  1855. label_decls:
  1856. label_decl
  1857. | label_decls label_decl
  1858. ;
  1859. label_decl:
  1860. LABEL identifiers_or_typenames ';'
  1861. { tree link;
  1862. for (link = $2; link; link = TREE_CHAIN (link))
  1863. {
  1864. tree label = shadow_label (TREE_VALUE (link));
  1865. C_DECLARED_LABEL_FLAG (label) = 1;
  1866. add_decl_stmt (label);
  1867. }
  1868. }
  1869. ;
  1870. /* This is the body of a function definition.
  1871. It causes syntax errors to ignore to the next openbrace. */
  1872. compstmt_or_error:
  1873. compstmt
  1874. {}
  1875. | error compstmt
  1876. ;
  1877. compstmt_start: '{' { compstmt_count++;
  1878. $$ = c_begin_compound_stmt (); }
  1879. ;
  1880. compstmt_nostart: '}'
  1881. { $$ = convert (void_type_node, integer_zero_node); }
  1882. | pushlevel maybe_label_decls compstmt_contents_nonempty '}' poplevel
  1883. { $$ = poplevel (kept_level_p (), 1, 0);
  1884. SCOPE_STMT_BLOCK (TREE_PURPOSE ($5))
  1885. = SCOPE_STMT_BLOCK (TREE_VALUE ($5))
  1886. = $$; }
  1887. ;
  1888. compstmt_contents_nonempty:
  1889. stmts_and_decls
  1890. | error
  1891. ;
  1892. compstmt_primary_start:
  1893. '(' '{'
  1894. { if (current_function_decl == 0)
  1895. {
  1896. error ("braced-group within expression allowed only inside a function");
  1897. YYERROR;
  1898. }
  1899. /* We must force a BLOCK for this level
  1900. so that, if it is not expanded later,
  1901. there is a way to turn off the entire subtree of blocks
  1902. that are contained in it. */
  1903. keep_next_level ();
  1904. push_label_level ();
  1905. compstmt_count++;
  1906. $$ = add_stmt (build_stmt (COMPOUND_STMT, last_tree));
  1907. }
  1908. ;
  1909. compstmt: compstmt_start compstmt_nostart
  1910. { RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
  1911. last_expr_type = NULL_TREE;
  1912. $$ = $1; }
  1913. ;
  1914. /* Value is number of statements counted as of the closeparen. */
  1915. simple_if:
  1916. if_prefix c99_block_lineno_labeled_stmt
  1917. { c_finish_then (); }
  1918. /* Make sure c_expand_end_cond is run once
  1919. for each call to c_expand_start_cond.
  1920. Otherwise a crash is likely. */
  1921. | if_prefix error
  1922. ;
  1923. if_prefix:
  1924. /* We must build the IF_STMT node before parsing its
  1925. condition so that STMT_LINENO refers to the line
  1926. containing the "if", and not the line containing
  1927. the close-parenthesis.
  1928. c_begin_if_stmt returns the IF_STMT node, which
  1929. we later pass to c_expand_start_cond to fill
  1930. in the condition and other tidbits. */
  1931. IF
  1932. { $<ttype>$ = c_begin_if_stmt (); }
  1933. '(' expr ')'
  1934. { c_expand_start_cond (c_common_truthvalue_conversion ($4),
  1935. compstmt_count,$<ttype>2);
  1936. $<itype>$ = stmt_count;
  1937. if_stmt_file = $<filename>-2;
  1938. if_stmt_line = $<lineno>-1; }
  1939. ;
  1940. /* This is a subroutine of stmt.
  1941. It is used twice, once for valid DO statements
  1942. and once for catching errors in parsing the end test. */
  1943. do_stmt_start:
  1944. DO
  1945. { stmt_count++;
  1946. compstmt_count++;
  1947. $<ttype>$
  1948. = add_stmt (build_stmt (DO_STMT, NULL_TREE,
  1949. NULL_TREE));
  1950. /* In the event that a parse error prevents
  1951. parsing the complete do-statement, set the
  1952. condition now. Otherwise, we can get crashes at
  1953. RTL-generation time. */
  1954. DO_COND ($<ttype>$) = error_mark_node; }
  1955. c99_block_lineno_labeled_stmt WHILE
  1956. { $$ = $<ttype>2;
  1957. RECHAIN_STMTS ($$, DO_BODY ($$)); }
  1958. ;
  1959. /* The forced readahead in here is because we might be at the end of a
  1960. line, and the line and file won't be bumped until yylex absorbs the
  1961. first token on the next line. */
  1962. save_filename:
  1963. { if (yychar == YYEMPTY)
  1964. yychar = YYLEX;
  1965. $$ = input_filename; }
  1966. ;
  1967. save_lineno:
  1968. { if (yychar == YYEMPTY)
  1969. yychar = YYLEX;
  1970. $$ = lineno; }
  1971. ;
  1972. lineno_labeled_stmt:
  1973. lineno_stmt
  1974. | lineno_label lineno_labeled_stmt
  1975. ;
  1976. /* Like lineno_labeled_stmt, but a block in C99. */
  1977. c99_block_lineno_labeled_stmt:
  1978. c99_block_start lineno_labeled_stmt c99_block_end
  1979. { if (flag_isoc99)
  1980. RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); }
  1981. ;
  1982. lineno_stmt:
  1983. save_filename save_lineno stmt
  1984. { if ($3)
  1985. {
  1986. STMT_LINENO ($3) = $2;
  1987. /* ??? We currently have no way of recording
  1988. the filename for a statement. This probably
  1989. matters little in practice at the moment,
  1990. but I suspect that problems will occur when
  1991. doing inlining at the tree level. */
  1992. }
  1993. }
  1994. ;
  1995. lineno_label:
  1996. save_filename save_lineno label
  1997. { if ($3)
  1998. {
  1999. STMT_LINENO ($3) = $2;
  2000. }
  2001. }
  2002. ;
  2003. select_or_iter_stmt:
  2004. simple_if ELSE
  2005. { c_expand_start_else ();
  2006. $<itype>1 = stmt_count; }
  2007. c99_block_lineno_labeled_stmt
  2008. { c_finish_else ();
  2009. c_expand_end_cond ();
  2010. if (extra_warnings && stmt_count == $<itype>1)
  2011. warning ("empty body in an else-statement"); }
  2012. | simple_if %prec IF
  2013. { c_expand_end_cond ();
  2014. /* This warning is here instead of in simple_if, because we
  2015. do not want a warning if an empty if is followed by an
  2016. else statement. Increment stmt_count so we don't
  2017. give a second error if this is a nested `if'. */
  2018. if (extra_warnings && stmt_count++ == $<itype>1)
  2019. warning_with_file_and_line (if_stmt_file, if_stmt_line,
  2020. "empty body in an if-statement"); }
  2021. /* Make sure c_expand_end_cond is run once
  2022. for each call to c_expand_start_cond.
  2023. Otherwise a crash is likely. */
  2024. | simple_if ELSE error
  2025. { c_expand_end_cond (); }
  2026. /* We must build the WHILE_STMT node before parsing its
  2027. condition so that STMT_LINENO refers to the line
  2028. containing the "while", and not the line containing
  2029. the close-parenthesis.
  2030. c_begin_while_stmt returns the WHILE_STMT node, which
  2031. we later pass to c_finish_while_stmt_cond to fill
  2032. in the condition and other tidbits. */
  2033. | WHILE
  2034. { stmt_count++;
  2035. $<ttype>$ = c_begin_while_stmt (); }
  2036. '(' expr ')'
  2037. { $4 = c_common_truthvalue_conversion ($4);
  2038. c_finish_while_stmt_cond
  2039. (c_common_truthvalue_conversion ($4), $<ttype>2);
  2040. $<ttype>$ = add_stmt ($<ttype>2); }
  2041. c99_block_lineno_labeled_stmt
  2042. { RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
  2043. | do_stmt_start
  2044. '(' expr ')' ';'
  2045. { DO_COND ($1) = c_common_truthvalue_conversion ($3); }
  2046. | do_stmt_start error
  2047. { }
  2048. | FOR
  2049. { $<ttype>$ = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
  2050. NULL_TREE, NULL_TREE);
  2051. add_stmt ($<ttype>$); }
  2052. '(' for_init_stmt
  2053. { stmt_count++;
  2054. RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
  2055. xexpr ';'
  2056. { if ($6)
  2057. FOR_COND ($<ttype>2)
  2058. = c_common_truthvalue_conversion ($6); }
  2059. xexpr ')'
  2060. { FOR_EXPR ($<ttype>2) = $9; }
  2061. c99_block_lineno_labeled_stmt
  2062. { RECHAIN_STMTS ($<ttype>2, FOR_BODY ($<ttype>2)); }
  2063. | SWITCH '(' expr ')'
  2064. { stmt_count++;
  2065. $<ttype>$ = c_start_case ($3); }
  2066. c99_block_lineno_labeled_stmt
  2067. { c_finish_case (); }
  2068. ;
  2069. for_init_stmt:
  2070. xexpr ';'
  2071. { add_stmt (build_stmt (EXPR_STMT, $1)); }
  2072. | decl
  2073. { check_for_loop_decls (); }
  2074. ;
  2075. openmp_construct:
  2076. parallel_construct
  2077. | for_construct
  2078. | sections_construct
  2079. | single_construct
  2080. | parallel_for_construct
  2081. | parallel_sections_construct
  2082. | master_construct
  2083. | critical_construct
  2084. | atomic_construct
  2085. | ordered_construct
  2086. | sl2_sections_construct
  2087. ;
  2088. sl2_sections_construct:
  2089. PRAGMA_SL2 SL2_SECTIONS '\n'
  2090. {
  2091. #ifdef TARG_SL
  2092. add_stmt(build_omp_stmt(sl2_sections_cons_b, NULL));
  2093. #endif
  2094. }
  2095. sl2_section_scope
  2096. {
  2097. #ifdef TARG_SL
  2098. add_stmt(build_omp_stmt(sl2_sections_cons_e, NULL)); $$=NULL;
  2099. #endif
  2100. }
  2101. | PRAGMA_SL2 SL2_MINOR_SECTIONS '\n'
  2102. {
  2103. #ifdef TARG_SL
  2104. add_stmt(build_omp_stmt(sl2_minor_sections_cons_b, NULL));
  2105. #endif
  2106. }
  2107. sl2_section_scope
  2108. {
  2109. #ifdef TARG_SL
  2110. add_stmt(build_omp_stmt(sl2_sections_cons_e, NULL)); $$=NULL;
  2111. #endif
  2112. }
  2113. ;
  2114. sl2_section_scope:
  2115. '{'
  2116. sl2_maybe_section_sequence
  2117. '}'
  2118. ;
  2119. sl2_maybe_section_sequence:
  2120. sl2_section_sequence
  2121. | sl2_maybe_structured_block
  2122. | sl2_maybe_structured_block sl2_section_sequence
  2123. ;
  2124. sl2_maybe_structured_block:
  2125. structured_block
  2126. ;
  2127. sl2_section_sequence:
  2128. sl2_section_construct
  2129. | sl2_section_sequence sl2_section_construct
  2130. ;
  2131. sl2_section_construct:
  2132. PRAGMA_SL2 SL2_SECTION '\n'
  2133. {
  2134. #ifdef TARG_SL
  2135. if (!In_MP_Section)
  2136. add_stmt (build_omp_stmt (sl2_section_cons_b, NULL));
  2137. else
  2138. In_MP_Section = false;
  2139. #endif
  2140. }
  2141. structured_block
  2142. {
  2143. #ifdef TARG_SL
  2144. add_stmt (build_omp_stmt (sl2_section_cons_e, NULL));
  2145. #endif
  2146. }
  2147. | PRAGMA_SL2 SL2_MINOR_SECTION '\n'
  2148. {
  2149. #ifdef TARG_SL
  2150. if (!In_MP_Section)
  2151. add_stmt (build_omp_stmt (sl2_minor_section_cons_b, NULL));
  2152. else
  2153. In_MP_Section = false;
  2154. #endif
  2155. }
  2156. structured_block
  2157. {
  2158. #ifdef TARG_SL
  2159. add_stmt (build_omp_stmt (sl2_minor_section_cons_e, NULL));
  2160. #endif
  2161. }
  2162. ;
  2163. pragma_directives:
  2164. barrier_directive
  2165. | flush_directive
  2166. | threadprivate_directive
  2167. {}
  2168. | options_directive
  2169. | exec_freq_directive
  2170. | unroll_directive
  2171. ;
  2172. options_directive:
  2173. PRAGMA_OPTIONS STRING '\n'
  2174. { add_stmt (build_omp_stmt (options_dir, $2)); $$ = NULL; }
  2175. ;
  2176. /* Ignore directive in global scope */
  2177. exec_freq_directive_ignore:
  2178. PRAGMA_EXEC_FREQ freq_hint_ignore IDENTIFIER '\n'
  2179. { $$ = NULL; }
  2180. ;
  2181. freq_hint_ignore:
  2182. FREQ_NEVER | FREQ_INIT | FREQ_FREQUENT
  2183. ;
  2184. exec_freq_directive:
  2185. PRAGMA_EXEC_FREQ freq_hint '\n'
  2186. { add_stmt (build_omp_stmt (exec_freq_dir, $2)); $$ = NULL; }
  2187. ;
  2188. freq_hint:
  2189. FREQ_NEVER { $$ = build_string (6, "never"); }
  2190. | FREQ_INIT { $$ = build_string (5, "init"); }
  2191. | FREQ_FREQUENT { $$ = build_string (9, "frequent"); }
  2192. ;
  2193. unroll_directive:
  2194. PRAGMA_UNROLL '\n'
  2195. { add_stmt (build_omp_stmt (unroll_dir, NULL)); $$ = NULL; }
  2196. | PRAGMA_UNROLL CONSTANT '\n'
  2197. { add_stmt (build_omp_stmt (unroll_dir, $2)); $$ = NULL; }
  2198. ;
  2199. structured_block:
  2200. stmt
  2201. ;
  2202. parallel_construct:
  2203. parallel_directive
  2204. {
  2205. $<ttype>$ = add_stmt (build_omp_stmt (parallel_dir_b, $1));
  2206. In_MP_Region = true;
  2207. mp_nesting++;
  2208. if (mp_nesting == MAX_MP_NESTING)
  2209. {
  2210. // will see
  2211. printf ("MP nesting > %d not supported\n", MAX_MP_NESTING-1);
  2212. abort();
  2213. }
  2214. mp_locals[mp_nesting] = NULL;
  2215. }
  2216. structured_block
  2217. {
  2218. add_stmt (build_omp_stmt (parallel_dir_e, NULL));
  2219. $$=NULL;
  2220. In_MP_Region = false;
  2221. if (mp_locals[mp_nesting])
  2222. {
  2223. $<ttype>2->omp.omp_clause_list =
  2224. chain_parallel_list_on ($<ttype>2->omp.omp_clause_list,
  2225. build_parallel_clause_list (mp_locals[mp_nesting],
  2226. p_private, 0, 0));
  2227. }
  2228. mp_locals[mp_nesting] = NULL;
  2229. mp_nesting--;
  2230. }
  2231. ;
  2232. parallel_directive:
  2233. PRAGMA_OMP PARALLEL '\n'
  2234. { $$ = NULL; }
  2235. | PRAGMA_OMP PARALLEL parallel_clause_list '\n'
  2236. { $$ = $3; }
  2237. ;
  2238. parallel_clause_list:
  2239. parallel_clause
  2240. { $$ = $1; }
  2241. | parallel_clause_list parallel_clause
  2242. { $$ = chain_parallel_list_on ($1, $2); }
  2243. ;
  2244. parallel_clause:
  2245. IF '(' expr_no_commas ')'
  2246. { $$ = build_parallel_clause_list($3, p_if, 0, 0); }
  2247. | NUM_THREADS '(' expr_no_commas ')'
  2248. { $$ = build_parallel_clause_list($3, p_num_threads, 0, 0); }
  2249. | PRIVATE '(' variable_list ')'
  2250. { $$ = build_parallel_clause_list($3, p_private, 0, 0); }
  2251. | FIRSTPRIVATE '(' variable_list ')'
  2252. { $$ = build_parallel_clause_list($3, p_firstprivate, 0, 0); }
  2253. | SHARED '(' variable_list ')'
  2254. { $$ = build_parallel_clause_list($3, p_shared, 0, 0); }
  2255. | DEFAULT '(' SHARED ')'
  2256. { $$ = build_parallel_clause_list(NULL, p_default, default_shared, 0); }
  2257. | DEFAULT '(' NONE ')'
  2258. { $$ = build_parallel_clause_list(NULL, p_default, default_none, 0); }
  2259. | REDUCTION '(' reduction_operator ':' variable_list ')'
  2260. { $$ = build_parallel_clause_list($5, p_reduction, 0, $3); }
  2261. | COPYIN '(' variable_list ')'
  2262. { $$ = build_parallel_clause_list($3, p_copyin, 0, 0); }
  2263. ;
  2264. for_construct:
  2265. for_directive
  2266. {
  2267. add_stmt (build_omp_stmt (for_dir_b, $1));
  2268. $<ttype>$ = NULL;
  2269. }
  2270. iteration_statement
  2271. { add_stmt (build_omp_stmt (for_dir_e, NULL)); $$ = NULL; }
  2272. ;
  2273. /* taken from 'stmt' */
  2274. iteration_statement:
  2275. FOR
  2276. { $<ttype>$ = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
  2277. NULL_TREE, NULL_TREE);
  2278. TREE_ADDRESSABLE ($<ttype>$) = 1; // generate do-loop
  2279. add_stmt ($<ttype>$); }
  2280. '(' for_init_stmt
  2281. { stmt_count++;
  2282. RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
  2283. xexpr ';'
  2284. { if ($6)
  2285. FOR_COND ($<ttype>2)
  2286. = c_common_truthvalue_conversion ($6); }
  2287. xexpr ')'
  2288. { FOR_EXPR ($<ttype>2) = $9; }
  2289. c99_block_lineno_labeled_stmt
  2290. { RECHAIN_STMTS ($<ttype>2, FOR_BODY ($<ttype>2)); }
  2291. ;
  2292. for_directive:
  2293. PRAGMA_OMP FOR '\n'
  2294. { $$ = NULL; }
  2295. | PRAGMA_OMP FOR for_clause_list '\n'
  2296. { $$ = $3; }
  2297. ;
  2298. for_clause_list:
  2299. for_clause
  2300. { $$ = $1; }
  2301. | for_clause_list for_clause
  2302. { $$ = chain_for_list_on ($1, $2); }
  2303. ;
  2304. for_clause:
  2305. PRIVATE '(' variable_list ')'
  2306. { $$ = build_for_clause_list($3, f_private, 0, 0); }
  2307. | FIRSTPRIVATE '(' variable_list ')'
  2308. { $$ = build_for_clause_list($3, f_firstprivate, 0, 0); }
  2309. | LASTPRIVATE '(' variable_list ')'
  2310. { $$ = build_for_clause_list($3, f_lastprivate, 0, 0); }
  2311. | REDUCTION '(' reduction_operator ':' variable_list ')'
  2312. { $$ = build_for_clause_list($5, f_reduction, 0, $3); }
  2313. | SCHEDULE '(' schedule_kind ')'
  2314. { $$ = build_for_clause_list(NULL, f_schedule_1, $3, 0); }
  2315. | SCHEDULE '(' schedule_kind ',' expr_no_commas ')'
  2316. { $$ = build_for_clause_list($5, f_schedule_2, $3, 0); }
  2317. | ORDERED
  2318. { $$ = build_for_clause_list(NULL, f_ordered, 0, 0); }
  2319. | NOWAIT
  2320. { $$ = build_for_clause_list(NULL, f_nowait, 0, 0); }
  2321. ;
  2322. schedule_kind:
  2323. STATIC
  2324. {
  2325. if (strcmp (IDENTIFIER_POINTER ($1), "static"))
  2326. error ("'%s' is not a valid schedule kind\n", IDENTIFIER_POINTER ($1));
  2327. else
  2328. $$=SK_STATIC; }
  2329. | DYNAMIC
  2330. { $$=SK_DYNAMIC; }
  2331. | GUIDED
  2332. { $$=SK_GUIDED; }
  2333. | RUNTIME
  2334. { $$=SK_RUNTIME; }
  2335. ;
  2336. sections_construct:
  2337. sections_directive
  2338. {
  2339. add_stmt (build_omp_stmt (sections_cons_b, $1));
  2340. $<ttype>$ = NULL;
  2341. }
  2342. section_scope
  2343. { add_stmt (build_omp_stmt (sections_cons_e, NULL)); $$ = NULL; }
  2344. ;
  2345. sections_directive:
  2346. PRAGMA_OMP SECTIONS '\n'
  2347. { $$ = NULL; }
  2348. | PRAGMA_OMP SECTIONS sections_clause_list '\n'
  2349. { $$ = $3; }
  2350. ;
  2351. sections_clause_list:
  2352. sections_clause
  2353. { $$ = $1; }
  2354. | sections_clause_list sections_clause
  2355. { $$ = chain_sections_list_on ($1, $2); }
  2356. ;
  2357. sections_clause:
  2358. PRIVATE '(' variable_list ')'
  2359. { $$ = build_sections_clause_list($3, sections_private, 0); }
  2360. | FIRSTPRIVATE '(' variable_list ')'
  2361. { $$ = build_sections_clause_list($3, sections_firstprivate, 0); }
  2362. | LASTPRIVATE '(' variable_list ')'
  2363. { $$ = build_sections_clause_list($3, sections_lastprivate, 0); }
  2364. | REDUCTION '(' reduction_operator ':' variable_list ')'
  2365. { $$ = build_sections_clause_list($5, sections_reduction, $3); }
  2366. | NOWAIT
  2367. { $$ = build_sections_clause_list(NULL, sections_nowait, 0); }
  2368. ;
  2369. /* The first section directive is optional */
  2370. section_scope:
  2371. '{'
  2372. {
  2373. In_MP_Section = true;
  2374. add_stmt (build_omp_stmt (section_cons_b, NULL));
  2375. }
  2376. maybe_section_sequence '}'
  2377. ;
  2378. maybe_section_sequence:
  2379. section_sequence
  2380. | maybe_structured_block
  2381. | maybe_structured_block section_sequence
  2382. ;
  2383. maybe_structured_block:
  2384. structured_block
  2385. {
  2386. In_MP_Section = false;
  2387. add_stmt (build_omp_stmt (section_cons_e, NULL));
  2388. }
  2389. ;
  2390. section_sequence:
  2391. section_construct
  2392. |section_sequence section_construct
  2393. ;
  2394. section_construct:
  2395. section_directive
  2396. {
  2397. if (!In_MP_Section)
  2398. add_stmt (build_omp_stmt (section_cons_b, NULL));
  2399. else
  2400. In_MP_Section = false;
  2401. }
  2402. structured_block
  2403. {
  2404. add_stmt (build_omp_stmt (section_cons_e, NULL));
  2405. }
  2406. ;
  2407. section_directive:
  2408. PRAGMA_OMP SECTION '\n'
  2409. ;
  2410. single_construct:
  2411. single_directive
  2412. {
  2413. add_stmt (build_omp_stmt (single_cons_b, $1));
  2414. $<ttype>$ = NULL;
  2415. }
  2416. structured_block
  2417. { add_stmt (build_omp_stmt (single_cons_e, NULL)); $$ = NULL; }
  2418. ;
  2419. single_directive:
  2420. PRAGMA_OMP SINGLE '\n'
  2421. {$$ = NULL;}
  2422. | PRAGMA_OMP SINGLE single_clause_list '\n'
  2423. {$$ = $3;}
  2424. ;
  2425. single_clause_list:
  2426. single_clause
  2427. { $$ = $1; }
  2428. | single_clause_list single_clause
  2429. { $$ = chain_single_list_on ($1, $2); }
  2430. ;
  2431. single_clause:
  2432. PRIVATE '(' variable_list ')'
  2433. { $$ = build_single_clause_list($3, single_private); }
  2434. | FIRSTPRIVATE '(' variable_list ')'
  2435. { $$ = build_single_clause_list($3, single_firstprivate); }
  2436. | COPYPRIVATE '(' variable_list ')'
  2437. { $$ = build_single_clause_list($3, single_copyprivate); }
  2438. | NOWAIT
  2439. { $$ = build_single_clause_list(NULL, single_nowait); }
  2440. ;
  2441. parallel_for_construct:
  2442. parallel_for_directive
  2443. {
  2444. $<ttype>$ = add_stmt (build_omp_stmt (par_for_cons_b, $1));
  2445. In_MP_Region = true;
  2446. mp_nesting++;
  2447. if (mp_nesting == MAX_MP_NESTING)
  2448. {
  2449. // will see
  2450. printf ("MP nesting > %d not supported\n", MAX_MP_NESTING-1);
  2451. abort();
  2452. }
  2453. mp_locals[mp_nesting] = NULL;
  2454. }
  2455. iteration_statement
  2456. {
  2457. add_stmt (build_omp_stmt (par_for_cons_e, NULL));
  2458. $$ = NULL;
  2459. In_MP_Region = false;
  2460. if (mp_locals[mp_nesting])
  2461. {
  2462. $<ttype>2->omp.omp_clause_list =
  2463. chain_parallel_for_list_on ($<ttype>2->omp.omp_clause_list,
  2464. build_parallel_for_clause_list (mp_locals[mp_nesting],
  2465. p_for_private, 0, 0, 0));
  2466. }
  2467. mp_locals[mp_nesting] = NULL;
  2468. mp_nesting--;
  2469. }
  2470. ;
  2471. parallel_for_directive:
  2472. PRAGMA_OMP PARALLEL FOR '\n'
  2473. {$$ = NULL;}
  2474. | PRAGMA_OMP PARALLEL FOR parallel_for_clause_list '\n'
  2475. {$$ = $4;}
  2476. ;
  2477. parallel_for_clause_list:
  2478. parallel_for_clause
  2479. { $$ = $1; }
  2480. | parallel_for_clause_list parallel_for_clause
  2481. { $$ = chain_parallel_for_list_on ($1, $2); }
  2482. ;
  2483. parallel_for_clause:
  2484. IF '(' expr_no_commas ')'
  2485. { $$ = build_parallel_for_clause_list($3, p_for_if, 0, 0, 0); }
  2486. | NUM_THREADS '(' expr_no_commas ')'
  2487. { $$ = build_parallel_for_clause_list($3, p_for_num_threads, 0, 0, 0); }
  2488. | PRIVATE '(' variable_list ')'
  2489. { $$ = build_parallel_for_clause_list($3, p_for_private, 0, 0, 0); }
  2490. | COPYPRIVATE '(' variable_list ')'
  2491. { $$ = build_parallel_for_clause_list($3, p_for_copyprivate, 0, 0, 0); }
  2492. | FIRSTPRIVATE '(' variable_list ')'
  2493. { $$ = build_parallel_for_clause_list($3, p_for_firstprivate, 0, 0, 0); }
  2494. | LASTPRIVATE '(' variable_list ')'
  2495. { $$ = build_parallel_for_clause_list($3, p_for_lastprivate, 0, 0, 0); }
  2496. | SHARED '(' variable_list ')'
  2497. { $$ = build_parallel_for_clause_list($3, p_for_shared, 0, 0, 0); }
  2498. | DEFAULT '(' SHARED ')'
  2499. { $$ = build_parallel_for_clause_list(NULL, p_for_default, default_shared, 0, 0); }
  2500. | DEFAULT '(' NONE ')'
  2501. { $$ = build_parallel_for_clause_list(NULL, p_for_default, default_none, 0, 0); }
  2502. | REDUCTION '(' reduction_operator ':' variable_list ')'
  2503. { $$ = build_parallel_for_clause_list($5, p_for_reduction, 0, 0, $3); }
  2504. | COPYIN '(' variable_list ')'
  2505. { $$ = build_parallel_for_clause_list($3, p_for_copyin, 0, 0, 0); }
  2506. | SCHEDULE '(' schedule_kind ')'
  2507. { $$ = build_parallel_for_clause_list(NULL, p_for_schedule_1, 0, $3, 0); }
  2508. | SCHEDULE '(' schedule_kind ',' expr_no_commas ')'
  2509. { $$ = build_parallel_for_clause_list($5, p_for_schedule_2, 0, $3, 0); }
  2510. | ORDERED
  2511. { $$ = build_parallel_for_clause_list(NULL, p_for_ordered, 0, 0, 0); }
  2512. ;
  2513. parallel_sections_construct:
  2514. parallel_sections_directive
  2515. {
  2516. $<ttype>$ = add_stmt (build_omp_stmt (par_sctn_cons_b, $1));
  2517. In_MP_Region = true;
  2518. mp_nesting++;
  2519. if (mp_nesting == MAX_MP_NESTING)
  2520. {
  2521. // will see
  2522. printf ("MP nesting > %d not supported\n", MAX_MP_NESTING-1);
  2523. abort();
  2524. }
  2525. mp_locals[mp_nesting] = NULL;
  2526. }
  2527. section_scope
  2528. {
  2529. add_stmt (build_omp_stmt (par_sctn_cons_e, NULL));
  2530. $$ = NULL;
  2531. In_MP_Region = false;
  2532. if (mp_locals[mp_nesting])
  2533. {
  2534. $<ttype>2->omp.omp_clause_list =
  2535. chain_parallel_sections_list_on ($<ttype>2->omp.omp_clause_list,
  2536. build_parallel_sections_clause_list (mp_locals[mp_nesting],
  2537. p_sections_private, 0, 0));
  2538. }
  2539. mp_locals[mp_nesting] = NULL;
  2540. mp_nesting--;
  2541. }
  2542. ;
  2543. parallel_sections_directive:
  2544. PRAGMA_OMP PARALLEL SECTIONS '\n'
  2545. {$$ = NULL;}
  2546. | PRAGMA_OMP PARALLEL SECTIONS parallel_sections_clause_list '\n'
  2547. {$$ = $4;}
  2548. ;
  2549. parallel_sections_clause_list:
  2550. parallel_sections_clause
  2551. { $$=$1; }
  2552. | parallel_sections_clause_list parallel_sections_clause
  2553. { $$ = chain_parallel_sections_list_on ($1, $2); }
  2554. ;
  2555. parallel_sections_clause:
  2556. IF '(' expr_no_commas ')'
  2557. { $$ = build_parallel_sections_clause_list($3, p_sections_if, 0, 0); }
  2558. | NUM_THREADS '(' expr_no_commas ')'
  2559. { $$ = build_parallel_sections_clause_list($3, p_sections_num_threads, 0, 0); }
  2560. | PRIVATE '(' variable_list ')'
  2561. { $$ = build_parallel_sections_clause_list($3, p_sections_private, 0, 0); }
  2562. | COPYPRIVATE '(' variable_list ')'
  2563. { $$ = build_parallel_sections_clause_list($3, p_sections_copyprivate, 0, 0); }
  2564. | FIRSTPRIVATE '(' variable_list ')'
  2565. { $$ = build_parallel_sections_clause_list($3, p_sections_firstprivate, 0, 0); }
  2566. | LASTPRIVATE '(' variable_list ')'
  2567. { $$ = build_parallel_sections_clause_list($3, p_sections_lastprivate, 0, 0); }
  2568. | SHARED '(' variable_list ')'
  2569. { $$ = build_parallel_sections_clause_list($3, p_sections_shared, 0, 0); }
  2570. | DEFAULT '(' SHARED ')'
  2571. { $$ = build_parallel_sections_clause_list(NULL, p_sections_default, default_shared, 0); }
  2572. | DEFAULT '(' NONE ')'
  2573. { $$ = build_parallel_sections_clause_list(NULL, p_sections_default, default_none, 0); }
  2574. | REDUCTION '(' reduction_operator ':' variable_list ')'
  2575. { $$ = build_parallel_sections_clause_list($5, p_sections_reduction, 0, $3); }
  2576. | COPYIN '(' variable_list ')'
  2577. { $$ = build_parallel_sections_clause_list($3, p_sections_copyin, 0, 0); }
  2578. ;
  2579. master_construct:
  2580. master_directive
  2581. { add_stmt (build_omp_stmt (master_cons_b, NULL)); $<ttype>$ = NULL; }
  2582. structured_block
  2583. { add_stmt (build_omp_stmt (master_cons_e, NULL)); $$ = NULL; }
  2584. ;
  2585. master_directive:
  2586. PRAGMA_OMP MASTER '\n'
  2587. ;
  2588. critical_construct:
  2589. critical_directive
  2590. { add_stmt (build_omp_stmt (critical_cons_b, $1)); $<ttype>$ = NULL; }
  2591. structured_block
  2592. { add_stmt (build_omp_stmt (critical_cons_e, NULL)); $$ = NULL; }
  2593. ;
  2594. critical_directive:
  2595. PRAGMA_OMP CRITICAL '\n'
  2596. { $$ = NULL; }
  2597. | PRAGMA_OMP CRITICAL '(' region_phrase ')' '\n'
  2598. { $$ = $4; }
  2599. ;
  2600. region_phrase:
  2601. IDENTIFIER
  2602. { $$ = $1; }
  2603. ;
  2604. barrier_directive:
  2605. PRAGMA_OMP BARRIER '\n'
  2606. { add_stmt (build_omp_stmt (barrier_dir, NULL)); $$ = NULL; }
  2607. ;
  2608. atomic_construct:
  2609. atomic_directive expr_no_commas ';'
  2610. {
  2611. add_stmt (build_omp_stmt (atomic_cons, $2));
  2612. $$ = NULL;
  2613. }
  2614. ;
  2615. atomic_directive:
  2616. PRAGMA_OMP ATOMIC '\n'
  2617. ;
  2618. flush_directive:
  2619. PRAGMA_OMP FLUSH '\n'
  2620. { add_stmt (build_omp_stmt (flush_dir, NULL)); $$ = NULL; }
  2621. | PRAGMA_OMP FLUSH '(' variable_list ')' '\n'
  2622. { add_stmt (build_omp_stmt (flush_dir, $4)); $$ = NULL; }
  2623. ;
  2624. ordered_construct:
  2625. ordered_directive
  2626. { add_stmt (build_omp_stmt (ordered_cons_b, NULL)); $<ttype>$ = NULL; }
  2627. structured_block
  2628. { add_stmt (build_omp_stmt (ordered_cons_e, NULL)); $$ = NULL; }
  2629. ;
  2630. ordered_directive:
  2631. PRAGMA_OMP ORDERED '\n'
  2632. ;
  2633. threadprivate_directive:
  2634. PRAGMA_OMP THREADPRIVATE '(' variable_list ')' '\n'
  2635. { expand_threadprivate($4); }
  2636. ;
  2637. reduction_operator:
  2638. '+'
  2639. {$$ = REDUCTION_OPR_ADD;}
  2640. | '*'
  2641. {$$ = REDUCTION_OPR_MPY;}
  2642. | '-'
  2643. {$$ = REDUCTION_OPR_SUB;}
  2644. | '&'
  2645. {$$ = REDUCTION_OPR_BAND;}
  2646. | '^'
  2647. {$$ = REDUCTION_OPR_BXOR;}
  2648. | '|'
  2649. {$$ = REDUCTION_OPR_BIOR;}
  2650. | ANDAND
  2651. {$$ = REDUCTION_OPR_CAND;}
  2652. | OROR
  2653. {$$ = REDUCTION_OPR_CIOR;}
  2654. ;
  2655. variable_list:
  2656. IDENTIFIER
  2657. {
  2658. if(lookup_name($1)==0)
  2659. error("Undefined variable %s", IDENTIFIER_POINTER($1));
  2660. $$ = build_tree_list (NULL_TREE, lookup_name ($1));
  2661. }
  2662. |variable_list ',' IDENTIFIER
  2663. {
  2664. if (lookup_name ($3) == 0)
  2665. error ("Undefined variable %s", IDENTIFIER_POINTER($3));
  2666. $$ = chainon ($1, build_tree_list (NULL_TREE, lookup_name ($3)));
  2667. }
  2668. ;
  2669. /* Parse a single real statement, not including any labels. */
  2670. stmt:
  2671. pragma_directives
  2672. |openmp_construct
  2673. | compstmt
  2674. { stmt_count++; $$ = $1; }
  2675. | expr ';'
  2676. { stmt_count++;
  2677. $$ = c_expand_expr_stmt ($1); }
  2678. | c99_block_start select_or_iter_stmt c99_block_end
  2679. { if (flag_isoc99)
  2680. RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
  2681. $$ = NULL_TREE; }
  2682. | BREAK ';'
  2683. { stmt_count++;
  2684. $$ = add_stmt (build_break_stmt ()); }
  2685. | CONTINUE ';'
  2686. { stmt_count++;
  2687. $$ = add_stmt (build_continue_stmt ()); }
  2688. | RETURN ';'
  2689. { stmt_count++;
  2690. $$ = c_expand_return (NULL_TREE); }
  2691. | RETURN expr ';'
  2692. { stmt_count++;
  2693. $$ = c_expand_return ($2); }
  2694. | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
  2695. { stmt_count++;
  2696. $$ = simple_asm_stmt ($4); }
  2697. /* This is the case with just output operands. */
  2698. | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
  2699. { stmt_count++;
  2700. $$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
  2701. /* This is the case with input operands as well. */
  2702. | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
  2703. asm_operands ')' ';'
  2704. { stmt_count++;
  2705. $$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
  2706. /* This is the case with clobbered registers as well. */
  2707. | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
  2708. asm_operands ':' asm_clobbers ')' ';'
  2709. { stmt_count++;
  2710. $$ = build_asm_stmt ($2, $4, $6, $8, $10); }
  2711. | GOTO identifier ';'
  2712. { tree decl;
  2713. stmt_count++;
  2714. decl = lookup_label ($2);
  2715. if (decl != 0)
  2716. {
  2717. TREE_USED (decl) = 1;
  2718. $$ = add_stmt (build_stmt (GOTO_STMT, decl));
  2719. }
  2720. else
  2721. $$ = NULL_TREE;
  2722. }
  2723. | GOTO '*' expr ';'
  2724. { if (pedantic)
  2725. pedwarn ("ISO C forbids `goto *expr;'");
  2726. stmt_count++;
  2727. $3 = convert (ptr_type_node, $3);
  2728. $$ = add_stmt (build_stmt (GOTO_STMT, $3)); }
  2729. | ';'
  2730. { $$ = NULL_TREE; }
  2731. ;
  2732. /* Any kind of label, including jump labels and case labels.
  2733. ANSI C accepts labels only before statements, but we allow them
  2734. also at the end of a compound statement. */
  2735. label: CASE expr_no_commas ':'
  2736. { stmt_count++;
  2737. $$ = do_case ($2, NULL_TREE); }
  2738. | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
  2739. { stmt_count++;
  2740. $$ = do_case ($2, $4); }
  2741. | DEFAULT ':'
  2742. { stmt_count++;
  2743. $$ = do_case (NULL_TREE, NULL_TREE); }
  2744. | identifier save_filename save_lineno ':' maybe_attribute
  2745. { tree label = define_label ($2, $3, $1);
  2746. stmt_count++;
  2747. if (label)
  2748. {
  2749. decl_attributes (&label, $5, 0);
  2750. $$ = add_stmt (build_stmt (LABEL_STMT, label));
  2751. }
  2752. else
  2753. $$ = NULL_TREE;
  2754. }
  2755. ;
  2756. /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
  2757. maybe_type_qual:
  2758. /* empty */
  2759. { emit_line_note (input_filename, lineno);
  2760. $$ = NULL_TREE; }
  2761. | TYPE_QUAL
  2762. { emit_line_note (input_filename, lineno); }
  2763. ;
  2764. xexpr:
  2765. /* empty */
  2766. { $$ = NULL_TREE; }
  2767. | expr
  2768. ;
  2769. /* These are the operands other than the first string and colon
  2770. in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
  2771. asm_operands: /* empty */
  2772. { $$ = NULL_TREE; }
  2773. | nonnull_asm_operands
  2774. ;
  2775. nonnull_asm_operands:
  2776. asm_operand
  2777. | nonnull_asm_operands ',' asm_operand
  2778. { $$ = chainon ($1, $3); }
  2779. ;
  2780. asm_operand:
  2781. STRING '(' expr ')'
  2782. { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
  2783. | '[' identifier ']' STRING '(' expr ')'
  2784. { $2 = build_string (IDENTIFIER_LENGTH ($2),
  2785. IDENTIFIER_POINTER ($2));
  2786. $$ = build_tree_list (build_tree_list ($2, $4), $6); }
  2787. ;
  2788. asm_clobbers:
  2789. STRING
  2790. { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  2791. | asm_clobbers ',' STRING
  2792. { $$ = tree_cons (NULL_TREE, $3, $1); }
  2793. ;
  2794. /* This is what appears inside the parens in a function declarator.
  2795. Its value is a list of ..._TYPE nodes. Attributes must appear here
  2796. to avoid a conflict with their appearance after an open parenthesis
  2797. in an abstract declarator, as in
  2798. "void bar (int (__attribute__((__mode__(SI))) int foo));". */
  2799. parmlist:
  2800. maybe_attribute
  2801. { pushlevel (0);
  2802. clear_parm_order ();
  2803. declare_parm_level (0); }
  2804. parmlist_1
  2805. { $$ = $3;
  2806. parmlist_tags_warning ();
  2807. poplevel (0, 0, 0); }
  2808. ;
  2809. parmlist_1:
  2810. parmlist_2 ')'
  2811. | parms ';'
  2812. { tree parm;
  2813. if (pedantic)
  2814. pedwarn ("ISO C forbids forward parameter declarations");
  2815. /* Mark the forward decls as such. */
  2816. for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
  2817. TREE_ASM_WRITTEN (parm) = 1;
  2818. clear_parm_order (); }
  2819. maybe_attribute
  2820. { /* Dummy action so attributes are in known place
  2821. on parser stack. */ }
  2822. parmlist_1
  2823. { $$ = $6; }
  2824. | error ')'
  2825. { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
  2826. ;
  2827. /* This is what appears inside the parens in a function declarator.
  2828. Is value is represented in the format that grokdeclarator expects. */
  2829. parmlist_2: /* empty */
  2830. { $$ = get_parm_info (0); }
  2831. | ELLIPSIS
  2832. { $$ = get_parm_info (0);
  2833. /* Gcc used to allow this as an extension. However, it does
  2834. not work for all targets, and thus has been disabled.
  2835. Also, since func (...) and func () are indistinguishable,
  2836. it caused problems with the code in expand_builtin which
  2837. tries to verify that BUILT_IN_NEXT_ARG is being used
  2838. correctly. */
  2839. error ("ISO C requires a named argument before `...'");
  2840. }
  2841. | parms
  2842. { $$ = get_parm_info (1);
  2843. parsing_iso_function_signature = true;
  2844. }
  2845. | parms ',' ELLIPSIS
  2846. { $$ = get_parm_info (0); }
  2847. ;
  2848. parms:
  2849. firstparm
  2850. { push_parm_decl ($1); }
  2851. | parms ',' parm
  2852. { push_parm_decl ($3); }
  2853. ;
  2854. /* A single parameter declaration or parameter type name,
  2855. as found in a parmlist. */
  2856. parm:
  2857. declspecs_ts setspecs parm_declarator maybe_attribute
  2858. { $$ = build_tree_list (build_tree_list (current_declspecs,
  2859. $3),
  2860. chainon ($4, all_prefix_attributes));
  2861. POP_DECLSPEC_STACK; }
  2862. | declspecs_ts setspecs notype_declarator maybe_attribute
  2863. { $$ = build_tree_list (build_tree_list (current_declspecs,
  2864. $3),
  2865. chainon ($4, all_prefix_attributes));
  2866. POP_DECLSPEC_STACK; }
  2867. | declspecs_ts setspecs absdcl_maybe_attribute
  2868. { $$ = $3;
  2869. POP_DECLSPEC_STACK; }
  2870. | declspecs_nots setspecs notype_declarator maybe_attribute
  2871. { $$ = build_tree_list (build_tree_list (current_declspecs,
  2872. $3),
  2873. chainon ($4, all_prefix_attributes));
  2874. POP_DECLSPEC_STACK; }
  2875. | declspecs_nots setspecs absdcl_maybe_attribute
  2876. { $$ = $3;
  2877. POP_DECLSPEC_STACK; }
  2878. ;
  2879. /* The first parm, which must suck attributes from off the top of the parser
  2880. stack. */
  2881. firstparm:
  2882. declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
  2883. { $$ = build_tree_list (build_tree_list (current_declspecs,
  2884. $3),
  2885. chainon ($4, all_prefix_attributes));
  2886. POP_DECLSPEC_STACK; }
  2887. | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
  2888. { $$ = build_tree_list (build_tree_list (current_declspecs,
  2889. $3),
  2890. chainon ($4, all_prefix_attributes));
  2891. POP_DECLSPEC_STACK; }
  2892. | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
  2893. { $$ = $3;
  2894. POP_DECLSPEC_STACK; }
  2895. | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
  2896. { $$ = build_tree_list (build_tree_list (current_declspecs,
  2897. $3),
  2898. chainon ($4, all_prefix_attributes));
  2899. POP_DECLSPEC_STACK; }
  2900. | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
  2901. { $$ = $3;
  2902. POP_DECLSPEC_STACK; }
  2903. ;
  2904. setspecs_fp:
  2905. setspecs
  2906. { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
  2907. all_prefix_attributes = prefix_attributes; }
  2908. ;
  2909. /* This is used in a function definition
  2910. where either a parmlist or an identifier list is ok.
  2911. Its value is a list of ..._TYPE nodes or a list of identifiers. */
  2912. parmlist_or_identifiers:
  2913. maybe_attribute
  2914. { pushlevel (0);
  2915. clear_parm_order ();
  2916. declare_parm_level (1); }
  2917. parmlist_or_identifiers_1
  2918. { $$ = $3;
  2919. parmlist_tags_warning ();
  2920. poplevel (0, 0, 0); }
  2921. ;
  2922. parmlist_or_identifiers_1:
  2923. parmlist_1
  2924. | identifiers ')'
  2925. { tree t;
  2926. for (t = $1; t; t = TREE_CHAIN (t))
  2927. if (TREE_VALUE (t) == NULL_TREE)
  2928. error ("`...' in old-style identifier list");
  2929. $$ = tree_cons (NULL_TREE, NULL_TREE, $1);
  2930. /* Make sure we have a parmlist after attributes. */
  2931. if ($<ttype>-1 != 0
  2932. && (TREE_CODE ($$) != TREE_LIST
  2933. || TREE_PURPOSE ($$) == 0
  2934. || TREE_CODE (TREE_PURPOSE ($$)) != PARM_DECL))
  2935. YYERROR1;
  2936. }
  2937. ;
  2938. /* A nonempty list of identifiers. */
  2939. identifiers:
  2940. IDENTIFIER
  2941. { $$ = build_tree_list (NULL_TREE, $1); }
  2942. | identifiers ',' IDENTIFIER
  2943. { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2944. ;
  2945. /* A nonempty list of identifiers, including typenames. */
  2946. identifiers_or_typenames:
  2947. identifier
  2948. { $$ = build_tree_list (NULL_TREE, $1); }
  2949. | identifiers_or_typenames ',' identifier
  2950. { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2951. ;
  2952. extension:
  2953. EXTENSION
  2954. { $$ = SAVE_EXT_FLAGS();
  2955. pedantic = 0;
  2956. warn_pointer_arith = 0;
  2957. warn_traditional = 0;
  2958. flag_iso = 0; }
  2959. ;
  2960. %%
  2961. /* yylex() is a thin wrapper around c_lex(), all it does is translate
  2962. cpplib.h's token codes into yacc's token codes. */
  2963. static enum cpp_ttype last_token;
  2964. /* The reserved keyword table. */
  2965. struct resword
  2966. {
  2967. const char *word;
  2968. ENUM_BITFIELD(rid) rid : 16;
  2969. unsigned int disable : 16;
  2970. };
  2971. /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
  2972. _true_. */
  2973. #define D_C89 0x01 /* not in C89 */
  2974. #define D_EXT 0x02 /* GCC extension */
  2975. #define D_EXT89 0x04 /* GCC extension incorporated in C99 */
  2976. #define D_OBJC 0x08 /* Objective C only */
  2977. static const struct resword reswords[] =
  2978. {
  2979. { "_Bool", RID_BOOL, 0 },
  2980. { "_Complex", RID_COMPLEX, 0 },
  2981. { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
  2982. { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
  2983. { "__alignof", RID_ALIGNOF, 0 },
  2984. { "__alignof__", RID_ALIGNOF, 0 },
  2985. { "__asm", RID_ASM, 0 },
  2986. { "__asm__", RID_ASM, 0 },
  2987. { "__attribute", RID_ATTRIBUTE, 0 },
  2988. { "__attribute__", RID_ATTRIBUTE, 0 },
  2989. { "__bounded", RID_BOUNDED, 0 },
  2990. { "__bounded__", RID_BOUNDED, 0 },
  2991. { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 },
  2992. { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 },
  2993. { "__builtin_va_arg", RID_VA_ARG, 0 },
  2994. { "__complex", RID_COMPLEX, 0 },
  2995. { "__complex__", RID_COMPLEX, 0 },
  2996. { "__const", RID_CONST, 0 },
  2997. { "__const__", RID_CONST, 0 },
  2998. { "__extension__", RID_EXTENSION, 0 },
  2999. { "__func__", RID_C99_FUNCTION_NAME, 0 },
  3000. { "__imag", RID_IMAGPART, 0 },
  3001. { "__imag__", RID_IMAGPART, 0 },
  3002. { "__inline", RID_INLINE, 0 },
  3003. { "__inline__", RID_INLINE, 0 },
  3004. { "__label__", RID_LABEL, 0 },
  3005. { "__ptrbase", RID_PTRBASE, 0 },
  3006. { "__ptrbase__", RID_PTRBASE, 0 },
  3007. { "__ptrextent", RID_PTREXTENT, 0 },
  3008. { "__ptrextent__", RID_PTREXTENT, 0 },
  3009. { "__ptrvalue", RID_PTRVALUE, 0 },
  3010. { "__ptrvalue__", RID_PTRVALUE, 0 },
  3011. { "__real", RID_REALPART, 0 },
  3012. { "__real__", RID_REALPART, 0 },
  3013. { "__restrict", RID_RESTRICT, 0 },
  3014. { "__restrict__", RID_RESTRICT, 0 },
  3015. { "__signed", RID_SIGNED, 0 },
  3016. { "__signed__", RID_SIGNED, 0 },
  3017. { "__thread", RID_THREAD, 0 },
  3018. { "__typeof", RID_TYPEOF, 0 },
  3019. { "__typeof__", RID_TYPEOF, 0 },
  3020. { "__unbounded", RID_UNBOUNDED, 0 },
  3021. { "__unbounded__", RID_UNBOUNDED, 0 },
  3022. { "__volatile", RID_VOLATILE, 0 },
  3023. { "__volatile__", RID_VOLATILE, 0 },
  3024. { "asm", RID_ASM, D_EXT },
  3025. { "auto", RID_AUTO, 0 },
  3026. { "break", RID_BREAK, 0 },
  3027. { "case", RID_CASE, 0 },
  3028. { "char", RID_CHAR, 0 },
  3029. { "const", RID_CONST, 0 },
  3030. { "continue", RID_CONTINUE, 0 },
  3031. { "default", RID_DEFAULT, 0 },
  3032. { "do", RID_DO, 0 },
  3033. { "double", RID_DOUBLE, 0 },
  3034. { "else", RID_ELSE, 0 },
  3035. { "enum", RID_ENUM, 0 },
  3036. { "extern", RID_EXTERN, 0 },
  3037. { "float", RID_FLOAT, 0 },
  3038. { "for", RID_FOR, 0 },
  3039. { "goto", RID_GOTO, 0 },
  3040. { "if", RID_IF, 0 },
  3041. { "inline", RID_INLINE, D_EXT89 },
  3042. { "int", RID_INT, 0 },
  3043. { "long", RID_LONG, 0 },
  3044. { "register", RID_REGISTER, 0 },
  3045. { "restrict", RID_RESTRICT, D_C89 },
  3046. #ifdef TARG_SL
  3047. { "__sbuf", RID_SBUF, 0 },
  3048. { "__sdram", RID_SDRAM, 0 },
  3049. { "__v1buf", RID_V1BUF, 0 },
  3050. { "__v2buf", RID_V2BUF, 0 },
  3051. { "__v4buf", RID_V4BUF, 0 },
  3052. #endif
  3053. { "return", RID_RETURN, 0 },
  3054. { "short", RID_SHORT, 0 },
  3055. { "signed", RID_SIGNED, 0 },
  3056. { "sizeof", RID_SIZEOF, 0 },
  3057. { "static", RID_STATIC, 0 },
  3058. { "struct", RID_STRUCT, 0 },
  3059. { "switch", RID_SWITCH, 0 },
  3060. { "typedef", RID_TYPEDEF, 0 },
  3061. { "typeof", RID_TYPEOF, D_EXT },
  3062. { "union", RID_UNION, 0 },
  3063. { "unsigned", RID_UNSIGNED, 0 },
  3064. { "void", RID_VOID, 0 },
  3065. { "volatile", RID_VOLATILE, 0 },
  3066. { "while", RID_WHILE, 0 },
  3067. };
  3068. #define N_reswords (sizeof reswords / sizeof (struct resword))
  3069. /* Table mapping from RID_* constants to yacc token numbers.
  3070. Unfortunately we have to have entries for all the keywords in all
  3071. three languages. */
  3072. static const short rid_to_yy[RID_MAX] =
  3073. {
  3074. /* RID_STATIC */ STATIC,
  3075. /* RID_UNSIGNED */ TYPESPEC,
  3076. /* RID_LONG */ TYPESPEC,
  3077. /* RID_CONST */ TYPE_QUAL,
  3078. /* RID_EXTERN */ SCSPEC,
  3079. /* RID_REGISTER */ SCSPEC,
  3080. /* RID_TYPEDEF */ SCSPEC,
  3081. /* RID_SHORT */ TYPESPEC,
  3082. /* RID_INLINE */ SCSPEC,
  3083. /* RID_VOLATILE */ TYPE_QUAL,
  3084. /* RID_SIGNED */ TYPESPEC,
  3085. /* RID_AUTO */ SCSPEC,
  3086. /* RID_RESTRICT */ TYPE_QUAL,
  3087. #ifdef TARG_SL
  3088. /* RID_SBUF */ TYPE_QUAL,
  3089. /* RID_SDRAM */ TYPE_QUAL,
  3090. /* RID_V1BUF */ TYPE_QUAL,
  3091. /* RID_V2BUF */ TYPE_QUAL,
  3092. /* RID_V4BUF */ TYPE_QUAL,
  3093. #endif
  3094. /* C extensions */
  3095. /* RID_BOUNDED */ TYPE_QUAL,
  3096. /* RID_UNBOUNDED */ TYPE_QUAL,
  3097. /* RID_COMPLEX */ TYPESPEC,
  3098. /* RID_THREAD */ SCSPEC,
  3099. /* C++ */
  3100. /* RID_FRIEND */ 0,
  3101. /* RID_VIRTUAL */ 0,
  3102. /* RID_EXPLICIT */ 0,
  3103. /* RID_EXPORT */ 0,
  3104. /* RID_MUTABLE */ 0,
  3105. /* ObjC */
  3106. /* RID_IN */ TYPE_QUAL,
  3107. /* RID_OUT */ TYPE_QUAL,
  3108. /* RID_INOUT */ TYPE_QUAL,
  3109. /* RID_BYCOPY */ TYPE_QUAL,
  3110. /* RID_BYREF */ TYPE_QUAL,
  3111. /* RID_ONEWAY */ TYPE_QUAL,
  3112. /* C */
  3113. /* RID_INT */ TYPESPEC,
  3114. /* RID_CHAR */ TYPESPEC,
  3115. /* RID_FLOAT */ TYPESPEC,
  3116. /* RID_DOUBLE */ TYPESPEC,
  3117. /* RID_VOID */ TYPESPEC,
  3118. /* RID_ENUM */ ENUM,
  3119. /* RID_STRUCT */ STRUCT,
  3120. /* RID_UNION */ UNION,
  3121. /* RID_IF */ IF,
  3122. /* RID_ELSE */ ELSE,
  3123. /* RID_WHILE */ WHILE,
  3124. /* RID_DO */ DO,
  3125. /* RID_FOR */ FOR,
  3126. /* RID_SWITCH */ SWITCH,
  3127. /* RID_CASE */ CASE,
  3128. /* RID_DEFAULT */ DEFAULT,
  3129. /* RID_BREAK */ BREAK,
  3130. /* RID_CONTINUE */ CONTINUE,
  3131. /* RID_RETURN */ RETURN,
  3132. /* RID_GOTO */ GOTO,
  3133. /* RID_SIZEOF */ SIZEOF,
  3134. /* C extensions */
  3135. /* RID_ASM */ ASM_KEYWORD,
  3136. /* RID_TYPEOF */ TYPEOF,
  3137. /* RID_ALIGNOF */ ALIGNOF,
  3138. /* RID_ATTRIBUTE */ ATTRIBUTE,
  3139. /* RID_VA_ARG */ VA_ARG,
  3140. /* RID_EXTENSION */ EXTENSION,
  3141. /* RID_IMAGPART */ IMAGPART,
  3142. /* RID_REALPART */ REALPART,
  3143. /* RID_LABEL */ LABEL,
  3144. /* RID_PTRBASE */ PTR_BASE,
  3145. /* RID_PTREXTENT */ PTR_EXTENT,
  3146. /* RID_PTRVALUE */ PTR_VALUE,
  3147. /* RID_CHOOSE_EXPR */ CHOOSE_EXPR,
  3148. /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P,
  3149. /* RID_FUNCTION_NAME */ STRING_FUNC_NAME,
  3150. /* RID_PRETTY_FUNCTION_NAME */ STRING_FUNC_NAME,
  3151. /* RID_C99_FUNCTION_NAME */ VAR_FUNC_NAME,
  3152. /* C++ */
  3153. /* RID_BOOL */ TYPESPEC,
  3154. /* RID_WCHAR */ 0,
  3155. /* RID_CLASS */ 0,
  3156. /* RID_PUBLIC */ 0,
  3157. /* RID_PRIVATE */ 0,
  3158. /* RID_PROTECTED */ 0,
  3159. /* RID_TEMPLATE */ 0,
  3160. /* RID_NULL */ 0,
  3161. /* RID_CATCH */ 0,
  3162. /* RID_DELETE */ 0,
  3163. /* RID_FALSE */ 0,
  3164. /* RID_NAMESPACE */ 0,
  3165. /* RID_NEW */ 0,
  3166. /* RID_OPERATOR */ 0,
  3167. /* RID_THIS */ 0,
  3168. /* RID_THROW */ 0,
  3169. /* RID_TRUE */ 0,
  3170. /* RID_TRY */ 0,
  3171. /* RID_TYPENAME */ 0,
  3172. /* RID_TYPEID */ 0,
  3173. /* RID_USING */ 0,
  3174. /* casts */
  3175. /* RID_CONSTCAST */ 0,
  3176. /* RID_DYNCAST */ 0,
  3177. /* RID_REINTCAST */ 0,
  3178. /* RID_STATCAST */ 0,
  3179. /* Objective C */
  3180. /* RID_ID */ OBJECTNAME,
  3181. /* RID_AT_ENCODE */ ENCODE,
  3182. /* RID_AT_END */ END,
  3183. /* RID_AT_CLASS */ CLASS,
  3184. /* RID_AT_ALIAS */ ALIAS,
  3185. /* RID_AT_DEFS */ DEFS,
  3186. /* RID_AT_PRIVATE */ PRIVATE,
  3187. /* RID_AT_PROTECTED */ PROTECTED,
  3188. /* RID_AT_PUBLIC */ PUBLIC,
  3189. /* RID_AT_PROTOCOL */ PROTOCOL,
  3190. /* RID_AT_SELECTOR */ SELECTOR,
  3191. /* RID_AT_INTERFACE */ INTERFACE,
  3192. /* RID_AT_IMPLEMENTATION */ IMPLEMENTATION
  3193. };
  3194. static void
  3195. init_reswords ()
  3196. {
  3197. unsigned int i;
  3198. tree id;
  3199. int mask = (flag_isoc99 ? 0 : D_C89)
  3200. | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
  3201. if (!flag_objc)
  3202. mask |= D_OBJC;
  3203. /* It is not necessary to register ridpointers as a GC root, because
  3204. all the trees it points to are permanently interned in the
  3205. get_identifier hash anyway. */
  3206. ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
  3207. for (i = 0; i < N_reswords; i++)
  3208. {
  3209. /* If a keyword is disabled, do not enter it into the table
  3210. and so create a canonical spelling that isn't a keyword. */
  3211. if (reswords[i].disable & mask)
  3212. continue;
  3213. id = get_identifier (reswords[i].word);
  3214. C_RID_CODE (id) = reswords[i].rid;
  3215. C_IS_RESERVED_WORD (id) = 1;
  3216. ridpointers [(int) reswords[i].rid] = id;
  3217. }
  3218. }
  3219. #define NAME(type) cpp_type2name (type)
  3220. static void
  3221. yyerror (msgid)
  3222. const char *msgid;
  3223. {
  3224. const char *string = _(msgid);
  3225. if (last_token == CPP_EOF)
  3226. error ("%s at end of input", string);
  3227. else if (last_token == CPP_CHAR || last_token == CPP_WCHAR)
  3228. {
  3229. unsigned int val = TREE_INT_CST_LOW (yylval.ttype);
  3230. const char *const ell = (last_token == CPP_CHAR) ? "" : "L";
  3231. if (val <= UCHAR_MAX && ISGRAPH (val))
  3232. error ("%s before %s'%c'", string, ell, val);
  3233. else
  3234. error ("%s before %s'\\x%x'", string, ell, val);
  3235. }
  3236. else if (last_token == CPP_STRING
  3237. || last_token == CPP_WSTRING)
  3238. error ("%s before string constant", string);
  3239. else if (last_token == CPP_NUMBER)
  3240. error ("%s before numeric constant", string);
  3241. else if (last_token == CPP_NAME)
  3242. error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
  3243. else
  3244. error ("%s before '%s' token", string, NAME(last_token));
  3245. }
  3246. static int
  3247. yylexname ()
  3248. {
  3249. tree decl;
  3250. if (C_IS_RESERVED_WORD (yylval.ttype))
  3251. {
  3252. enum rid rid_code = C_RID_CODE (yylval.ttype);
  3253. {
  3254. int yycode = rid_to_yy[(int) rid_code];
  3255. if (yycode == STRING_FUNC_NAME)
  3256. {
  3257. /* __FUNCTION__ and __PRETTY_FUNCTION__ get converted
  3258. to string constants. */
  3259. const char *name = fname_string (rid_code);
  3260. yylval.ttype = build_string (strlen (name) + 1, name);
  3261. C_ARTIFICIAL_STRING_P (yylval.ttype) = 1;
  3262. last_token = CPP_STRING; /* so yyerror won't choke */
  3263. return STRING;
  3264. }
  3265. /* Return the canonical spelling for this keyword. */
  3266. yylval.ttype = ridpointers[(int) rid_code];
  3267. return yycode;
  3268. }
  3269. }
  3270. decl = lookup_name (yylval.ttype);
  3271. if (decl)
  3272. {
  3273. if (TREE_CODE (decl) == TYPE_DECL)
  3274. return TYPENAME;
  3275. }
  3276. return IDENTIFIER;
  3277. }
  3278. /* Concatenate strings before returning them to the parser. This isn't quite
  3279. as good as having it done in the lexer, but it's better than nothing. */
  3280. static int
  3281. yylexstring ()
  3282. {
  3283. enum cpp_ttype next_type;
  3284. tree orig = yylval.ttype;
  3285. next_type = c_lex (&yylval.ttype);
  3286. if (next_type == CPP_STRING
  3287. || next_type == CPP_WSTRING
  3288. || (next_type == CPP_NAME && yylexname () == STRING))
  3289. {
  3290. varray_type strings;
  3291. static int last_lineno = 0;
  3292. static const char *last_input_filename = 0;
  3293. if (warn_traditional && !in_system_header
  3294. && (lineno != last_lineno || !last_input_filename ||
  3295. strcmp (last_input_filename, input_filename)))
  3296. {
  3297. warning ("traditional C rejects string concatenation");
  3298. last_lineno = lineno;
  3299. last_input_filename = input_filename;
  3300. }
  3301. VARRAY_TREE_INIT (strings, 32, "strings");
  3302. VARRAY_PUSH_TREE (strings, orig);
  3303. do
  3304. {
  3305. VARRAY_PUSH_TREE (strings, yylval.ttype);
  3306. next_type = c_lex (&yylval.ttype);
  3307. }
  3308. while (next_type == CPP_STRING
  3309. || next_type == CPP_WSTRING
  3310. || (next_type == CPP_NAME && yylexname () == STRING));
  3311. yylval.ttype = combine_strings (strings);
  3312. }
  3313. else
  3314. yylval.ttype = orig;
  3315. /* We will have always read one token too many. */
  3316. _cpp_backup_tokens (parse_in, 1);
  3317. return STRING;
  3318. }
  3319. extern bool in_omp_pragma;
  3320. extern bool seen_omp_paren;
  3321. static int
  3322. check_omp_string (char * s, bool * status)
  3323. {
  3324. *status = true;
  3325. /* Windows systems use \r\n not \n, so check for that
  3326. * but return \n since that is what grammar is checking for.
  3327. */
  3328. if (!strcmp (s, "\n") || !strcmp(s,"\r"))
  3329. {
  3330. in_omp_pragma = seen_omp_paren = FALSE;
  3331. return '\n';
  3332. }
  3333. if ((!strcmp (s, "mips_frequency_hint") ||
  3334. !strcmp (s, "frequency_hint")) && !seen_omp_paren)
  3335. return PRAGMA_EXEC_FREQ;
  3336. if (!strcasecmp (s, "never") && !seen_omp_paren)
  3337. return FREQ_NEVER;
  3338. if (!strcasecmp (s, "init") && !seen_omp_paren)
  3339. return FREQ_INIT;
  3340. if (!strcasecmp (s, "frequent") && !seen_omp_paren)
  3341. return FREQ_FREQUENT;
  3342. if (!strcmp (s, "options") && !seen_omp_paren)
  3343. return PRAGMA_OPTIONS;
  3344. if (!strcmp (s, "unroll") && !seen_omp_paren)
  3345. return PRAGMA_UNROLL;
  3346. if (!strcmp (s, "private") && !seen_omp_paren)
  3347. return PRIVATE;
  3348. if (!strcmp (s, "parallel") && !seen_omp_paren)
  3349. return PARALLEL;
  3350. if (!strcmp (s, "omp") && !seen_omp_paren)
  3351. return PRAGMA_OMP;
  3352. if (!strcmp (s, "copyprivate") && !seen_omp_paren)
  3353. return COPYPRIVATE;
  3354. if (!strcmp (s, "firstprivate") && !seen_omp_paren)
  3355. return FIRSTPRIVATE;
  3356. if (!strcmp (s, "lastprivate") && !seen_omp_paren)
  3357. return LASTPRIVATE;
  3358. if (!strcmp (s, "shared"))
  3359. return SHARED;
  3360. if (!strcmp (s, "none"))
  3361. return NONE;
  3362. if (!strcmp (s, "reduction") && !seen_omp_paren)
  3363. return REDUCTION;
  3364. if (!strcmp (s, "copyin") && !seen_omp_paren)
  3365. return COPYIN;
  3366. if (!strcmp (s, "static"))
  3367. {
  3368. fprintf (stderr,"NYI\n");
  3369. abort();
  3370. }
  3371. if (!strcmp (s, "dynamic"))
  3372. return DYNAMIC;
  3373. if (!strcmp (s, "guided"))
  3374. return GUIDED;
  3375. if (!strcmp (s, "runtime"))
  3376. return RUNTIME;
  3377. if (!strcmp (s, "ordered"))
  3378. return ORDERED;
  3379. if (!strcmp (s, "schedule"))
  3380. return SCHEDULE;
  3381. if (!strcmp (s, "nowait"))
  3382. return NOWAIT;
  3383. if (!strcmp (s, "num_threads") && !seen_omp_paren)
  3384. return NUM_THREADS;
  3385. if (!strcmp (s, "sections") && !seen_omp_paren)
  3386. return SECTIONS;
  3387. if (!strcmp (s, "section"))
  3388. return SECTION;
  3389. if (!strcmp (s, "single"))
  3390. return SINGLE;
  3391. if (!strcmp (s, "master") && !seen_omp_paren)
  3392. return MASTER;
  3393. if (!strcmp (s, "critical") && !seen_omp_paren)
  3394. return CRITICAL;
  3395. if (!strcmp (s, "barrier") && !seen_omp_paren)
  3396. return BARRIER;
  3397. if (!strcmp (s, "atomic") && !seen_omp_paren)
  3398. return ATOMIC;
  3399. if (!strcmp (s, "flush") && !seen_omp_paren)
  3400. return FLUSH;
  3401. if (!strcmp (s, "threadprivate") && !seen_omp_paren)
  3402. return THREADPRIVATE;
  3403. #ifdef TARG_SL //fork_joint
  3404. if(!strcmp(s, "sl2") && !seen_omp_paren)
  3405. return PRAGMA_SL2;
  3406. if(!strcmp(s, "sl2_major_sections") && !seen_omp_paren)
  3407. return SL2_SECTIONS;
  3408. if(!strcmp(s, "sl2_minor_sections") && !seen_omp_paren)
  3409. return SL2_MINOR_SECTIONS;
  3410. if(!strcmp(s, "sl2_major_section") && !seen_omp_paren)
  3411. return SL2_SECTION;
  3412. if(!strcmp(s, "sl2_minor_section") && !seen_omp_paren)
  3413. return SL2_MINOR_SECTION;
  3414. #endif
  3415. // this must be last, return anything
  3416. *status = false;
  3417. return 0;
  3418. }
  3419. static inline int
  3420. _yylex ()
  3421. {
  3422. get_next:
  3423. last_token = c_lex (&yylval.ttype);
  3424. switch (last_token)
  3425. {
  3426. case CPP_EQ: return '=';
  3427. case CPP_NOT: return '!';
  3428. case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
  3429. case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
  3430. case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
  3431. case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
  3432. case CPP_MULT: yylval.code = MULT_EXPR; return '*';
  3433. case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
  3434. case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
  3435. case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
  3436. case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
  3437. case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
  3438. case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
  3439. case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
  3440. case CPP_COMPL: return '~';
  3441. case CPP_AND_AND: return ANDAND;
  3442. case CPP_OR_OR: return OROR;
  3443. case CPP_QUERY: return '?';
  3444. case CPP_OPEN_PAREN: return '(';
  3445. case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
  3446. case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
  3447. case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
  3448. case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
  3449. case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
  3450. case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
  3451. case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
  3452. case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
  3453. case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
  3454. case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
  3455. case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
  3456. case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
  3457. case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
  3458. case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
  3459. case CPP_OPEN_SQUARE: return '[';
  3460. case CPP_CLOSE_SQUARE: return ']';
  3461. case CPP_OPEN_BRACE: return '{';
  3462. case CPP_CLOSE_BRACE: return '}';
  3463. case CPP_ELLIPSIS: return ELLIPSIS;
  3464. case CPP_PLUS_PLUS: return PLUSPLUS;
  3465. case CPP_MINUS_MINUS: return MINUSMINUS;
  3466. case CPP_DEREF: return POINTSAT;
  3467. case CPP_DOT: return '.';
  3468. /* The following tokens may affect the interpretation of any
  3469. identifiers following, if doing Objective-C. */
  3470. case CPP_COLON: OBJC_NEED_RAW_IDENTIFIER (0); return ':';
  3471. case CPP_COMMA: OBJC_NEED_RAW_IDENTIFIER (0); return ',';
  3472. case CPP_CLOSE_PAREN: OBJC_NEED_RAW_IDENTIFIER (0); return ')';
  3473. case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';';
  3474. case CPP_EOF:
  3475. return 0;
  3476. case CPP_NAME:
  3477. {
  3478. int ret = yylexname ();
  3479. if (ret == STRING)
  3480. return yylexstring ();
  3481. else if (ret == IDENTIFIER && in_omp_pragma)
  3482. {
  3483. char *omp_name;
  3484. bool valid = false;
  3485. int code;
  3486. if (TREE_CODE (yylval.ttype) != IDENTIFIER_NODE) abort();
  3487. omp_name = IDENTIFIER_POINTER (yylval.ttype);
  3488. code = check_omp_string (omp_name, &valid);
  3489. if (valid) return code;
  3490. }
  3491. return ret;
  3492. }
  3493. case CPP_NUMBER:
  3494. case CPP_CHAR:
  3495. case CPP_WCHAR:
  3496. return CONSTANT;
  3497. case CPP_STRING:
  3498. case CPP_WSTRING:
  3499. return yylexstring ();
  3500. /* This token is Objective-C specific. It gives the next token
  3501. special significance. */
  3502. case CPP_ATSIGN:
  3503. /* These tokens are C++ specific (and will not be generated
  3504. in C mode, but let's be cautious). */
  3505. case CPP_SCOPE:
  3506. case CPP_DEREF_STAR:
  3507. case CPP_DOT_STAR:
  3508. case CPP_MIN_EQ:
  3509. case CPP_MAX_EQ:
  3510. case CPP_MIN:
  3511. case CPP_MAX:
  3512. /* These tokens should not survive translation phase 4. */
  3513. case CPP_HASH:
  3514. case CPP_PASTE:
  3515. error ("syntax error at '%s' token", NAME(last_token));
  3516. goto get_next;
  3517. default:
  3518. abort ();
  3519. }
  3520. /* NOTREACHED */
  3521. }
  3522. static int
  3523. yylex()
  3524. {
  3525. int r;
  3526. timevar_push (TV_LEX);
  3527. r = _yylex();
  3528. timevar_pop (TV_LEX);
  3529. return r;
  3530. }
  3531. /* Function used when yydebug is set, to print a token in more detail. */
  3532. static void
  3533. yyprint (file, yychar, yyl)
  3534. FILE *file;
  3535. int yychar;
  3536. YYSTYPE yyl;
  3537. {
  3538. tree t = yyl.ttype;
  3539. fprintf (file, " [%s]", NAME(last_token));
  3540. switch (yychar)
  3541. {
  3542. case IDENTIFIER:
  3543. case TYPENAME:
  3544. case OBJECTNAME:
  3545. case TYPESPEC:
  3546. case TYPE_QUAL:
  3547. case SCSPEC:
  3548. case STATIC:
  3549. if (IDENTIFIER_POINTER (t))
  3550. fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
  3551. break;
  3552. case CONSTANT:
  3553. fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
  3554. if (TREE_CODE (t) == INTEGER_CST)
  3555. fprintf (file,
  3556. #if HOST_BITS_PER_WIDE_INT == 64
  3557. #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
  3558. " 0x%x%016x",
  3559. #else
  3560. #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
  3561. " 0x%lx%016lx",
  3562. #else
  3563. " 0x%llx%016llx",
  3564. #endif
  3565. #endif
  3566. #else
  3567. #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
  3568. " 0x%lx%08lx",
  3569. #else
  3570. " 0x%x%08x",
  3571. #endif
  3572. #endif
  3573. TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
  3574. break;
  3575. }
  3576. }
  3577. /* This is not the ideal place to put these, but we have to get them out
  3578. of c-lex.c because cp/lex.c has its own versions. */
  3579. /* Free malloced parser stacks if necessary. */
  3580. void
  3581. free_parser_stacks ()
  3582. {
  3583. if (malloced_yyss)
  3584. {
  3585. free (malloced_yyss);
  3586. free (malloced_yyvs);
  3587. }
  3588. }
  3589. #include "gt-c-parse.h"