aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
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/cp/class.c
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/cp/class.c')
-rw-r--r--gcc/cp/class.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 306ee29..4960b4b 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5171,6 +5171,40 @@ classtype_has_move_assign_or_move_ctor_p (tree t, bool user_p)
return false;
}
+/* If T, a class, has a user-provided copy constructor, copy assignment
+ operator, or destructor, returns that function. Otherwise, null. */
+
+tree
+classtype_has_user_copy_or_dtor (tree t)
+{
+ if (!CLASSTYPE_LAZY_COPY_CTOR (t))
+ for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
+ {
+ tree fn = *iter;
+ if (user_provided_p (fn) && copy_fn_p (fn))
+ return fn;
+ }
+
+ if (!CLASSTYPE_LAZY_COPY_ASSIGN (t))
+ for (ovl_iterator iter (get_class_binding_direct
+ (t, assign_op_identifier));
+ iter; ++iter)
+ {
+ tree fn = *iter;
+ if (user_provided_p (fn) && copy_fn_p (fn))
+ return fn;
+ }
+
+ if (!CLASSTYPE_LAZY_DESTRUCTOR (t))
+ {
+ tree fn = CLASSTYPE_DESTRUCTOR (t);
+ if (user_provided_p (fn))
+ return fn;
+ }
+
+ return NULL_TREE;
+}
+
/* Nonzero if we need to build up a constructor call when initializing an
object of this class, either because it has a user-declared constructor
or because it doesn't have a default constructor (so we need to give an
@@ -5201,6 +5235,7 @@ type_build_ctor_call (tree t)
{
tree fn = *iter;
if (!DECL_ARTIFICIAL (fn)
+ || TREE_DEPRECATED (fn)
|| DECL_DELETED_FN (fn))
return true;
}
@@ -5228,6 +5263,7 @@ type_build_dtor_call (tree t)
{
tree fn = *iter;
if (!DECL_ARTIFICIAL (fn)
+ || TREE_DEPRECATED (fn)
|| DECL_DELETED_FN (fn))
return true;
}