On Thu, Jan 15, 2026 at 12:06:10PM +0800, Jason Merrill wrote:
> On 1/15/26 4:20 AM, Marek Polacek wrote:
> > On Wed, Jan 14, 2026 at 03:11:26PM -0500, Marek Polacek wrote:
> > > Another month of work, so it's time for v3 of the Reflection patch
> > > series.  Since v2, we checked in over 75 commits, mostly cleanups
> > > and bug fixes for reflect.cc.
> > > 
> > > The whole branch can be found at
> > > <https://forge.sourceware.org/marek/gcc/commits/branch/reflection>
> > > 
> > > I will post v2/v3 diff as well.
> 
> A few small comments below.
> 
> Note that I'm not going to repeat comments from my last reply to v2 3/9,
> please also keep them in mind.
> 
> At this point I think we should go ahead and merge, subject to release
> manager approval; the remaining minor issues can be resolved incrementally.

Thanks again!
 
> > --- a/gcc/cp/mangle.cc
> > +++ b/gcc/cp/mangle.cc
> > @@ -4183,7 +4183,10 @@ write_reflection (tree refl)
> >       write_type (arg);
> >     else if (strcmp (prefix, "dm") == 0)
> >       {
> > -      write_prefix (decl_mangling_context (arg));
> > +      tree ctx = decl_mangling_context (arg);
> > +      while (ctx && ANON_UNION_TYPE_P (ctx))
> > +   ctx = decl_mangling_context (TYPE_NAME (ctx));
> 
> Please add a FIXME referring to the ABI discussion.

Not done as per the other email.

> > @@ -133,6 +143,14 @@ get_reflection (location_t loc, tree t, reflect_kind 
> > kind/*=REFLECT_UNDEF*/)
> >             "parameter %qD", t);
> >         return error_mark_node;
> >       }
> > +  /* If the id-expression denotes a variable declared by an init-capture,
> > +     R is ill-formed.  */
> > +  else if (is_capture_proxy (t))
> > +    {
> > +      error_at (loc, "%<^^%> cannot be applied to a local entity declared "
> > +           "by init-capture");
> 
> This diagnostic needs adjustment now that the condition includes all
> captures.

Patch posted:
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/706070.html>
 
> > +/* For direct base class relationship R return the binfo related
> > +   to the derived type.  */
> > +
> > +static tree
> > +direct_base_parent_binfo (tree r)
> > +{
> > +  /* Looping needed for multiple virtual inheritance.  */
> > +  while (BINFO_INHERITANCE_CHAIN (r))
> > +    r = BINFO_INHERITANCE_CHAIN (r);
> > +  return r;
> > +}
> > +
> > +/* For direct base class relationship R return the derived type
> > +   (i.e. when R is (D, B) it returns D).  */
> 
> Let's use "derived" instead of "parent" in the name of this function; the
> latter is specific to parent_of semantics.

Patch posted:
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/706071.html>
 
> > @@ -3064,6 +3035,8 @@ eval_variable_of (location_t loc, const constexpr_ctx 
> > *ctx, tree r,
> >               tree fun)
> >   {
> >     if (eval_is_function_parameter (r, kind) == boolean_false_node
> > +      /* This doesn't consider the points corresponding to injected
> > +    declarations.  */
> 
> This reads like a fixme, please add that it doesn't seem needed.

Done in r16-6849-g00f7efe1e5cc30.
 
> > @@ -8552,24 +8373,32 @@ check_splice_expr (location_t loc, location_t 
> > start_loc, tree t,
> >        foo.[: ^^S::bar :].  */
> >     if (!address_p
> >         && !member_access_p
> > -      && ((DECL_P (t) && DECL_NONSTATIC_MEMBER_P (t))
> > -     || (VAR_P (t) && DECL_ANON_UNION_VAR_P (t))))
> > +      && DECL_P (t)
> > +      && DECL_NONSTATIC_MEMBER_P (t))
> >       {
> >         if (complain_p)
> > -   error_at (loc, "cannot implicitly reference a class member through "
> > -             "a splice");
> > +   error_at (loc, "cannot implicitly reference a class member %qD "
> > +             "through a splice", t);
> >         return false;
> >       }
> >     /* [expr.unary.op]/3.1 "If the operand [of unary &] is a qualified-id or
> >        splice-expression designating a non-static member m, other than an
> >        explicit object member function, m shall be a direct member of some
> >        class C that is not an anonymous union."  */
> > -  if (address_p && VAR_P (t) && DECL_ANON_UNION_VAR_P (t))
> > -    {
> > -      if (complain_p)
> > -   error_at (loc, "unary %<&%> applied to an anonymous union member %qD "
> > -             "that is not a direct member of a named class", t);
> > -      return false;
> > +  if (address_p
> > +      && TREE_CODE (t) == FIELD_DECL
> > +      && ANON_UNION_TYPE_P (DECL_CONTEXT (t)))
> > +    {
> > +      tree c = CP_TYPE_CONTEXT (DECL_CONTEXT (t));
> > +      while (ANON_UNION_TYPE_P (c))
> > +   c = CP_TYPE_CONTEXT (c);
> 
> This could be context_for_name_lookup (t)

Patch posted:
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/706072.html>


I'll continue addressing your other comments next week.

Marek

Reply via email to