From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] c++: local class in nested generic lambda [PR109241]
Date: Wed, 22 Mar 2023 23:23:55 -0400 [thread overview]
Message-ID: <20230323032355.2678239-1-jason@redhat.com> (raw)
Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
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.
---
gcc/cp/pt.cc | 12 ++++++++----
.../g++.dg/cpp1y/lambda-generic-local-class2.C | 13 +++++++++++++
2 files changed, 21 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 90bcaa78701..40deedc9ba9 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 00000000000..83856de1f41
--- /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);
+}
base-commit: cd0c433e5faba9a18f64881cd761a53a530aa798
--
2.31.1
next reply other threads:[~2023-03-23 3:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 3:23 Jason Merrill [this message]
2023-04-26 21:16 Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230323032355.2678239-1-jason@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).