From 05008fb97d0b9316c8c4a453d6fbd3948c869442 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Wed, 12 Aug 1998 13:48:30 +0000 Subject: [PATCH] decl.c (grokdeclarator): Issue errors on namespace qualified declarators in parameter lists or in class... 1998-08-12 Mark Mitchell * decl.c (grokdeclarator): Issue errors on namespace qualified declarators in parameter lists or in class scope. From-SVN: r21684 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 8 +++++++- gcc/testsuite/g++.old-deja/g++.ns/bogus1.C | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.ns/bogus1.C 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 `::' +};