diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1995-08-31 18:38:14 -0400 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1995-08-31 18:38:14 -0400 |
commit | 28a19afce3adc9b0ad44346c8de63577e0e670f2 (patch) | |
tree | 04b371574536768984255faffbc0604fdd0af694 /gcc | |
parent | f4eed9e2c57990dedd7b1b6f912cfc3175cbf917 (diff) | |
download | gcc-28a19afce3adc9b0ad44346c8de63577e0e670f2.zip gcc-28a19afce3adc9b0ad44346c8de63577e0e670f2.tar.gz gcc-28a19afce3adc9b0ad44346c8de63577e0e670f2.tar.bz2 |
(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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-parse.in | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in index c3c85d4..4d63f61 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -103,7 +103,7 @@ void yyerror (); %start program %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 and are not declared typedefs in the current block */ @@ -210,6 +210,8 @@ void yyerror (); %type <itype> setspecs +%type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label + %type <filename> save_filename %type <lineno> save_lineno @@ -1557,9 +1559,19 @@ absdcl1: /* a nonempty absolute declarator */ is actually regarded as an invalid decl and part of the decls. */ 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 - | stmts lineno_stmt_or_label - | stmts errstmt + | lineno_stmt_or_labels lineno_stmt_or_label + { $$ = $2; } + | lineno_stmt_or_labels errstmt + { $$ = 0; } ; xstmts: @@ -1699,19 +1711,14 @@ lineno_labeled_stmt: lineno_stmt_or_label: save_filename save_lineno stmt_or_label - { } + { $$ = $3; } ; stmt_or_label: stmt + { $$ = 0; } | label - { int next; - position_after_white_space (); - next = getc (finput); - ungetc (next, finput); - if (pedantic && next == '}') - pedwarn ("ANSI C forbids label at end of compound statement"); - } + { $$ = 1; } ; /* Parse a single real statement, not including any labels. */ |