diff options
author | Jason Merrill <jason@redhat.com> | 2023-03-22 16:11:47 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-03-22 23:23:13 -0400 |
commit | 4872e46e080c6695dfe1f9dc9db26b4703bc348c (patch) | |
tree | 7745d14d3bdf6eecd0792983c5f44e2df4a3a866 | |
parent | cd0c433e5faba9a18f64881cd761a53a530aa798 (diff) | |
download | gcc-4872e46e080c6695dfe1f9dc9db26b4703bc348c.zip gcc-4872e46e080c6695dfe1f9dc9db26b4703bc348c.tar.gz gcc-4872e46e080c6695dfe1f9dc9db26b4703bc348c.tar.bz2 |
c++: local class in nested generic lambda [PR109241]
In this testcase, the tree walk to look for bare parameter packs was
confused by finding a type with no TREE_BINFO. But it should be fine that
it's unset; we already checked for unexpanded packs at parse time.
I also tried doing the partial instantiation of the local class, which is
probably the long-term direction we want to go, but for stage 4 let's go
with this safer change.
PR c++/109241
gcc/cp/ChangeLog:
* pt.cc (find_parameter_packs_r): Handle null TREE_BINFO.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-local-class2.C: New test.
-rw-r--r-- | gcc/cp/pt.cc | 12 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C | 13 |
2 files changed, 21 insertions, 4 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 90bcaa7..40deedc 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -4069,10 +4069,14 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) case TAG_DEFN: 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); + { + /* Local class, need to look through the whole definition. + TYPE_BINFO might be unset for a partial instantiation. */ + if (TYPE_BINFO (t)) + 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)) diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C new file mode 100644 index 0000000..83856de --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C @@ -0,0 +1,13 @@ +// PR c++/109241 +// { dg-do compile { target c++14 } } +// { dg-options "" } no pedantic + +void g() { + [](auto) { + [](auto) { + ({ + struct A {}; + }); + }; + }(1); +} |