re PR c++/16707 (ICE with using)
authorMark Mitchell <mark@codesourcery.com>
Mon, 2 Aug 2004 18:49:07 +0000 (18:49 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 2 Aug 2004 18:49:07 +0000 (18:49 +0000)
PR c++/16707
* name-lookup.c (validate_nonmember_using_decl): Robustify.

PR c++/16707
* g++.dg/lookup/using12.C: New test.

From-SVN: r85446

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/using12.C [new file with mode: 0644]

index 81a819a793167575e1b90f0894c7518ab69b00fa..d87b4827aee2fc5c695eecf84fa382be48404a5a 100644 (file)
@@ -1,3 +1,8 @@
+2004-08-02  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/16707
+       * name-lookup.c (validate_nonmember_using_decl): Robustify.
+
 2004-08-01  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/16224
index c44541285fb73ef850f2419225ddf816f05b3098..2859d8035b9fd95ff6887290f3f4c817ed96866d 100644 (file)
@@ -2115,6 +2115,17 @@ push_overloaded_decl (tree decl, int flags)
 static tree
 validate_nonmember_using_decl (tree decl, tree scope, tree name)
 {
+  /* [namespace.udecl]
+       A using-declaration for a class member shall be a
+       member-declaration.  */
+  if (TYPE_P (scope))
+    {
+      error ("`%T' is not a namespace", scope);
+      return NULL_TREE;
+    }
+  else if (scope == error_mark_node)
+    return NULL_TREE;
+
   if (TREE_CODE (decl) == TEMPLATE_ID_EXPR)
     {
       /* 7.3.3/5
@@ -2142,15 +2153,6 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name)
 
   my_friendly_assert (DECL_P (decl), 20020908);
 
-  /* [namespace.udecl]
-       A using-declaration for a class member shall be a
-       member-declaration.  */
-  if (TYPE_P (scope))
-    {
-      error ("`%T' is not a namespace", scope);
-      return NULL_TREE;
-    }
-
   /* Make a USING_DECL.  */
   return push_using_decl (scope, name);
 }
index 6a1dbc6d147f2b8e246405f3c0edd189c4f3761e..4ae35e2c75de0eda4ca13c730ed9f10be1f6a2de 100644 (file)
@@ -1,5 +1,8 @@
 2004-08-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/16707
+       * g++.dg/lookup/using12.C: New test.
+
        * g++.dg/init/null1.C: Fix PR number.
        * g++.dg/parse/namespace10.C: Likewise.
 
diff --git a/gcc/testsuite/g++.dg/lookup/using12.C b/gcc/testsuite/g++.dg/lookup/using12.C
new file mode 100644 (file)
index 0000000..0303855
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/16707
+
+int i;
+using N::i; // { dg-error "declared|expected" }