public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/86342, -Wdeprecated-copy and system headers
@ 2018-06-28 20:54 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2018-06-28 20:54 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]

-Wdeprecated-copy shouldn't warn about classes that the user can't change.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 86342.diff --]
[-- Type: text/x-patch, Size: 1388 bytes --]

commit 8ca5b3176d0a79534b99bf0d53bb0467abb38800
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 28 15:41:20 2018 -0400

            PR c++/86342 - -Wdeprecated-copy and system headers.
    
            * decl2.c (cp_warn_deprecated_use): Don't warn about declarations
            in system headers.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 5fc6369d39d..e06ffa613b7 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -5208,8 +5208,10 @@ cp_warn_deprecated_use (tree decl, tsubst_flags_t complain)
       && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)
       && copy_fn_p (decl))
     {
-      warned = warning (OPT_Wdeprecated_copy,
-			"implicitly-declared %qD is deprecated", decl);
+      /* Don't warn about system library classes (c++/86342).  */
+      if (!DECL_IN_SYSTEM_HEADER (decl))
+	warned = warning (OPT_Wdeprecated_copy,
+			  "implicitly-declared %qD is deprecated", decl);
       if (warned)
 	{
 	  tree ctx = DECL_CONTEXT (decl);
diff --git a/gcc/testsuite/g++.dg/cpp0x/depr-copy2.C b/gcc/testsuite/g++.dg/cpp0x/depr-copy2.C
new file mode 100644
index 00000000000..cef18b63d4a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/depr-copy2.C
@@ -0,0 +1,17 @@
+// PR c++/86342
+// { dg-options -Wdeprecated-copy }
+
+# 1 "deprcopy.cc"
+# 1 "deprcopy.h" 1 3
+
+struct X {
+  X() { }
+  ~X() { }
+};
+# 2 "deprcopy.cc" 2
+
+int main()
+{
+  X x;
+  X y = x;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-06-28 20:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 20:54 C++ PATCH for c++/86342, -Wdeprecated-copy and system headers 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).