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.
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.
+
PR c++/94272
* cp-gimplify.c (cp_genericize_r): Handle STATEMENT_LIST.
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. */
2020-03-26 Jakub Jelinek <jakub@redhat.com>
+ PR c++/81349
+ * g++.dg/cpp1z/pr81349.C: New test.
+
PR c++/94272
* g++.dg/debug/pr94272.C: New test.
--- /dev/null
+// PR c++/81349
+// { dg-do compile { target c++17_only } }
+
+#include <type_traits>
+
+struct A {
+ A (int) = delete;
+};
+
+struct B {
+ template <typename T>
+ B (T) = delete;
+};
+
+template <typename U>
+struct C {
+ C (U) = delete;
+};
+
+template <typename U>
+struct D {
+ template <typename T>
+ D (T, U) = delete;
+};
+
+static_assert (std::is_aggregate_v<A>);
+static_assert (std::is_aggregate_v<B>);
+static_assert (std::is_aggregate_v<C<int>>);
+static_assert (std::is_aggregate_v<D<int>>);