On Thu, Feb 19, 2026 at 03:09:49PM -0500, Marek Polacek wrote:
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> 
> -- >8 --
> The assert in this test currently doesn't pass because .size () is 3, due to
> {A, B, B} found in N, but it should only be {A, B}, because we should
> skip the hidden "void N::B()".
> 
>       PR c++/123641
> 
> gcc/cp/ChangeLog:
> 
>       * name-lookup.cc (STAT_TYPE_HIDDEN_P, STAT_DECL_HIDDEN_P): Moved from
>       here to...
>       * name-lookup.h: ...here.
>       * reflect.cc (namespace_members_of): Skip STAT_TYPE_HIDDEN_P.
> 
> gcc/testsuite/ChangeLog:
> 
>       * g++.dg/reflect/members_of8.C: New test.

> --- a/gcc/cp/name-lookup.cc
> +++ b/gcc/cp/name-lookup.cc
> @@ -59,7 +59,9 @@ enum binding_slots
>  
>  /* Create an overload suitable for recording an artificial TYPE_DECL
>     and another decl.  We use this machanism to implement the struct
> -   stat hack.  */
> +   stat hack.
> +   When a STAT_HACK_P is true, OVL_USING_P and OVL_EXPORT_P are valid
> +   and apply to the hacked type.  */
>  
>  #define STAT_HACK_P(N) ((N) && TREE_CODE (N) == OVERLOAD && OVL_LOOKUP_P (N))
>  #define STAT_TYPE_VISIBLE_P(N) TREE_USED (OVERLOAD_CHECK (N))
> @@ -69,18 +71,6 @@ enum binding_slots
>  #define MAYBE_STAT_DECL(N) (STAT_HACK_P (N) ? STAT_DECL (N) : N)
>  #define MAYBE_STAT_TYPE(N) (STAT_HACK_P (N) ? STAT_TYPE (N) : NULL_TREE)
>  
> -/* When a STAT_HACK_P is true, OVL_USING_P and OVL_EXPORT_P are valid
> -   and apply to the hacked type.  */
> -
> -/* For regular (maybe) overloaded functions, we have OVL_HIDDEN_P.
> -   But we also need to indicate hiddenness on implicit type decls
> -   (injected friend classes), and (coming soon) decls injected from
> -   block-scope externs.  It is too awkward to press the existing
> -   overload marking for that.  If we have a hidden non-function, we
> -   always create a STAT_HACK, and use these two markers as needed.  */
> -#define STAT_TYPE_HIDDEN_P(N) OVL_HIDDEN_P (N)
> -#define STAT_DECL_HIDDEN_P(N) OVL_DEDUP_P (N)

I thought you should move over all the macros, starting with STAT_HACK_P
and ending with STAT_DECL_HIDDEN_P, including the comments.

> --- a/gcc/cp/reflect.cc
> +++ b/gcc/cp/reflect.cc
> @@ -6482,7 +6482,7 @@ namespace_members_of (location_t loc, tree ns)
>               CONSTRUCTOR_APPEND_ELT (elts, NULL_TREE,
>                                       get_reflection_raw (loc, m));
>           }
> -       if (OVL_DEDUP_P (o) || !OVL_FUNCTION (o))
> +       if (OVL_DEDUP_P (o) || !OVL_FUNCTION (o) || STAT_TYPE_HIDDEN_P (o))
>           continue;
>         o = OVL_FUNCTION (o);

I think STAT_TYPE_HIDDEN_P means the STAT_TYPE should be hidden, not
STAT_DECL.
Furthermore, if/when all the macros are moved, it would be better to
use those macros in the function rather than what they expand to.
So untested
-      if (TREE_CODE (o) == OVERLOAD && OVL_LOOKUP_P (o))
+      if (STAT_HACK_P (o))
         {
-          if (TREE_TYPE (o))
+          if (STAT_TYPE (o) && !STAT_TYPE_HIDDEN_P (o))
             {
-              tree m = TREE_TYPE (TREE_TYPE (o));
+              tree m = TREE_TYPE (STAT_TYPE (o));
               if (members_of_representable_p (ns, m))
                 CONSTRUCTOR_APPEND_ELT (elts, NULL_TREE,
                                         get_reflection_raw (loc, m));
             }
-          if (OVL_DEDUP_P (o) || !OVL_FUNCTION (o))
+          if (STAT_DECL_HIDDEN_P (o) || !STAT_DECL (o))
             continue;
-          o = OVL_FUNCTION (o);
+          o = STAT_DECL (o);
         }
?

        Jakub

Reply via email to