Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at litex 2.5 kB view raw
1https://gcc.gnu.org/PR109241 2 3Fix ICE on ccache. 4 5From 396a4e76afec30d2461638f569cae18955eb4ad2 Mon Sep 17 00:00:00 2001 6From: Jason Merrill <jason@redhat.com> 7Date: Wed, 22 Mar 2023 16:11:47 -0400 8Subject: [PATCH] c++: local class in nested generic lambda [PR109241] 9 10In this testcase, the tree walk to look for bare parameter packs was 11confused by finding a type with no TREE_BINFO. But it should be fine that 12it's unset; we already checked for unexpanded packs at parse time. 13 14I also tried doing the partial instantiation of the local class, which is 15probably the long-term direction we want to go, but for stage 4 let's go 16with this safer change. 17 18 PR c++/109241 19 20gcc/cp/ChangeLog: 21 22 * pt.cc (find_parameter_packs_r): Handle null TREE_BINFO. 23 24gcc/testsuite/ChangeLog: 25 26 * g++.dg/cpp1y/lambda-generic-local-class2.C: New test. 27--- 28 gcc/cp/pt.cc | 12 ++++++++---- 29 .../g++.dg/cpp1y/lambda-generic-local-class2.C | 13 +++++++++++++ 30 2 files changed, 21 insertions(+), 4 deletions(-) 31 create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C 32 33diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc 34index c7f4a95a723..79bc9c014c8 100644 35--- a/gcc/cp/pt.cc 36+++ b/gcc/cp/pt.cc 37@@ -4106,10 +4106,14 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) 38 case TAG_DEFN: 39 t = TREE_TYPE (t); 40 if (CLASS_TYPE_P (t)) 41- /* Local class, need to look through the whole definition. */ 42- for (tree bb : BINFO_BASE_BINFOS (TYPE_BINFO (t))) 43- cp_walk_tree (&BINFO_TYPE (bb), &find_parameter_packs_r, 44- ppd, ppd->visited); 45+ { 46+ /* Local class, need to look through the whole definition. 47+ TYPE_BINFO might be unset for a partial instantiation. */ 48+ if (TYPE_BINFO (t)) 49+ for (tree bb : BINFO_BASE_BINFOS (TYPE_BINFO (t))) 50+ cp_walk_tree (&BINFO_TYPE (bb), &find_parameter_packs_r, 51+ ppd, ppd->visited); 52+ } 53 else 54 /* Enum, look at the values. */ 55 for (tree l = TYPE_VALUES (t); l; l = TREE_CHAIN (l)) 56diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C 57new file mode 100644 58index 00000000000..83856de1f41 59--- /dev/null 60+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C 61@@ -0,0 +1,13 @@ 62+// PR c++/109241 63+// { dg-do compile { target c++14 } } 64+// { dg-options "" } no pedantic 65+ 66+void g() { 67+ [](auto) { 68+ [](auto) { 69+ ({ 70+ struct A {}; 71+ }); 72+ }; 73+ }(1); 74+} 75-- 762.40.1 77