aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-05-18 16:02:48 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-05-18 16:02:48 -0400
commitb46b715d5b838d9869f89d3594ebf7d0b7cb374c (patch)
tree5684d331d1a9d9e995bb252f9febf8e86618a0a5 /gcc/testsuite/g++.dg
parentf07c22376848e9923aa8455d2c0a059d9d0e01d5 (diff)
downloadgcc-b46b715d5b838d9869f89d3594ebf7d0b7cb374c.zip
gcc-b46b715d5b838d9869f89d3594ebf7d0b7cb374c.tar.gz
gcc-b46b715d5b838d9869f89d3594ebf7d0b7cb374c.tar.bz2
PR c++/58407 - deprecated implicit copy ops.
gcc/c-family/ * c.opt (Wdeprecated-copy): New flag. gcc/cp/ * call.c (build_over_call): Warn about deprecated trivial fns. * class.c (classtype_has_user_copy_or_dtor): New. (type_build_ctor_call): Check TREE_DEPRECATED. (type_build_dtor_call): Likewise. * decl2.c (cp_warn_deprecated_use): Move from tree.c. Add checks. Return bool. Handle -Wdeprecated-copy. (mark_used): Use it. * decl.c (grokdeclarator): Remove redundant checks. * typeck2.c (build_functional_cast): Likewise. * method.c (lazily_declare_fn): Mark deprecated copy ops. * init.c (build_aggr_init): Only set TREE_USED if there are side-effects. libitm/ * beginend.cc (save): Disable -Werror=deprecated-copy. From-SVN: r260381
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/depr-copy1.C29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/depr-copy1.C b/gcc/testsuite/g++.dg/cpp0x/depr-copy1.C
new file mode 100644
index 0000000..d33c6dc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/depr-copy1.C
@@ -0,0 +1,29 @@
+/* [depr.impldec] The implicit definition of a copy constructor as defaulted is
+ deprecated if the class has a user-declared copy assignment operator or a
+ user-declared destructor. The implicit definition of a copy assignment
+ operator as defaulted is deprecated if the class has a user-declared copy
+ constructor or a user-declared destructor (15.4, 15.8). In a future revision
+ of this International Standard, these implicit definitions could become
+ deleted (11.4). */
+
+// { dg-additional-options -Wdeprecated-copy }
+
+struct X
+{
+ X();
+ X(const X&);
+};
+struct A
+{
+ X x;
+ ~A();
+};
+
+void f(bool b)
+{
+ A a;
+ if (b)
+ throw A(); // Don't warn about elided copy
+ A a2 = A(); // Here either.
+ A a3 (a); // { dg-warning "deprecated" "" { target c++11 } }
+}