[Bug c++/124831] Anonymous enum not enumerated in members_of on a namespace reflection

2026-04-10 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124831

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|--- |16.0
 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Jakub Jelinek  ---
Fixed.

[Bug c++/124831] Anonymous enum not enumerated in members_of on a namespace reflection

2026-04-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124831

--- Comment #3 from GCC Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:6535e206f12552c7840169adeb9187fe9cf7f3a6

commit r16-8565-g6535e206f12552c7840169adeb9187fe9cf7f3a6
Author: Jakub Jelinek 
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  

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 

[Bug c++/124831] Anonymous enum not enumerated in members_of on a namespace reflection

2026-04-09 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124831

--- Comment #2 from Jakub Jelinek  ---
Created attachment 64181
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64181&action=edit
gcc16-pr124831.patch

Untested fix.

[Bug c++/124831] Anonymous enum not enumerated in members_of on a namespace reflection

2026-04-09 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124831

Jakub Jelinek  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2026-04-09
 Status|UNCONFIRMED |ASSIGNED
 Blocks||123615
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek  ---
As enum {}; at namespace scope is pedantically invalid, I think we can just
list it when we see the first enumerator of such enum there.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123615
[Bug 123615] (c++-reflection) - [meta-bug] reflection issue