public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2653] c++: ICE on anon struct with base [PR96636] Date: Sat, 31 Jul 2021 14:45:55 +0000 (GMT) [thread overview] Message-ID: <20210731144555.6D62C384841A@sourceware.org> (raw) https://gcc.gnu.org/g:af76342b444948ab262b276cdf083c2d2e0cebbb commit r12-2653-gaf76342b444948ab262b276cdf083c2d2e0cebbb Author: Jason Merrill <jason@redhat.com> Date: Fri Jul 30 16:49:03 2021 -0400 c++: ICE on anon struct with base [PR96636] pinski pointed out that my recent change to reject anonymous structs with bases was relevant to this PR. But we still ICEd after giving that error; this fixes the ICE. PR c++/96636 gcc/cp/ChangeLog: * decl.c (fixup_anonymous_aggr): Clear TYPE_NEEDS_CONSTRUCTING after error. gcc/testsuite/ChangeLog: * g++.dg/ext/anon-struct9.C: New test. Diff: --- gcc/cp/decl.c | 6 +++++- gcc/testsuite/g++.dg/ext/anon-struct9.C | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e4be6be1819..6fa6b9adc87 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5094,7 +5094,11 @@ fixup_anonymous_aggr (tree t) tree field, type; if (BINFO_N_BASE_BINFOS (TYPE_BINFO (t))) - error_at (location_of (t), "anonymous struct with base classes"); + { + error_at (location_of (t), "anonymous struct with base classes"); + /* Avoid ICE after error on anon-struct9.C. */ + TYPE_NEEDS_CONSTRUCTING (t) = false; + } for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL) diff --git a/gcc/testsuite/g++.dg/ext/anon-struct9.C b/gcc/testsuite/g++.dg/ext/anon-struct9.C new file mode 100644 index 00000000000..56759429620 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/anon-struct9.C @@ -0,0 +1,9 @@ +// PR c++/96636 +// { dg-options "" } + +typedef class { + class a {}; + class : virtual a {}; // { dg-error "anonymous struct with base" } +} b; +void foo(){ b();} +
reply other threads:[~2021-07-31 14:45 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210731144555.6D62C384841A@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).