Commit 28a19afc by Richard Kenner

(ends_in_label): New %union member.

(stmts, stmt_or_label): Use new member to avoid lexical lookahead hack.
(lineno_stmt_or_labels): New rule.
(lineno_stmt_or_label, stmt_or_label): Yield nonzero if it ends in a label.

From-SVN: r10302
parent f4eed9e2
...@@ -103,7 +103,7 @@ void yyerror (); ...@@ -103,7 +103,7 @@ void yyerror ();
%start program %start program
%union {long itype; tree ttype; enum tree_code code; %union {long itype; tree ttype; enum tree_code code;
char *filename; int lineno; } char *filename; int lineno; int ends_in_label; }
/* All identifiers that are not reserved words /* All identifiers that are not reserved words
and are not declared typedefs in the current block */ and are not declared typedefs in the current block */
...@@ -210,6 +210,8 @@ void yyerror (); ...@@ -210,6 +210,8 @@ void yyerror ();
%type <itype> setspecs %type <itype> setspecs
%type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
%type <filename> save_filename %type <filename> save_filename
%type <lineno> save_lineno %type <lineno> save_lineno
...@@ -1557,9 +1559,19 @@ absdcl1: /* a nonempty absolute declarator */ ...@@ -1557,9 +1559,19 @@ absdcl1: /* a nonempty absolute declarator */
is actually regarded as an invalid decl and part of the decls. */ is actually regarded as an invalid decl and part of the decls. */
stmts: stmts:
lineno_stmt_or_labels
{
if (pedantic && $1)
pedwarn ("ANSI C forbids label at end of compound statement");
}
;
lineno_stmt_or_labels:
lineno_stmt_or_label lineno_stmt_or_label
| stmts lineno_stmt_or_label | lineno_stmt_or_labels lineno_stmt_or_label
| stmts errstmt { $$ = $2; }
| lineno_stmt_or_labels errstmt
{ $$ = 0; }
; ;
xstmts: xstmts:
...@@ -1699,19 +1711,14 @@ lineno_labeled_stmt: ...@@ -1699,19 +1711,14 @@ lineno_labeled_stmt:
lineno_stmt_or_label: lineno_stmt_or_label:
save_filename save_lineno stmt_or_label save_filename save_lineno stmt_or_label
{ } { $$ = $3; }
; ;
stmt_or_label: stmt_or_label:
stmt stmt
{ $$ = 0; }
| label | label
{ int next; { $$ = 1; }
position_after_white_space ();
next = getc (finput);
ungetc (next, finput);
if (pedantic && next == '}')
pedwarn ("ANSI C forbids label at end of compound statement");
}
; ;
/* Parse a single real statement, not including any labels. */ /* Parse a single real statement, not including any labels. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment