From: Jason Merrill Date: Sat, 14 Mar 2020 21:10:39 +0000 (-0400) Subject: c++: Find parameter pack in typedef in lambda [92909]. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b3b0c671cc341fd04afc045a8d42d7a845d7f73c;p=gcc.git c++: Find parameter pack in typedef in lambda [92909]. find_parameter_packs_r doesn't look through typedefs, which is normally correct, but that means we need to handle their declarations specially. gcc/cp/ChangeLog 2020-03-14 Jason Merrill PR c++/92909 * pt.c (find_parameter_packs_r): [DECL_EXPR]: Walk DECL_ORIGINAL_TYPE of a typedef. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b4fa15047b5..bb7f590ea0b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-03-14 Jason Merrill + + PR c++/92909 + * pt.c (find_parameter_packs_r): [DECL_EXPR]: Walk + DECL_ORIGINAL_TYPE of a typedef. + 2020-03-14 Jason Merrill PR c++/93248 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0f3c2ad8fec..bd2f9be82ea 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3916,10 +3916,18 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) return NULL_TREE; case DECL_EXPR: - /* Ignore the declaration of a capture proxy for a parameter pack. */ - if (is_capture_proxy (DECL_EXPR_DECL (t))) - *walk_subtrees = 0; - return NULL_TREE; + { + tree decl = DECL_EXPR_DECL (t); + /* Ignore the declaration of a capture proxy for a parameter pack. */ + if (is_capture_proxy (decl)) + *walk_subtrees = 0; + if (is_typedef_decl (decl)) + /* Since we stop at typedefs above, we need to look through them at + the point of the DECL_EXPR. */ + cp_walk_tree (&DECL_ORIGINAL_TYPE (decl), + &find_parameter_packs_r, ppd, ppd->visited); + return NULL_TREE; + } case TEMPLATE_DECL: if (!DECL_TEMPLATE_TEMPLATE_PARM_P (t)) diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic10.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic10.C new file mode 100644 index 00000000000..052283e6caa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic10.C @@ -0,0 +1,12 @@ +// PR c++/92909 +// { dg-do compile { target c++11 } } + +template +void foo() +{ + [] + { + using T = Ts; + }(); // { dg-error "not expanded" } +} +template void foo<>();