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
This commit is contained in:
Richard Henderson 1999-09-02 10:20:19 -07:00 committed by Richard Henderson
parent a8c6125952
commit d0668a7393
7 changed files with 3959 additions and 3744 deletions

View file

@ -1,3 +1,12 @@
Thu Sep 2 10:19:20 1999 Richard Henderson <rth@cygnus.com>
* 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.
Thu Sep 2 01:35:50 1999 Marc Espie <espie@cvs.openbsd.org>
* protoize.c (gen_aux_info_file): Let pexecute call choose_temp_base if

File diff suppressed because it is too large Load diff

View file

@ -1,66 +1,66 @@
typedef union {long itype; tree ttype; enum tree_code code;
char *filename; int lineno; int ends_in_label; } YYSTYPE;
#define IDENTIFIER 258
#define TYPENAME 259
#define SCSPEC 260
#define TYPESPEC 261
#define TYPE_QUAL 262
#define CONSTANT 263
#define STRING 264
#define ELLIPSIS 265
#define SIZEOF 266
#define ENUM 267
#define STRUCT 268
#define UNION 269
#define IF 270
#define ELSE 271
#define WHILE 272
#define DO 273
#define FOR 274
#define SWITCH 275
#define CASE 276
#define DEFAULT 277
#define BREAK 278
#define CONTINUE 279
#define RETURN 280
#define GOTO 281
#define ASM_KEYWORD 282
#define TYPEOF 283
#define ALIGNOF 284
#define ATTRIBUTE 285
#define EXTENSION 286
#define LABEL 287
#define REALPART 288
#define IMAGPART 289
#define VA_ARG 290
#define END_OF_LINE 291
#define ASSIGN 292
#define OROR 293
#define ANDAND 294
#define EQCOMPARE 295
#define ARITHCOMPARE 296
#define LSHIFT 297
#define RSHIFT 298
#define UNARY 299
#define PLUSPLUS 300
#define MINUSMINUS 301
#define HYPERUNARY 302
#define POINTSAT 303
#define INTERFACE 304
#define IMPLEMENTATION 305
#define END 306
#define SELECTOR 307
#define DEFS 308
#define ENCODE 309
#define CLASSNAME 310
#define PUBLIC 311
#define PRIVATE 312
#define PROTECTED 313
#define PROTOCOL 314
#define OBJECTNAME 315
#define CLASS 316
#define ALIAS 317
#define OBJC_STRING 318
#define IDENTIFIER 257
#define TYPENAME 258
#define SCSPEC 259
#define TYPESPEC 260
#define TYPE_QUAL 261
#define CONSTANT 262
#define STRING 263
#define ELLIPSIS 264
#define SIZEOF 265
#define ENUM 266
#define STRUCT 267
#define UNION 268
#define IF 269
#define ELSE 270
#define WHILE 271
#define DO 272
#define FOR 273
#define SWITCH 274
#define CASE 275
#define DEFAULT 276
#define BREAK 277
#define CONTINUE 278
#define RETURN 279
#define GOTO 280
#define ASM_KEYWORD 281
#define TYPEOF 282
#define ALIGNOF 283
#define ATTRIBUTE 284
#define EXTENSION 285
#define LABEL 286
#define REALPART 287
#define IMAGPART 288
#define VA_ARG 289
#define END_OF_LINE 290
#define ASSIGN 291
#define OROR 292
#define ANDAND 293
#define EQCOMPARE 294
#define ARITHCOMPARE 295
#define LSHIFT 296
#define RSHIFT 297
#define UNARY 298
#define PLUSPLUS 299
#define MINUSMINUS 300
#define HYPERUNARY 301
#define POINTSAT 302
#define INTERFACE 303
#define IMPLEMENTATION 304
#define END 305
#define SELECTOR 306
#define DEFS 307
#define ENCODE 308
#define CLASSNAME 309
#define PUBLIC 310
#define PRIVATE 311
#define PROTECTED 312
#define PROTOCOL 313
#define OBJECTNAME 314
#define CLASS 315
#define ALIAS 316
#define OBJC_STRING 317
extern YYSTYPE yylval;

View file

@ -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

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -28,7 +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 66
%expect 73
%{
#include "config.h"
@ -157,7 +157,7 @@ const char * const language_string = "GNU Obj-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
@ -756,42 +756,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); }
@ -1709,9 +1704,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);
@ -1719,7 +1714,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);
@ -1727,7 +1722,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);
@ -1737,6 +1732,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