PR c++/78749 - friend in anonymous namespace
authorJason Merrill <jason@redhat.com>
Wed, 21 Dec 2016 18:28:54 +0000 (13:28 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 21 Dec 2016 18:28:54 +0000 (13:28 -0500)
* decl.c (wrapup_globals_for_namespace): Don't complain about friend
pseudo-template instantiations.

From-SVN: r243862

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/warn/Wunused-function3.C [new file with mode: 0644]

index 757bcef99d50c794a26a7d10c67f1c13efcdc2d5..c4c51719374758b8f6f7bad907ea3ae9802ac35d 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/78749 - friend in anonymous namespace
+       * decl.c (wrapup_globals_for_namespace): Don't complain about friend
+       pseudo-template instantiations.
+
 2016-12-16  Richard Biener  <rguenther@suse.de>
 
        PR c++/71694
index e83b542d424d698414f2835d771676a4dd42d0a4..295416051b709b5428cf1d58d0631568cfa55fe7 100644 (file)
@@ -926,6 +926,7 @@ wrapup_globals_for_namespace (tree name_space, void* data ATTRIBUTE_UNUSED)
            && DECL_EXTERNAL (decl)
            && !TREE_PUBLIC (decl)
            && !DECL_ARTIFICIAL (decl)
+           && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl)
            && !TREE_NO_WARNING (decl))
          {
            warning_at (DECL_SOURCE_LOCATION (decl),
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-function3.C b/gcc/testsuite/g++.dg/warn/Wunused-function3.C
new file mode 100644 (file)
index 0000000..94c9025
--- /dev/null
@@ -0,0 +1,11 @@
+// { dg-options -Wunused-function }
+
+namespace
+{
+  template <class T> struct A
+  {
+    friend void f(A) { }
+  };
+
+  A<int> a;
+}