diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a84a1a952b2..fe7813b6d1d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1998-08-12 Mark Mitchell + + * decl.c (grokdeclarator): Issue errors on namespace qualified + declarators in parameter lists or in class scope. + 1998-08-09 Mark Mitchell * pt.c (check_explicit_specialization): Don't abort on bogus diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1b70a1ba915..1fa4abf70d2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 index 00000000000..c61dea8e77e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/bogus1.C @@ -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 `::' +};