Patchwork C++ PATCH for c++/50742 (ICE on switch with local using-decl)

login
register
mail settings
Submitter Jason Merrill
Date Oct. 18, 2011, 5:37 p.m.
Message ID <4E9DB95F.3000903@redhat.com>
Download mbox | patch
Permalink /patch/120472/
State New
Headers show

Comments

Jason Merrill - Oct. 18, 2011, 5:37 p.m.
A using-declaration adds a TREE_LIST to the list of names on a binding 
level, so we need to cope with that here.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 052e893fe307f33ca3d3c2ead06248e0ef738f16
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Oct 17 22:04:08 2011 -0400

    	PR c++/50742
    	* decl.c (check_previous_goto_1): Handle using-decl.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8b5033f..4b5b6c8 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2683,7 +2683,8 @@  check_previous_goto_1 (tree decl, cp_binding_level* level, tree names,
       tree new_decls, old_decls = (b == level ? names : NULL_TREE);
 
       for (new_decls = b->names; new_decls != old_decls;
-	   new_decls = DECL_CHAIN (new_decls))
+	   new_decls = (DECL_P (new_decls) ? DECL_CHAIN (new_decls)
+			: TREE_CHAIN (new_decls)))
 	{
 	  int problem = decl_jump_unsafe (new_decls);
 	  if (! problem)
diff --git a/gcc/testsuite/g++.dg/lookup/using23.C b/gcc/testsuite/g++.dg/lookup/using23.C
new file mode 100644
index 0000000..5dd8d85
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/using23.C
@@ -0,0 +1,13 @@ 
+// PR c++/50742
+
+typedef int A;
+
+void f(int i)
+{
+  switch (i)
+    {
+    case 0:
+      using ::A;
+    default:;
+    }
+}