https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113919
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- I suppose this should fix it but there are testsuite FAILs. --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -5522,6 +5522,12 @@ fixup_anonymous_aggr (tree t) } } } + /* [class.union.anon]/1: Nested types, anonymous unions, and functions + shall not be declared within an anonymous union. */ + else if (ANON_UNION_TYPE_P (TREE_TYPE (probe))) + pedwarn (DECL_SOURCE_LOCATION (probe), OPT_Wpedantic, + "anonymous unions cannot be declared within an anonymous " + "union"); } /* Splice all functions out of CLASSTYPE_MEMBER_VEC. */