PR c++/22293
authorreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Oct 2005 16:20:55 +0000 (16:20 +0000)
committerreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Oct 2005 16:20:55 +0000 (16:20 +0000)
* decl.c (grokdeclarator): Reject unqualified destructors in
friend declarations.

* g++.dg/other/friend3.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105564 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/friend3.C [new file with mode: 0644]

index 4c79e89..e7c259d 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-18  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/22293
+       * decl.c (grokdeclarator): Reject unqualified destructors in
+       friend declarations.
+
 2005-10-18  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/23293
index 982fe12..8958850 100644 (file)
@@ -8021,15 +8021,25 @@ grokdeclarator (const cp_declarator *declarator,
              }
 
            /* Check that the name used for a destructor makes sense.  */
-           if (sfk == sfk_destructor
-               && !same_type_p (TREE_OPERAND
-                                (id_declarator->u.id.unqualified_name, 0),
-                                ctype))
+           if (sfk == sfk_destructor)
              {
-               error ("declaration of %qD as member of %qT",
-                      id_declarator->u.id.unqualified_name,
-                      ctype);
-               return error_mark_node;
+               if (!ctype)
+                 {
+                   gcc_assert (friendp);
+                   error ("expected qualified name in friend declaration "
+                          "for destructor %qD",
+                          id_declarator->u.id.unqualified_name);
+                   return error_mark_node;
+                 }
+
+               if (!same_type_p (TREE_OPERAND
+                                 (id_declarator->u.id.unqualified_name, 0),
+                                 ctype))
+                 {
+                   error ("declaration of %qD as member of %qT",
+                          id_declarator->u.id.unqualified_name, ctype);
+                   return error_mark_node;
+                 }
              }
 
            /* Tell grokfndecl if it needs to set TREE_PUBLIC on the node.  */
index f212358..6ba9056 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-18  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/22293
+       * g++.dg/other/friend3.C: New test.
+
 2005-10-18  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/23293
diff --git a/gcc/testsuite/g++.dg/other/friend3.C b/gcc/testsuite/g++.dg/other/friend3.C
new file mode 100644 (file)
index 0000000..ce872e5
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/22293
+// Origin: Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+// { dg-do compile }
+
+struct A
+{
+  friend ~A();  // { dg-error "qualified name" }
+};
+
+struct B
+{
+  friend ~A();  // { dg-error "qualified name" }
+};