re PR c++/4206 (ICE with switch in while)
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 13 Nov 2001 21:05:57 +0000 (21:05 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 13 Nov 2001 21:05:57 +0000 (21:05 +0000)
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
gcc/cp/parse.y
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/forscope1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/forscope2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/forscope1.C [new file with mode: 0644]

index f7b629626cd26390ab9104aeba414b2f1fea417c..688a55be19fb8356ed5a86d874728aff617762a9 100644 (file)
@@ -1,3 +1,9 @@
+2001-11-13  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR g++/4206
+       * parse.y (already_scoped_stmt): Remove.
+       (simple_stmt, WHILE & FOR): Use implicitly_scoped_stmt.
+
 2001-11-12  H.J. Lu <hjl@gnu.org>
 
        * cp/cvt.c (ocp_convert): Don't warn the address of a weak
index 1cf00209028ddfc9965b2d23095e21199486b176..12e8e2634b57e7663a1b750cd5599a33438e1ab7 100644 (file)
@@ -1187,16 +1187,6 @@ compstmtend:
        | maybe_label_decls error '}'
        ;
 
-already_scoped_stmt:
-         save_lineno '{'
-               { $<ttype>$ =  begin_compound_stmt (1); }
-         compstmtend
-               { STMT_LINENO ($<ttype>3) = $1;
-                 finish_compound_stmt (1, $<ttype>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, $<ttype>2); }
-         already_scoped_stmt
+         implicitly_scoped_stmt
                 { $$ = $<ttype>2;
                  finish_while_stmt ($<ttype>2); }
        | DO
@@ -3415,7 +3405,7 @@ simple_stmt:
                 { finish_for_cond ($6, $<ttype>2); }
          xexpr ')'
                 { finish_for_expr ($9, $<ttype>2); }
-         already_scoped_stmt
+         implicitly_scoped_stmt
                 { $$ = $<ttype>2;
                  finish_for_stmt ($<ttype>2); }
        | SWITCH 
index f52f1b8c4395ba1511e215c505c3f3f54ab2332c..41e0aaca45640ed2646c2a7fd3c40e1ef0d6bb7f 100644 (file)
@@ -1,3 +1,9 @@
+2001-11-13  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * 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  <jakub@redhat.com>
 
        * 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 (file)
index 0000000..fa6401a
--- /dev/null
@@ -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 <nathan@codesourcery.com>
+
+// 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 (file)
index 0000000..b883eff
--- /dev/null
@@ -0,0 +1,27 @@
+// { dg-do compile }
+// { dg-options -fpermissive }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 Sept 2001 <nathan@codesourcery.com>
+
+// 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 (file)
index 0000000..e694d6f
--- /dev/null
@@ -0,0 +1,25 @@
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 Sept 2001 <nathan@codesourcery.com>
+
+// Bug 4206. We were nesting SCOPE_STMTs badly.
+
+struct A
+{
+  A ();
+  ~A ();
+};
+
+
+void Go( )
+{
+  while (1)
+    {
+      switch (1) {
+      default: {}
+      }
+      A d;
+    }
+  
+}