aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-09-29 13:45:02 -0400
committerJason Merrill <jason@redhat.com>2022-09-29 15:11:44 -0400
commit04d54b70fe2c3d69eb1d08f7212f01c8a972b701 (patch)
treeae7b9c097ebe383eceab5fbb65090ec52a0d66af /gcc/cp
parent13337ea9a1ccffc7d73a8ff87f5f186fd4d0d51c (diff)
downloadgcc-04d54b70fe2c3d69eb1d08f7212f01c8a972b701.zip
gcc-04d54b70fe2c3d69eb1d08f7212f01c8a972b701.tar.gz
gcc-04d54b70fe2c3d69eb1d08f7212f01c8a972b701.tar.bz2
c++: fix triviality of class with unsatisfied op=
cxx20_pair is trivially copyable because it has a trivial copy constructor and only a deleted copy assignment operator; the non-triviality of the unsatisfied copy assignment overload is not considered. gcc/cp/ChangeLog: * class.cc (check_methods): Call constraints_satisfied_p. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/cond-triv3.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/class.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index b84f422..aebcb53 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -4795,8 +4795,9 @@ check_methods (tree t)
/* Check whether the eligible special member functions (P0848) are
user-provided. add_method arranged that the CLASSTYPE_MEMBER_VEC only
- has the eligible ones; TYPE_FIELDS also contains ineligible overloads,
- which is why this needs to be separate from the loop above. */
+ has the eligible ones, unless none are eligible; TYPE_FIELDS also contains
+ ineligible overloads, which is why this needs to be separate from the loop
+ above. */
if (tree dtor = CLASSTYPE_DESTRUCTOR (t))
{
@@ -4819,6 +4820,10 @@ check_methods (tree t)
{
if (!user_provided_p (fn))
/* Might be trivial. */;
+ else if (TREE_CODE (fn) == TEMPLATE_DECL)
+ /* Templates are never special members. */;
+ else if (!constraints_satisfied_p (fn))
+ /* Not eligible. */;
else if (copy_fn_p (fn))
TYPE_HAS_COMPLEX_COPY_CTOR (t) = true;
else if (move_fn_p (fn))
@@ -4829,6 +4834,10 @@ check_methods (tree t)
{
if (!user_provided_p (fn))
/* Might be trivial. */;
+ else if (TREE_CODE (fn) == TEMPLATE_DECL)
+ /* Templates are never special members. */;
+ else if (!constraints_satisfied_p (fn))
+ /* Not eligible. */;
else if (copy_fn_p (fn))
TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = true;
else if (move_fn_p (fn))