PR c++/86342 - -Wdeprecated-copy and system headers.
authorJason Merrill <jason@redhat.com>
Thu, 28 Jun 2018 20:22:21 +0000 (16:22 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 28 Jun 2018 20:22:21 +0000 (16:22 -0400)
* decl2.c (cp_warn_deprecated_use): Don't warn about declarations
in system headers.

From-SVN: r262231

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/g++.dg/cpp0x/depr-copy2.C [new file with mode: 0644]

index 040a84d021693cf1d6a0457622f36dc265005b79..862b7370b7e61242275597dc27e427d2f7df0456 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-28  Jason Merrill  <jason@redhat.com>
+
+       PR c++/86342 - -Wdeprecated-copy and system headers.
+       * decl2.c (cp_warn_deprecated_use): Don't warn about declarations
+       in system headers.
+
 2018-06-27  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/86329
index 5fc6369d39d93d5607ad1be5cd2dfbe784425ac0..e06ffa613b71171477383cfebf969fb6df527c7b 100644 (file)
@@ -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 (file)
index 0000000..cef18b6
--- /dev/null
@@ -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;
+}