c++: Reject anonymous struct with bases
commit3ead06c1cff8fb42b4e278c3624917e6b5477f12
authorJason Merrill <jason@redhat.com>
Fri, 30 Jul 2021 12:45:01 +0000 (30 08:45 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 30 Jul 2021 16:21:32 +0000 (30 12:21 -0400)
tree59b79334540cc2c7c14d0dbf92e588e57796a85b
parent0ba2003cf306aa98b6ec91c9d849ab9bafcf17c2
c++: Reject anonymous struct with bases

In discussion of jakub's patch for C++20 pointer-interconvertibility, it
came up that we allow anonymous structs to have bases, but don't do anything
usable with them.  Let's reject it.

The comment change is something I noticed while looking for the right place
to diagnose this: finish_struct_anon does not actually check for anything
invalid, so it shouldn't claim to.

gcc/cp/ChangeLog:

* class.c (finish_struct_anon): Improve comment.
* decl.c (fixup_anonymous_aggr): Reject anonymous struct
with bases.

gcc/testsuite/ChangeLog:

* g++.dg/ext/anon-struct8.C: New test.
gcc/cp/class.c
gcc/cp/decl.c
gcc/testsuite/g++.dg/ext/anon-struct8.C [new file with mode: 0644]