From b02922a4e3bcbb73a8c223a2a89ebc82f70314ab Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 13 Nov 2001 21:05:57 +0000 Subject: [PATCH] re PR c++/4206 (ICE with switch in while) cp: PR g++/4206 * parse.y (already_scoped_stmt): Remove. (simple_stmt, WHILE & FOR): Use implicitly_scoped_stmt. testsuite: * g++.dg/other/forscope1.C: New test. * g++.dg/ext/forscope1.C: New test. * g++.dg/ext/forscope2.C: New test. From-SVN: r46992 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parse.y | 14 ++----------- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/ext/forscope1.C | 27 ++++++++++++++++++++++++++ gcc/testsuite/g++.dg/ext/forscope2.C | 27 ++++++++++++++++++++++++++ gcc/testsuite/g++.dg/other/forscope1.C | 25 ++++++++++++++++++++++++ 6 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/forscope1.C create mode 100644 gcc/testsuite/g++.dg/ext/forscope2.C create mode 100644 gcc/testsuite/g++.dg/other/forscope1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f7b629626cd2..688a55be19fb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2001-11-13 Nathan Sidwell + + PR g++/4206 + * parse.y (already_scoped_stmt): Remove. + (simple_stmt, WHILE & FOR): Use implicitly_scoped_stmt. + 2001-11-12 H.J. Lu * cp/cvt.c (ocp_convert): Don't warn the address of a weak diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 1cf00209028d..12e8e2634b57 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -1187,16 +1187,6 @@ compstmtend: | maybe_label_decls error '}' ; -already_scoped_stmt: - save_lineno '{' - { $$ = begin_compound_stmt (1); } - compstmtend - { STMT_LINENO ($3) = $1; - finish_compound_stmt (1, $3); } - | save_lineno simple_stmt - { if ($2) STMT_LINENO ($2) = $1; } - ; - nontrivial_exprlist: expr_no_commas ',' expr_no_commas { $$ = tree_cons (NULL_TREE, $$, @@ -3394,7 +3384,7 @@ simple_stmt: } paren_cond_or_null { finish_while_stmt_cond ($3, $2); } - already_scoped_stmt + implicitly_scoped_stmt { $$ = $2; finish_while_stmt ($2); } | DO @@ -3415,7 +3405,7 @@ simple_stmt: { finish_for_cond ($6, $2); } xexpr ')' { finish_for_expr ($9, $2); } - already_scoped_stmt + implicitly_scoped_stmt { $$ = $2; finish_for_stmt ($2); } | SWITCH diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f52f1b8c4395..41e0aaca4564 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2001-11-13 Nathan Sidwell + + * g++.dg/other/forscope1.C: New test. + * g++.dg/ext/forscope1.C: New test. + * g++.dg/ext/forscope2.C: New test. + 2001-11-13 Jakub Jelinek * gcc.c-torture/execute/20011113-1.c: New test. diff --git a/gcc/testsuite/g++.dg/ext/forscope1.C b/gcc/testsuite/g++.dg/ext/forscope1.C new file mode 100644 index 000000000000..fa6401a3b943 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/forscope1.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options -fno-for-scope } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Sept 2001 + +// Bug 4206. We were nesting SCOPE_STMTs badly. + + +struct A +{ + A (); + ~A (); +}; + + +void Go( ) +{ + for (int i = 1;;) + { + switch (1) { + default: {} + } + A d; + } + i; +} diff --git a/gcc/testsuite/g++.dg/ext/forscope2.C b/gcc/testsuite/g++.dg/ext/forscope2.C new file mode 100644 index 000000000000..b883effb2552 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/forscope2.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options -fpermissive } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Sept 2001 + +// Bug 4206. We were nesting SCOPE_STMTs badly. + + +struct A +{ + A (); + ~A (); +}; + + +void Go( ) +{ + for (int i = 1;;) // { dg-warning "using obsolete binding" "" } + { + switch (1) { + default: {} + } + A d; + } + i; // { dg-warning "name lookup" "" } +} diff --git a/gcc/testsuite/g++.dg/other/forscope1.C b/gcc/testsuite/g++.dg/other/forscope1.C new file mode 100644 index 000000000000..e694d6f23326 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/forscope1.C @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Sept 2001 + +// Bug 4206. We were nesting SCOPE_STMTs badly. + +struct A +{ + A (); + ~A (); +}; + + +void Go( ) +{ + while (1) + { + switch (1) { + default: {} + } + A d; + } + +}