From: A J Ryan Solutions Ltd Date: Sun, 2 Feb 2025 22:26:32 +0000 (+0000) Subject: c++: find A pack from B in ...B> [PR118265] X-Git-Tag: basepoints/gcc-16~2214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26d3424ca5d9f47d7e0b6fcaf0fae48435a73442;p=thirdparty%2Fgcc.git c++: find A pack from B in ...B> [PR118265] For non-type parameter packs when unifying the arguments in unify_pack_expansion it iterates over the associated packs of a param so that when it recursively unifies the param with the arguments it knows which targs have been populated with parameter pack arguments that it can then collect up. This change adds a tree walk so that in the example above it reaches ...A and adds it to the associated packs for ...B and therefore knows it will have been set in targs in unify_pack_expansion and processes it as per other pack arguments. PR c++/118265 gcc/cp/ChangeLog: * pt.cc (find_parameter_packs_r) : Walk into the type of a parameter pack. Signed-off-by: Adam J Ryan --- diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 77583dd6bb5..39232b5e67f 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -4010,6 +4010,11 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) &find_parameter_packs_r, ppd, ppd->visited); return NULL_TREE; + case TEMPLATE_PARM_INDEX: + if (parameter_pack_p) + WALK_SUBTREE (TREE_TYPE (t)); + return NULL_TREE; + case DECL_EXPR: { tree decl = DECL_EXPR_DECL (t); diff --git a/gcc/testsuite/g++.dg/cpp1z/variadic-nontype1.C b/gcc/testsuite/g++.dg/cpp1z/variadic-nontype1.C new file mode 100644 index 00000000000..ad2af623b13 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/variadic-nontype1.C @@ -0,0 +1,18 @@ +// { dg-do compile { target c++17 } } +struct Class1 +{ + void apply_bool(bool){} + void apply_char(char){} +}; + +template struct Class2; +template struct Class2 +{ + void apply(){} +}; + +int main() +{ + Class2<&Class1::apply_bool, &Class1::apply_char> class2; + class2.apply (); +}