From fd85b88869cca061959582783d5ec75b0da8b1d7 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Wed, 24 Oct 2018 18:06:14 +0000 Subject: [PATCH] PR c++/84851 - missing -Wclass-memaccess for a memcpy in a copy ctor with a non-trivial member gcc/cp/ChangeLog: PR c++/84851 * call.c (maybe_warn_class_memaccess): Tighten up. gcc/testsuite/ChangeLog: PR c++/84851 * g++.dg/Wclass-memaccess-4.C: Remove XFAIL. From-SVN: r265467 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 9 --------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/Wclass-memaccess-4.C | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c04dbe84005..fad86908102 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-10-24 Martin Sebor + + PR c++/84851 + * call.c (maybe_warn_class_memaccess): Tighten up. + 2018-10-17 David Malcolm * Make-lang.in (selftest-c++): New. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 0baf26e4346..cd0c0f60ced 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8665,15 +8665,6 @@ maybe_warn_class_memaccess (location_t loc, tree fndecl, bool special = same_type_ignoring_top_level_qualifiers_p (ctx, desttype); tree binfo = TYPE_BINFO (ctx); - /* FIXME: The following if statement is overly permissive (see - bug 84851). Remove it in GCC 9. */ - if (special - && !BINFO_VTABLE (binfo) - && !BINFO_N_BASE_BINFOS (binfo) - && (DECL_CONSTRUCTOR_P (current_function_decl) - || DECL_DESTRUCTOR_P (current_function_decl))) - return; - if (special && !BINFO_VTABLE (binfo) && !first_non_trivial_field (desttype)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e1679013d08..6f9ba884e04 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-24 Martin Sebor + + PR c++/84851 + * g++.dg/Wclass-memaccess-4.C: Remove XFAIL. + 2018-10-24 Martin Liska PR tree-optimization/84436 diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess-4.C b/gcc/testsuite/g++.dg/Wclass-memaccess-4.C index 8c334219099..69b8c780c8b 100644 --- a/gcc/testsuite/g++.dg/Wclass-memaccess-4.C +++ b/gcc/testsuite/g++.dg/Wclass-memaccess-4.C @@ -29,7 +29,7 @@ struct C C::C (const C &c) { - memcpy (this, &c, sizeof c); // { dg-warning "\\\[-Wclass-memaccess]" "pr84851" { xfail *-*-*} } + memcpy (this, &c, sizeof c); // { dg-warning "\\\[-Wclass-memaccess]" } } C& C::operator= (const C &c) -- 2.30.2