diff options
author | Volker Reichelt <reichelt@igpm.rwth-aachen.de> | 2005-10-18 16:20:55 +0000 |
---|---|---|
committer | Volker Reichelt <reichelt@gcc.gnu.org> | 2005-10-18 16:20:55 +0000 |
commit | 6d2989e11752934162a82ed4718298f3f8a47bfe (patch) | |
tree | e0d29138a0ec4f4daa1df0f1faa9074d14b7041d /gcc | |
parent | 685e39c289c014c395367c0146e51225e0521b31 (diff) | |
download | gcc-6d2989e11752934162a82ed4718298f3f8a47bfe.zip gcc-6d2989e11752934162a82ed4718298f3f8a47bfe.tar.gz gcc-6d2989e11752934162a82ed4718298f3f8a47bfe.tar.bz2 |
re PR c++/22293 (ICE declaring destructor as friend)
PR c++/22293
* decl.c (grokdeclarator): Reject unqualified destructors in
friend declarations.
* g++.dg/other/friend3.C: New test.
From-SVN: r105564
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 26 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/friend3.C | 13 |
4 files changed, 42 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4c79e89..e7c259d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 982fe12..8958850 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f212358..6ba9056 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..ce872e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend3.C @@ -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" } +}; |