From 7f5deba1c21888aacedae93e9f324827073a1d1e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 20 Apr 2021 00:50:49 -0400 Subject: [PATCH] c++: unexpanded pack in enum in lambda [PR100109] Another construct we need to look inside. gcc/cp/ChangeLog: PR c++/100109 * pt.c (find_parameter_packs_r): Look into enum initializers. gcc/testsuite/ChangeLog: PR c++/100109 * g++.dg/cpp0x/lambda/lambda-variadic14.C: New test. --- gcc/cp/pt.c | 8 +++++++- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic14.C | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic14.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 19fdafa..7bcbe6d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4066,12 +4066,18 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) return NULL_TREE; case TAG_DEFN: - /* Local class, need to look through the whole definition. */ t = TREE_TYPE (t); if (CLASS_TYPE_P (t)) + /* Local class, need to look through the whole definition. */ for (tree bb : BINFO_BASE_BINFOS (TYPE_BINFO (t))) cp_walk_tree (&BINFO_TYPE (bb), &find_parameter_packs_r, ppd, ppd->visited); + else + /* Enum, look at the values. */ + for (tree l = TYPE_VALUES (t); l; l = TREE_CHAIN (l)) + cp_walk_tree (&DECL_INITIAL (TREE_VALUE (l)), + &find_parameter_packs_r, + ppd, ppd->visited); return NULL_TREE; case FUNCTION_TYPE: diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic14.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic14.C new file mode 100644 index 0000000..185aa03 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic14.C @@ -0,0 +1,8 @@ +// PR c++/100109 +// { dg-do compile { target c++11 } } + +template +void f() { + [] { enum e { e = E }; }; // { dg-error "not expanded" } +} +template void f<>(); -- 2.7.4