tree pattern;
tree pack, packs = NULL_TREE;
bool unsubstituted_packs = false;
- bool unsubstituted_fn_pack = false;
int i, len = -1;
tree result;
bool need_local_specializations = false;
else
arg_pack = make_fnparm_pack (arg_pack);
}
- else if (argument_pack_element_is_expansion_p (arg_pack, 0))
- /* This argument pack isn't fully instantiated yet. We set this
- flag rather than clear arg_pack because we do want to do the
- optimization below, and we don't want to substitute directly
- into the pattern (as that would expose a NONTYPE_ARGUMENT_PACK
- where it isn't expected). */
- unsubstituted_fn_pack = true;
+ else if (DECL_PACK_P (arg_pack))
+ /* This argument pack isn't fully instantiated yet. */
+ arg_pack = NULL_TREE;
}
else if (is_capture_proxy (parm_pack))
{
arg_pack = retrieve_local_specialization (parm_pack);
- if (argument_pack_element_is_expansion_p (arg_pack, 0))
- unsubstituted_fn_pack = true;
+ if (DECL_PACK_P (arg_pack))
+ arg_pack = NULL_TREE;
}
else
{
if (len < 0)
len = my_len;
- else if (len != my_len
- && !unsubstituted_fn_pack)
+ else if (len != my_len)
{
if (!(complain & tf_error))
/* Fail quietly. */;
/* We can't substitute for this parameter pack. We use a flag as
well as the missing_level counter because function parameter
packs don't have a level. */
- if (!(processing_template_decl || is_auto (parm_pack)))
- {
- gcc_unreachable ();
- }
gcc_assert (processing_template_decl || is_auto (parm_pack));
unsubstituted_packs = true;
}
{
inst = (retrieve_local_specialization
(DECL_CAPTURED_VARIABLE (decl)));
- gcc_assert (TREE_CODE (inst) == NONTYPE_ARGUMENT_PACK);
+ gcc_assert (TREE_CODE (inst) == NONTYPE_ARGUMENT_PACK
+ || DECL_PACK_P (inst));
}
else
inst = lookup_init_capture_pack (decl);
}
for (; tmpl_parm; tmpl_parm = DECL_CHAIN (tmpl_parm))
{
- if (!DECL_PACK_P (tmpl_parm))
+ if (!DECL_PACK_P (tmpl_parm)
+ || (spec_parm && DECL_PACK_P (spec_parm)))
{
register_local_specialization (spec_parm, tmpl_parm);
spec_parm = DECL_CHAIN (spec_parm);
--- /dev/null
+// PR c++/94546
+// { dg-do compile { target c++2a } }
+
+template <class T> T&& forward(T&& t) { return static_cast<T&&>(t); }
+
+template <class X>
+void test(X&& plot)
+{
+ // Note: For brevity, this lambda function is only
+ // defined, not called nor assigned to a variable.
+ // Doing those things won't fix the error.
+ [&]<class... T>(T&&... rest)
+ {
+ plot(forward<T>(rest)...);
+ };
+}
+int main()
+{
+ auto Plot = [](auto&&...)
+ {
+ };
+ test(Plot);
+}