decl.c (grokdeclarator): Issue errors on namespace qualified declarators in parameter...
authorMark Mitchell <mark@markmitchell.com>
Wed, 12 Aug 1998 13:48:30 +0000 (13:48 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 12 Aug 1998 13:48:30 +0000 (13:48 +0000)
1998-08-12  Mark Mitchell  <mark@markmitchell.com>
* decl.c (grokdeclarator): Issue errors on namespace qualified
declarators in parameter lists or in class scope.

From-SVN: r21684

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

index a84a1a952b23dc88a6842d2e767d91b8050af501..fe7813b6d1df81a633c5293fbedb9ea19b6db7de 100644 (file)
@@ -1,3 +1,8 @@
+1998-08-12  Mark Mitchell  <mark@markmitchell.com>
+
+       * decl.c (grokdeclarator): Issue errors on namespace qualified
+       declarators in parameter lists or in class scope.
+
 1998-08-09  Mark Mitchell  <mark@markmitchell.com>
 
        * pt.c (check_explicit_specialization): Don't abort on bogus
index 1b70a1ba9151820378737ee192e8fbc2cd31c8cb..1fa4abf70d29fbf472e7fdc2719febe68d097fcf 100644 (file)
@@ -10125,7 +10125,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
 
     if (decl_context == PARM)
       {
-       if (ctype)
+       if (ctype || in_namespace)
          error ("cannot use `::' in parameter declaration");
 
        /* A parameter declared as an array of T is really a pointer to T.
@@ -10179,6 +10179,12 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
               are error_mark_node, for example.  */
            decl = NULL_TREE;
          }
+       else if (in_namespace)
+         {
+           /* Something like struct S { int N::j; };  */
+           cp_error ("invalid use of `::'");
+           decl = NULL_TREE;
+         }
        else if (TREE_CODE (type) == FUNCTION_TYPE)
          {
            int publicp = 0;
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/bogus1.C b/gcc/testsuite/g++.old-deja/g++.ns/bogus1.C
new file mode 100644 (file)
index 0000000..c61dea8
--- /dev/null
@@ -0,0 +1,10 @@
+// Build don't link:
+
+namespace N {}
+
+void f(int N::k); // ERROR - cannot use `::' in parameter declaration
+
+class Foo
+{
+  int N::j; // ERROR - invalid use of `::'
+};