diff options
author | Richard Henderson <rth@cygnus.com> | 1999-09-02 10:20:19 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 1999-09-02 10:20:19 -0700 |
commit | d0668a73936a55ac7dbb3d62d94a9da6c1cc46cf (patch) | |
tree | 332aa137165e706894a9d57a9a0948baf6b87b4c /gcc/c-parse.y | |
parent | a8c61259522b6380059d092abfb7ca9c61fc36bf (diff) | |
download | gcc-d0668a73936a55ac7dbb3d62d94a9da6c1cc46cf.tar.gz |
c-parse.in (compstmt_primary_start): New, broken out of first part of compstmt handling in primary.
* c-parse.in (compstmt_primary_start): New, broken out of first
part of compstmt handling in primary.
(primary): Use it. Add an error clause.
(compstmt_nostart): Renamed from compstmt; remove all
initial invocations of compstmt_start.
(compstmt): New.
From-SVN: r29059
Diffstat (limited to 'gcc/c-parse.y')
-rw-r--r-- | gcc/c-parse.y | 92 |
1 files changed, 43 insertions, 49 deletions
diff --git a/gcc/c-parse.y b/gcc/c-parse.y index 08d985b0876..9833b0fde29 100644 --- a/gcc/c-parse.y +++ b/gcc/c-parse.y @@ -28,30 +28,7 @@ Boston, MA 02111-1307, USA. */ /* To whomever it may concern: I have heard that such a thing was once written by AT&T, but I have never seen it. */ -%expect 51 - -/* These are the 23 conflicts you should get in parse.output; - the state numbers may vary if minor changes in the grammar are made. - -State 42 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.) -State 44 contains 1 shift/reduce conflict. (Two ways to recover from error.) -State 103 contains 1 shift/reduce conflict. (Two ways to recover from error.) -State 110 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.) -State 111 contains 1 shift/reduce conflict. (Two ways to recover from error.) -State 115 contains 1 shift/reduce conflict. (Two ways to recover from error.) -State 132 contains 1 shift/reduce conflict. (See comment at component_decl.) -State 180 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.) -State 194 contains 2 shift/reduce conflict. (Four ways to parse this.) -State 202 contains 1 shift/reduce conflict. (Two ways to recover from error.) -State 214 contains 1 shift/reduce conflict. (Two ways to recover from error.) -State 220 contains 1 shift/reduce conflict. (Two ways to recover from error.) -State 304 contains 2 shift/reduce conflicts. (Four ways to parse this.) -State 335 contains 2 shift/reduce conflicts. (Four ways to parse this.) -State 347 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.) -State 352 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.) -State 383 contains 2 shift/reduce conflicts. (Four ways to parse this.) -State 434 contains 2 shift/reduce conflicts. (Four ways to parse this.) */ - +%expect 52 %{ #include "config.h" @@ -179,7 +156,7 @@ const char * const language_string = "GNU C"; %type <ttype> maybe_attribute attributes attribute attribute_list attrib %type <ttype> any_word -%type <ttype> compstmt +%type <ttype> compstmt compstmt_nostart compstmt_primary_start %type <ttype> declarator %type <ttype> notype_declarator after_type_declarator @@ -692,42 +669,37 @@ primary: $$ = $2; } | '(' error ')' { $$ = error_mark_node; } - | '(' - { if (current_function_decl == 0) - { - error ("braced-group within expression allowed only inside a function"); - YYERROR; - } - /* We must force a BLOCK for this level - so that, if it is not expanded later, - there is a way to turn off the entire subtree of blocks - that are contained in it. */ - keep_next_level (); - push_iterator_stack (); - push_label_level (); - $<ttype>$ = expand_start_stmt_expr (); } - compstmt ')' + | compstmt_primary_start compstmt_nostart ')' { tree rtl_exp; if (pedantic) pedwarn ("ANSI C forbids braced-groups within expressions"); pop_iterator_stack (); pop_label_level (); - rtl_exp = expand_end_stmt_expr ($<ttype>2); + rtl_exp = expand_end_stmt_expr ($1); /* The statements have side effects, so the group does. */ TREE_SIDE_EFFECTS (rtl_exp) = 1; - if (TREE_CODE ($3) == BLOCK) + if (TREE_CODE ($2) == BLOCK) { /* Make a BIND_EXPR for the BLOCK already made. */ $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp), - NULL_TREE, rtl_exp, $3); + NULL_TREE, rtl_exp, $2); /* Remove the block from the tree at this point. It gets put back at the proper place when the BIND_EXPR is expanded. */ - delete_block ($3); + delete_block ($2); } else - $$ = $3; + $$ = $2; + } + | compstmt_primary_start error ')' + { + /* Make sure we call expand_end_stmt_expr. Otherwise + we are likely to lose sequences and crash later. */ + pop_iterator_stack (); + pop_label_level (); + expand_end_stmt_expr ($1); + $$ = error_mark_node; } | primary '(' exprlist ')' %prec '.' { $$ = build_function_call ($1, $3); } @@ -1600,9 +1572,9 @@ compstmt_or_error: compstmt_start: '{' { compstmt_count++; } -compstmt: compstmt_start '}' +compstmt_nostart: '}' { $$ = convert (void_type_node, integer_zero_node); } - | compstmt_start pushlevel maybe_label_decls decls xstmts '}' + | pushlevel maybe_label_decls decls xstmts '}' { emit_line_note (input_filename, lineno); expand_end_bindings (getdecls (), 1, 0); $$ = poplevel (1, 1, 0); @@ -1610,7 +1582,7 @@ compstmt: compstmt_start '}' pop_momentary_nofree (); else pop_momentary (); } - | compstmt_start pushlevel maybe_label_decls error '}' + | pushlevel maybe_label_decls error '}' { emit_line_note (input_filename, lineno); expand_end_bindings (getdecls (), kept_level_p (), 0); $$ = poplevel (kept_level_p (), 0, 0); @@ -1618,7 +1590,7 @@ compstmt: compstmt_start '}' pop_momentary_nofree (); else pop_momentary (); } - | compstmt_start pushlevel maybe_label_decls stmts '}' + | pushlevel maybe_label_decls stmts '}' { emit_line_note (input_filename, lineno); expand_end_bindings (getdecls (), kept_level_p (), 0); $$ = poplevel (kept_level_p (), 0, 0); @@ -1628,6 +1600,28 @@ compstmt: compstmt_start '}' pop_momentary (); } ; +compstmt_primary_start: + '(' '{' + { if (current_function_decl == 0) + { + error ("braced-group within expression allowed only inside a function"); + YYERROR; + } + /* We must force a BLOCK for this level + so that, if it is not expanded later, + there is a way to turn off the entire subtree of blocks + that are contained in it. */ + keep_next_level (); + push_iterator_stack (); + push_label_level (); + $$ = expand_start_stmt_expr (); + compstmt_count++; + } + +compstmt: compstmt_start compstmt_nostart + { $$ = $2; } + ; + /* Value is number of statements counted as of the closeparen. */ simple_if: if_prefix lineno_labeled_stmt |