/* Return the non-aggregate deduction guides for deducible template TMPL. The
aggregate candidate is added separately because it depends on the
- initializer. */
+ initializer. Set ANY_DGUIDES_P if we find a non-implicit deduction
+ guide. */
static tree
-deduction_guides_for (tree tmpl, tsubst_flags_t complain)
+deduction_guides_for (tree tmpl, bool &any_dguides_p, tsubst_flags_t complain)
{
tree guides = NULL_TREE;
if (DECL_ALIAS_TEMPLATE_P (tmpl))
{
tree under = DECL_ORIGINAL_TYPE (DECL_TEMPLATE_RESULT (tmpl));
tree tinfo = get_template_info (under);
- guides = deduction_guides_for (TI_TEMPLATE (tinfo), complain);
+ guides = deduction_guides_for (TI_TEMPLATE (tinfo), any_dguides_p,
+ complain);
}
else
{
/*hidden*/false);
if (guides == error_mark_node)
guides = NULL_TREE;
+ else
+ any_dguides_p = true;
}
/* Cache the deduction guides for a template. We also remember the result of
if (args == NULL)
return error_mark_node;
- tree cands = deduction_guides_for (tmpl, complain);
+ bool any_dguides_p = false;
+ tree cands = deduction_guides_for (tmpl, any_dguides_p, complain);
if (cands == error_mark_node)
return error_mark_node;
}
}
- if (tree guide = maybe_aggr_guide (tmpl, init, args))
- cands = lookup_add (guide, cands);
+ if (!any_dguides_p)
+ if (tree guide = maybe_aggr_guide (tmpl, init, args))
+ cands = lookup_add (guide, cands);
tree call = error_mark_node;
--- /dev/null
+// PR c++/98802
+// { dg-do compile { target c++17 } }
+
+using size_t = decltype(sizeof(42));
+
+template<typename T, size_t N = 0>
+struct List {
+ T head;
+ List<T, N-1> tail;
+};
+
+template<typename T>
+struct List<T, 0> {};
+
+template<typename T> List(T) -> List<T, 1>;
+template<typename T, size_t N> List(T, List<T, N>) -> List<T, N+1>;
+
+int main() {
+ auto list2 = List{0, List{1, List{2}}};
+}