On Sun, 10 Aug 2025, Jason Merrill wrote:

> On 8/8/25 1:27 PM, Patrick Palka wrote:
> > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK
> > for trunk?
> > 
> > -- >8 --
> > 
> > At some point these flag start getting defined in terms of the previous
> > flag, which is inconvenient when we want to test if the flag is set
> > during a debugging session since we don't immediately know its actual
> > numeric value.
> 
> Can't you ask the debugger its value?  You're using -g3, right?

I've just been using a vanilla --disable-bootstrap build which uses -g by
default.  -g3 works nicely, I wonder why it isn't the default given our
still pervasive use of macros?

Looks like impact on build time/memory use is minimal compared to -g,
but it does increase the size of each object file by about 2MB.  Can't
we just build one object file with -g3 to preserve the macro definitions
(and perhaps with -fkeep-inline-functions so that small inline functions
will be preserved as well), and the rest with -g?

> 
> The current pattern was intended to allow adding/removing flags without
> adjusting the whole list, but I guess we could also leave a hole if we remove
> a flag.

Makes sense, though removing flags doesn't seem to happen very often --
around 12 times according to

  git log --oneline --grep "LOOKUP_.*[rR]emove" --grep "LOOKUP_.*[dD]elete"

> 
> So, it's not clear to me that this is an improvement, but I also don't object
> to it; if it's helpful to you then it's OK.
> 
> > It also results in a rather large AST that looks like
> > ((1 << (1 << ...)) << 1).  This patch defines all LOOKUP_* flags directly.
> > 
> > gcc/cp/ChangeLog:
> > 
> >     * cp-tree.h (LOOKUP_NO_NARROWING): Determine value directly, not
> >     in terms of the previous flag.
> >     (LOOKUP_LIST_INIT_CTOR): Likewise.
> >     (LOOKUP_COPY_PARM): Likewise.
> >     (LOOKUP_LIST_ONLY): Likewise.
> >     (LOOKUP_SPECULATIVE): Likewise.
> >     (LOOKUP_DEFAULTED): Likewise.
> >     (LOOKUP_ALREADY_DIGESTED): Likewise.
> >     (LOOKUP_NO_RVAL_BIND): Likewise.
> >     (LOOKUP_NO_NON_INTEGRAL): Likewise.
> >     (LOOKUP_DELEGATING_CONS): Likewise.
> >     (LOOKUP_ALLOW_FLEXARRAY_INIT): Likewise.
> >     (LOOKUP_REWRITTEN): Likewise.
> >     (LOOKUP_REVERSED): Likewise.
> >     (LOOKUP_AGGREGATE_PAREN_INIT): Likewise.
> >     (LOOKUP_SHORTCUT_BAD_CONVS): Likewise.
> > ---
> >   gcc/cp/cp-tree.h | 30 +++++++++++++++---------------
> >   1 file changed, 15 insertions(+), 15 deletions(-)
> > 
> > diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> > index fb8e0d8d98e3..bc0b8fd8b85b 100644
> > --- a/gcc/cp/cp-tree.h
> > +++ b/gcc/cp/cp-tree.h
> > @@ -6224,52 +6224,52 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG,
> > TYPENAME_FLAG };
> >   /* Do not permit references to bind to temporaries.  */
> >   #define LOOKUP_NO_TEMP_BIND (1 << 6)
> >   /* We're inside an init-list, so narrowing conversions are ill-formed.  */
> > -#define LOOKUP_NO_NARROWING (LOOKUP_NO_TEMP_BIND << 1)
> > +#define LOOKUP_NO_NARROWING (1 << 7)
> >   /* We're looking up a constructor for list-initialization.  */
> > -#define LOOKUP_LIST_INIT_CTOR (LOOKUP_NO_NARROWING << 1)
> > +#define LOOKUP_LIST_INIT_CTOR (1 << 8)
> >   /* This is the first parameter of a copy constructor.  */
> > -#define LOOKUP_COPY_PARM (LOOKUP_LIST_INIT_CTOR << 1)
> > +#define LOOKUP_COPY_PARM (1 << 9)
> >   /* We only want to consider list constructors.  */
> > -#define LOOKUP_LIST_ONLY (LOOKUP_COPY_PARM << 1)
> > +#define LOOKUP_LIST_ONLY (1 << 10)
> >   /* Return after determining which function to call and checking access.
> >      Used by sythesized_method_walk to determine which functions will
> >      be called to initialize subobjects, in order to determine exception
> >      specification and possible implicit delete.
> >      This is kind of a hack, but exiting early avoids problems with trying
> >      to perform argument conversions when the class isn't complete yet.  */
> > -#define LOOKUP_SPECULATIVE (LOOKUP_LIST_ONLY << 1)
> > +#define LOOKUP_SPECULATIVE (1 << 11)
> >   /* Used by calls from defaulted functions to limit the overload set to
> > avoid
> >      cycles trying to declare them (core issue 1092).  */
> > -#define LOOKUP_DEFAULTED (LOOKUP_SPECULATIVE << 1)
> > +#define LOOKUP_DEFAULTED (1 << 12)
> >   /* Used in calls to store_init_value to suppress its usual call to
> >      digest_init.  */
> > -#define LOOKUP_ALREADY_DIGESTED (LOOKUP_DEFAULTED << 1)
> > +#define LOOKUP_ALREADY_DIGESTED (1 << 13)
> >   /* Like LOOKUP_NO_TEMP_BIND, but also prevent binding to xvalues.  */
> > -#define LOOKUP_NO_RVAL_BIND (LOOKUP_ALREADY_DIGESTED << 1)
> > +#define LOOKUP_NO_RVAL_BIND (1 << 14)
> >   /* Used by case_conversion to disregard non-integral conversions.  */
> > -#define LOOKUP_NO_NON_INTEGRAL (LOOKUP_NO_RVAL_BIND << 1)
> > +#define LOOKUP_NO_NON_INTEGRAL (1 << 15)
> >   /* Used for delegating constructors in order to diagnose self-delegation.
> > */
> > -#define LOOKUP_DELEGATING_CONS (LOOKUP_NO_NON_INTEGRAL << 1)
> > +#define LOOKUP_DELEGATING_CONS (1 << 16)
> >   /* Allow initialization of a flexible array members.  */
> > -#define LOOKUP_ALLOW_FLEXARRAY_INIT (LOOKUP_DELEGATING_CONS << 1)
> > +#define LOOKUP_ALLOW_FLEXARRAY_INIT (1 << 17)
> >   /* We're looking for either a rewritten comparison operator candidate or
> > the
> >      operator to use on the former's result.  We distinguish between the two
> > by
> >      knowing that comparisons other than == and <=> must be the latter, as
> > must
> >      a <=> expression trying to rewrite to <=> without reversing.  */
> > -#define LOOKUP_REWRITTEN (LOOKUP_ALLOW_FLEXARRAY_INIT << 1)
> > +#define LOOKUP_REWRITTEN (1 << 18)
> >   /* Reverse the order of the two arguments for comparison rewriting.  First
> > we
> >      swap the arguments in add_operator_candidates, then we swap the
> > conversions
> >      in add_candidate (so that they correspond to the original order of the
> >      args), then we swap the conversions back in build_new_op_1 (so they
> >      correspond to the order of the args in the candidate).  */
> > -#define LOOKUP_REVERSED (LOOKUP_REWRITTEN << 1)
> > +#define LOOKUP_REVERSED (1 << 19)
> >   /* We're initializing an aggregate from a parenthesized list of values.
> > */
> > -#define LOOKUP_AGGREGATE_PAREN_INIT (LOOKUP_REVERSED << 1)
> > +#define LOOKUP_AGGREGATE_PAREN_INIT (1 << 20)
> >   /* We're computing conversions as part of a first pass of overload
> > resolution
> >      wherein we don't try to distinguish an unviable candidate from a
> >      non-strictly viable candidate and thus can avoid computing unnecessary
> >      bad conversions.  */
> > -#define LOOKUP_SHORTCUT_BAD_CONVS (LOOKUP_AGGREGATE_PAREN_INIT << 1)
> > +#define LOOKUP_SHORTCUT_BAD_CONVS (1 << 21)
> >     /* These flags are used by the conversion code.
> >      CONV_IMPLICIT   :  Perform implicit conversions (standard and
> > user-defined).
> 
> 

Reply via email to