Booststrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk and perhaps 13?
-- >8 -- We shouldn't issue a "declared static but never defined" warning for a deduction guide (declared in an anonymous namespace). PR c++/106604 gcc/cp/ChangeLog: * decl.cc (wrapup_namespace_globals): Don't issue a -Wunused-function warning for a deduction guide. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction116.C: New test. --- gcc/cp/decl.cc | 1 + gcc/testsuite/g++.dg/cpp1z/class-deduction116.C | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/class-deduction116.C diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 792ab330dd0..9fe3a0b98fd 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -856,6 +856,7 @@ wrapup_namespace_globals () && !TREE_PUBLIC (decl) && !DECL_ARTIFICIAL (decl) && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl) + && !deduction_guide_p (decl) && !warning_suppressed_p (decl, OPT_Wunused_function)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_function, diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction116.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction116.C new file mode 100644 index 00000000000..00f6d5fef41 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction116.C @@ -0,0 +1,8 @@ +// PR c++/106604 +// { dg-do compile { target c++17 } } +// { dg-additional-options "-Wunused-function" } + +namespace { + template<class T> struct A { A(...); }; + A(bool) -> A<bool>; // { dg-bogus "never defined" } +} -- 2.42.0.rc0.25.ga82fb66fed