Normally cp_parser_base_clause prevents unexpanded packs, but in a lambda
check_for_bare_parameter_packs allows it. Then we weren't finding the
pack when scanning the lambda body.
This doesn't fix a valid variant like
template <class... Ts> void sink (Ts&&...);
template <class... Ts>
void f() {
sink ([] { struct S : Ts { }; }...);
}
int main() {
f<int>();
}
but that's a much bigger project.
gcc/cp/ChangeLog:
PR c++/100006
* pt.c (find_parameter_packs_r) [TAG_DEFN]: Look into bases.
gcc/testsuite/ChangeLog:
PR c++/100006
* g++.dg/cpp0x/lambda/lambda-variadic13.C: New test.
*walk_subtrees = 0;
return NULL_TREE;
+ case TAG_DEFN:
+ /* Local class, need to look through the whole definition. */
+ t = TREE_TYPE (t);
+ if (CLASS_TYPE_P (t))
+ for (tree bb : BINFO_BASE_BINFOS (TYPE_BINFO (t)))
+ cp_walk_tree (&BINFO_TYPE (bb), &find_parameter_packs_r,
+ ppd, ppd->visited);
+ return NULL_TREE;
+
default:
return NULL_TREE;
}
--- /dev/null
+// PR c++/100006
+// { dg-do compile { target c++14 } }
+
+template <class... Ts>
+void f() {
+ [] { struct S : Ts { }; }; // { dg-error "not expanded" }
+}
+
+int main() {
+ f<>();
+}