decl2.c (validate_nonmember_using_decl): Complain about using declarations for class...
authorMark Mitchell <mark@markmitchell.com>
Wed, 2 Dec 1998 10:12:20 +0000 (10:12 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 2 Dec 1998 10:12:20 +0000 (10:12 +0000)
* decl2.c (validate_nonmember_using_decl): Complain about using
declarations for class members.

From-SVN: r24060

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/g++.old-deja/g++.ns/using11.C [new file with mode: 0644]

index 3cfe70127199859ba3a5a592b4468a42c11f84e5..336e694d8760b3578ae6917de3ae987b949b4d37 100644 (file)
@@ -1,3 +1,8 @@
+1998-12-02  Mark Mitchell  <mark@markmitchell.com>
+
+       * decl2.c (validate_nonmember_using_decl): Complain about using
+       declarations for class members.
+
 1998-11-29  Jason Merrill  <jason@yorick.cygnus.com>
 
        * typeck2.c (process_init_constructor): Use same_type_p.
index e57a6af1ee0e92ed67f11fc9ce8b05a368d0d205..cf9df28ba0c2f62affc127074af3f40dab3a9abe 100644 (file)
@@ -4690,6 +4690,16 @@ validate_nonmember_using_decl (decl, scope, name)
     {
       *scope = TREE_OPERAND (decl, 0);
       *name = TREE_OPERAND (decl, 1);
+
+      /* [namespace.udecl]
+
+        A using-declaration for a class member shall be a
+        member-declaration.  */
+      if (TREE_CODE (*scope) != NAMESPACE_DECL)
+       {
+         cp_error ("`%D' is not a namespace", *scope);
+         return NULL_TREE;
+       }
     }
   else if (TREE_CODE (decl) == IDENTIFIER_NODE
            || TREE_CODE (decl) == TYPE_DECL
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using11.C b/gcc/testsuite/g++.old-deja/g++.ns/using11.C
new file mode 100644 (file)
index 0000000..23943f2
--- /dev/null
@@ -0,0 +1,9 @@
+// Build don't link:
+
+class joey {
+public:
+  typedef int SVec;
+};
+
+using joey::SVec; // ERROR - joey is not a namespace
+