Commit 59e7c84c by Volker Reichelt Committed by Volker Reichelt

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
parent 41e8659e
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> 2005-12-22 Mark Mitchell <mark@codesourcery.com>
PR c++/25369 PR c++/25369
......
...@@ -7609,8 +7609,13 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -7609,8 +7609,13 @@ grokdeclarator (const cp_declarator *declarator,
} }
if (ctype == current_class_type) 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) else if (TREE_CODE (type) == FUNCTION_TYPE)
{ {
tree sname = declarator->u.id.unqualified_name; tree sname = declarator->u.id.unqualified_name;
...@@ -8183,7 +8188,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -8183,7 +8188,7 @@ grokdeclarator (const cp_declarator *declarator,
{ {
/* Friends are treated specially. */ /* Friends are treated specially. */
if (ctype == current_class_type) 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)) else if (decl && DECL_NAME (decl))
{ {
if (template_class_depth (current_class_type) == 0) if (template_class_depth (current_class_type) == 0)
......
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> 2005-12-23 Jakub Jelinek <jakub@redhat.com>
PR target/25005 PR target/25005
// 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" }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment