aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-03-26 09:31:15 +0100
committerJakub Jelinek <jakub@redhat.com>2020-03-26 09:31:15 +0100
commitdab932d1519ba07fb4c49e6849ee7ceb02c0d603 (patch)
treea74636b0d3ef492d71bcfc0cd9dd9f65c3a554ed /gcc/cp/class.c
parent5a1706f63a2024a5c2d878f2efeb8d198214542f (diff)
downloadgcc-dab932d1519ba07fb4c49e6849ee7ceb02c0d603.zip
gcc-dab932d1519ba07fb4c49e6849ee7ceb02c0d603.tar.gz
gcc-dab932d1519ba07fb4c49e6849ee7ceb02c0d603.tar.bz2
c++: Fix up user_provided_p [PR81349]
The standard says: "A function is user-provided if it is user-declared and not explicitly defaulted or deleted on its first declaration." I don't see anything about function templates having different rules here, but user_provided_p does return true for all TEMPLATE_DECLs. The following patch fixes it by treating as user-provided only templates that aren't deleted. 2020-03-26 Jakub Jelinek <jakub@redhat.com> PR c++/81349 * class.c (user_provided_p): Use STRIP_TEMPLATE instead of returning true for all TEMPLATE_DECLs. * g++.dg/cpp1z/pr81349.C: New test.
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 5340799..41f52e5 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5159,12 +5159,10 @@ in_class_defaulted_default_constructor (tree t)
bool
user_provided_p (tree fn)
{
- if (TREE_CODE (fn) == TEMPLATE_DECL)
- return true;
- else
- return (!DECL_ARTIFICIAL (fn)
- && !(DECL_INITIALIZED_IN_CLASS_P (fn)
- && (DECL_DEFAULTED_FN (fn) || DECL_DELETED_FN (fn))));
+ fn = STRIP_TEMPLATE (fn);
+ return (!DECL_ARTIFICIAL (fn)
+ && !(DECL_INITIALIZED_IN_CLASS_P (fn)
+ && (DECL_DEFAULTED_FN (fn) || DECL_DELETED_FN (fn))));
}
/* Returns true iff class T has a user-provided constructor. */