[Bug c++/113919] Nested anonymous unions should be prohibited in ISO C++

2024-02-14 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113919

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #4 from Marek Polacek  ---
Ah, we have a dup.

*** This bug has been marked as a duplicate of bug 72751 ***

[Bug c++/113919] Nested anonymous unions should be prohibited in ISO C++

2024-02-14 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113919

--- Comment #3 from Marek Polacek  ---
clang++ has -Wnested-anon-types so I think we need that too.

[Bug c++/113919] Nested anonymous unions should be prohibited in ISO C++

2024-02-14 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113919

--- Comment #2 from Marek Polacek  ---
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.  */

[Bug c++/113919] Nested anonymous unions should be prohibited in ISO C++

2024-02-14 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113919

Marek Polacek  changed:

   What|Removed |Added

   Last reconfirmed||2024-02-14
 Status|UNCONFIRMED |NEW
   Keywords||accepts-invalid
 Ever confirmed|0   |1
 CC||mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek  ---
[class.union.anon]/1: Nested types, anonymous unions, and functions shall not
be declared within an anonymous union.