aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-02-01 08:42:58 -0700
committerMartin Sebor <msebor@redhat.com>2021-02-01 08:42:58 -0700
commitc2f8e378d64f65645e5f9c41a8221ca102c71208 (patch)
tree4032647fd00bd3c0bfac72eae64517ceb317b925
parent7e534fb7d8256a605b6bdc12451d209af1bed329 (diff)
downloadgcc-c2f8e378d64f65645e5f9c41a8221ca102c71208.zip
gcc-c2f8e378d64f65645e5f9c41a8221ca102c71208.tar.gz
gcc-c2f8e378d64f65645e5f9c41a8221ca102c71208.tar.bz2
Verify a warning for a class with a ref-qualified assignment (PR c++/98835).
gcc/testsuite/ChangeLog: PR c++/98835 * g++.dg/Wclass-memaccess-6.C: New test.
-rw-r--r--gcc/testsuite/g++.dg/Wclass-memaccess-6.C18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess-6.C b/gcc/testsuite/g++.dg/Wclass-memaccess-6.C
new file mode 100644
index 0000000..7f6fe03
--- /dev/null
+++ b/gcc/testsuite/g++.dg/Wclass-memaccess-6.C
@@ -0,0 +1,18 @@
+/* PR c++/98835 - -Wclass-memaccess with class with ref-qualified
+ copy-assignment operator
+ { dg-do compile { target { c++11 } } }
+ { dg-options "-Wall" } */
+
+struct Bad
+{
+ Bad* operator& () { return this; }
+ Bad & operator=(Bad const &) & = default;
+};
+
+void test ()
+{
+ static_assert (__has_trivial_copy (Bad));
+
+ // T () = T (); // error
+ __builtin_memcpy (&Bad (), &Bad (), sizeof (Bad)); // { dg-warning "\\\[-Wclass-memaccess" }
+}