aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-parse.in
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-11-18 23:18:36 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2000-11-18 23:18:36 +0000
commit77c4d6c06a83f7d86471befb76a1be433dc2e3a3 (patch)
treeb4a745279c572b08d93715d1c76a506422218e89 /gcc/c-parse.in
parentce7d4fc8dd42a1885bc22d1c720c6c94314acad1 (diff)
downloadgcc-77c4d6c06a83f7d86471befb76a1be433dc2e3a3.zip
gcc-77c4d6c06a83f7d86471befb76a1be433dc2e3a3.tar.gz
gcc-77c4d6c06a83f7d86471befb76a1be433dc2e3a3.tar.bz2
c-decl.c (check_for_loop_decls): New function.
* c-decl.c (check_for_loop_decls): New function. * c-parse.in (for_init_stmt): New. (select_or_iter_stmt): Use for_init_stmt. * c-tree.h (check_for_loop_decls): New declaration. testsuite: * gcc.dg/c90-fordecl-1.c, gcc.dg/c99-fordecl-1.c, gcc.dg/c99-fordecl-2.c: New tests. From-SVN: r37549
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r--gcc/c-parse.in24
1 files changed, 15 insertions, 9 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index ae47466..517b488 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -1868,19 +1868,18 @@ select_or_iter_stmt:
| do_stmt_start error
{ }
| FOR
- '(' xexpr ';'
- { stmt_count++;
- $3 = build_stmt (EXPR_STMT, $3);
- $<ttype>$ = build_stmt (FOR_STMT, $3, NULL_TREE,
+ { $<ttype>$ = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
NULL_TREE, NULL_TREE);
- add_stmt ($<ttype>$);
- }
+ add_stmt ($<ttype>$); }
+ '(' for_init_stmt
+ { stmt_count++;
+ RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
xexpr ';'
- { FOR_COND ($<ttype>5) = $6; }
+ { FOR_COND ($<ttype>2) = $6; }
xexpr ')'
- { FOR_EXPR ($<ttype>5) = $9; }
+ { FOR_EXPR ($<ttype>2) = $9; }
c99_block_lineno_labeled_stmt
- { RECHAIN_STMTS ($<ttype>5, FOR_BODY ($<ttype>5)); }
+ { RECHAIN_STMTS ($<ttype>2, FOR_BODY ($<ttype>2)); }
| SWITCH '(' expr ')'
{ stmt_count++;
$<ttype>$ = c_start_case ($3); }
@@ -1888,6 +1887,13 @@ select_or_iter_stmt:
{ c_finish_case (); }
;
+for_init_stmt:
+ xexpr ';'
+ { add_stmt (build_stmt (EXPR_STMT, $1)); }
+ | decl
+ { check_for_loop_decls (); }
+ ;
+
/* Parse a single real statement, not including any labels. */
stmt:
compstmt