https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124831
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:6535e206f12552c7840169adeb9187fe9cf7f3a6 commit r16-8565-g6535e206f12552c7840169adeb9187fe9cf7f3a6 Author: Jakub Jelinek <[email protected]> Date: Fri Apr 10 18:49:00 2026 +0200 c++: Include anon enum types in namespace members_of [PR124831] As the testcase shows, we have similar problem with namespace scope anonymous enums like we have with namespace scope anonymous unions. Because they are anonymous, in neither case we emit anything into the namespace bindings but we should still list those. Now, for anonymous union this is done by adding it (once only) when seeing corresponding DECL_ANON_UNION_VAR_P (and it doesn't work when there is anon union without any members but that is a pedwarn anyway). The following patch handles it similarly for anon enums, namespace scope enum {}; is still ignored (but that is a pedwarn as well, so not a big deal) and when there is at least one enumerator in it, we add it when seeing the CONST_DECL (but again, just once for the whole members_of call). 2026-04-10 Jakub Jelinek <[email protected]> PR c++/124831 * reflect.cc (namespace_members_of): Append reflection of anon unions when we see it first time as CP_DECL_CONTEXT of some CONST_DECL in the namespace. * g++.dg/reflect/members_of13.C: New test. Reviewed-by: Jason Merrill <[email protected]>
