public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: bogus warning w/ deduction guide in anon ns [PR106604]
@ 2023-08-10 16:09 Patrick Palka
  2023-08-10 17:22 ` Jason Merrill
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick Palka @ 2023-08-10 16:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, Patrick Palka

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-11 14:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-10 16:09 [PATCH] c++: bogus warning w/ deduction guide in anon ns [PR106604] Patrick Palka
2023-08-10 17:22 ` Jason Merrill
2023-08-10 20:40   ` Patrick Palka
2023-08-10 21:11     ` Jason Merrill
2023-08-11 13:54       ` Patrick Palka
2023-08-11 14:00         ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).