aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2006-08-25 17:03:50 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2006-08-25 17:03:50 +0000
commit2884e22c4b89b5a12977743bede11cde3a781316 (patch)
treea2988c448d8b37ffa24849355e13f63dc860b19d /gcc
parent7d3bec9db50a2d46f697ad621edd50165e51c168 (diff)
downloadgcc-2884e22c4b89b5a12977743bede11cde3a781316.zip
gcc-2884e22c4b89b5a12977743bede11cde3a781316.tar.gz
gcc-2884e22c4b89b5a12977743bede11cde3a781316.tar.bz2
re PR c++/28056 (enum accepted as scope)
PR c++/28056 * decl.c (grokdeclarator): Disallow declarations with qualified names in local scopes. PR c++/28056 * g++.dg/parse/local1.C: New test. From-SVN: r116410
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c22
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/other/qual1.C2
-rw-r--r--gcc/testsuite/g++.dg/parse/local1.C18
5 files changed, 51 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 629ba67..24fbf9a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-25 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/28056
+ * decl.c (grokdeclarator): Disallow declarations with qualified
+ names in local scopes.
+
2006-08-25 Nathan Sidwell <nathan@codesourcery.com>
PR c++/27787
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8ba2a13..2d69cdb 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6948,7 +6948,27 @@ grokdeclarator (const cp_declarator *declarator,
break;
if (qualifying_scope)
{
- if (TYPE_P (qualifying_scope))
+ if (at_function_scope_p ())
+ {
+ /* [dcl.meaning]
+
+ A declarator-id shall not be qualified except
+ for ...
+
+ None of the cases are permitted in block
+ scope. */
+ if (qualifying_scope == global_namespace)
+ error ("invalid use of qualified-name %<::%D%>",
+ decl);
+ else if (TYPE_P (qualifying_scope))
+ error ("invalid use of qualified-name %<%T::%D%>",
+ qualifying_scope, decl);
+ else
+ error ("invalid use of qualified-name %<%D::%D%>",
+ qualifying_scope, decl);
+ return error_mark_node;
+ }
+ else if (TYPE_P (qualifying_scope))
{
ctype = qualifying_scope;
if (innermost_code != cdk_function
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8e9e60a..ee47bb3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-08-25 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/28056
+ * g++.dg/parse/local1.C: New test.
+
2006-08-25 Nathan Sidwell <nathan@codesourcery.com>
PR c++/27787
diff --git a/gcc/testsuite/g++.dg/other/qual1.C b/gcc/testsuite/g++.dg/other/qual1.C
index bd6f234..e4bae23 100644
--- a/gcc/testsuite/g++.dg/other/qual1.C
+++ b/gcc/testsuite/g++.dg/other/qual1.C
@@ -6,6 +6,6 @@ struct A
int i;
void foo()
{
- int A::i = i; // { dg-error "extra qualification|not a static member" }
+ int A::i = i; // { dg-error "qualified" }
}
};
diff --git a/gcc/testsuite/g++.dg/parse/local1.C b/gcc/testsuite/g++.dg/parse/local1.C
new file mode 100644
index 0000000..cfcffc9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/local1.C
@@ -0,0 +1,18 @@
+// PR c++/28056
+
+void f1();
+
+namespace N {
+ void f2();
+}
+
+class C {
+ static void f3();
+};
+
+void foo() {
+ void ::f1(); // { dg-error "qualified" }
+ void N::f2(); // { dg-error "qualified" }
+ void C::f3(); // { dg-error "qualified" }
+ void ::f4(); // { dg-error "qualified" }
+}