diff options
author | Volker Reichelt <reichelt@igpm.rwth-aachen.de> | 2005-12-23 17:10:37 +0000 |
---|---|---|
committer | Volker Reichelt <reichelt@gcc.gnu.org> | 2005-12-23 17:10:37 +0000 |
commit | 59e7c84ca11369f80c0b30c330544678a41aa54c (patch) | |
tree | 5db7ad6fdc64c09a233ef4189f70daca1d224e18 /gcc | |
parent | 41e8659ef1cd6f069608490882ddcc179634283e (diff) | |
download | gcc-59e7c84ca11369f80c0b30c330544678a41aa54c.zip gcc-59e7c84ca11369f80c0b30c330544678a41aa54c.tar.gz gcc-59e7c84ca11369f80c0b30c330544678a41aa54c.tar.bz2 |
decl.c (grokdeclarator): Improve diagnostic for friend declarations of class members.
* decl.c (grokdeclarator): Improve diagnostic for friend
declarations of class members.
* g++.dg/other/friend4.C: New test.
From-SVN: r109017
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/friend4.C | 8 |
4 files changed, 25 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5d90619..6a6090a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2005-12-23 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + + * decl.c (grokdeclarator): Improve diagnostic for friend + declarations of class members. + 2005-12-22 Mark Mitchell <mark@codesourcery.com> PR c++/25369 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 447e98d..8a7688e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7609,8 +7609,13 @@ grokdeclarator (const cp_declarator *declarator, } if (ctype == current_class_type) - pedwarn ("extra qualification %<%T::%> on member %qs", - ctype, name); + { + if (friendp) + pedwarn ("member functions are implicitly friends of their class"); + else + pedwarn ("extra qualification %<%T::%> on member %qs", + ctype, name); + } else if (TREE_CODE (type) == FUNCTION_TYPE) { tree sname = declarator->u.id.unqualified_name; @@ -8183,7 +8188,7 @@ grokdeclarator (const cp_declarator *declarator, { /* Friends are treated specially. */ if (ctype == current_class_type) - warning (0, "member functions are implicitly friends of their class"); + ; /* We already issued a pedwarn. */ else if (decl && DECL_NAME (decl)) { if (template_class_depth (current_class_type) == 0) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a61ab6f..3265ba5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-12-23 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + + * g++.dg/other/friend4.C: New test. + 2005-12-23 Jakub Jelinek <jakub@redhat.com> PR target/25005 diff --git a/gcc/testsuite/g++.dg/other/friend4.C b/gcc/testsuite/g++.dg/other/friend4.C new file mode 100644 index 0000000..537643d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend4.C @@ -0,0 +1,8 @@ +// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> +// Misleading diagnostic + +struct A +{ + friend void A::foo(); // { dg-error "implicitly friends" } + friend A::~A(); // { dg-error "implicitly friends" } +}; |