This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to finish_struct_anon
- To: gcc-patches at gcc dot gnu dot org
- Subject: C++ PATCH to finish_struct_anon
- From: Jason Merrill <jason_merrill at redhat dot com>
- Date: 11 Oct 2001 22:28:44 +0100
The test for invalid nested classes was too strict; it didn't allow for
unnamed structs used to define fields. Apparently this is used by some
cygwin headers.
Test in other/anon2.C
2001-10-11 Jason Merrill <jason_merrill@redhat.com>
* class.c (finish_struct_anon): Use TYPE_ANONYMOUS_P instead of
ANON_AGGR_TYPE_P.
*** class.c.~1~ Tue Oct 9 16:42:03 2001
--- class.c Thu Oct 11 14:21:49 2001
*************** finish_struct_anon (t)
*** 2926,2935 ****
declared, but we also find nested classes by noticing
the TYPE_DECL that we create implicitly. You're
allowed to put one anonymous union inside another,
! though, so we explicitly tolerate that. */
if (DECL_ARTIFICIAL (elt)
&& (!DECL_IMPLICIT_TYPEDEF_P (elt)
! || ANON_AGGR_TYPE_P (TREE_TYPE (elt))))
continue;
if (DECL_NAME (elt) == constructor_name (t))
--- 2926,2937 ----
declared, but we also find nested classes by noticing
the TYPE_DECL that we create implicitly. You're
allowed to put one anonymous union inside another,
! though, so we explicitly tolerate that. We use
! TYPE_ANONYMOUS_P rather than ANON_AGGR_TYPE_P so that
! we also allow unnamed types used for defining fields. */
if (DECL_ARTIFICIAL (elt)
&& (!DECL_IMPLICIT_TYPEDEF_P (elt)
! || TYPE_ANONYMOUS_P (TREE_TYPE (elt))))
continue;
if (DECL_NAME (elt) == constructor_name (t))
// Test that we can have an unnamed struct inside an anonymous union.
struct A
{
union
{
struct { int i; } foo;
};
};
static union
{
struct { int i; } foo;
};
int main ()
{
union
{
struct { int i; } bar;
};
}