summaryrefslogtreecommitdiff
path: root/gcc/c-parse.in
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r--gcc/c-parse.in94
1 files changed, 44 insertions, 50 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 7bd12990ddc..a329a1610ac 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -28,33 +28,10 @@ Boston, MA 02111-1307, USA. */
written by AT&T, but I have never seen it. */
ifobjc
-%expect 66
+%expect 73
end ifobjc
ifc
-%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
end ifc
%{
@@ -191,7 +168,7 @@ end ifc
%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
@@ -806,42 +783,37 @@ end ifobjc
$$ = $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); }
@@ -1795,9 +1767,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);
@@ -1805,7 +1777,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);
@@ -1813,7 +1785,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);
@@ -1823,6 +1795,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