]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (grokdeclarator): Improve diagnostic for friend declarations of class members.
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Fri, 23 Dec 2005 17:10:37 +0000 (17:10 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Fri, 23 Dec 2005 17:10:37 +0000 (17:10 +0000)
* decl.c (grokdeclarator): Improve diagnostic for friend
declarations of class members.

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

From-SVN: r109017

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

index 5d906193e733d28b06116c4ad17984c7d3d7b9af..6a6090a8af8b8a7617a6b3f7eeddd81d14dd4c67 100644 (file)
@@ -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
index 447e98dd0cc7ee8c383142482bd7fbcbfb179f80..8a7688ec7137e46762d74b2c289003dfe72f848a 100644 (file)
@@ -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)
index a61ab6f185db346b64f76d4a406d90090be4f7a9..3265ba5168c3d1ab064ff5f8cf2905c9dfb08932 100644 (file)
@@ -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 (file)
index 0000000..537643d
--- /dev/null
@@ -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" }
+};