Re: [PATCH 1/2] gdb: simplify code in check_typedef

Keith Seitz <[email protected]> Wed, 29 Jul 2026 10:27:03 -0700
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Hi,

On 7/27/26 2:20 AM, Tankut Baris Aktemur wrote:
> Simplify a code portion in check_typedef where the conditions are
> unnecessary.  Also remove the comment that says "treat address spaces
> and address classes separately", because since the commit 92fdad7
> "gdb: convert type instance flags to bitfields", they are separate
> fields; so, the comment does not look useful.

Thank you for the quick turnaround for such a, well, minor
corner case. It is very appreciated.

One concern I still have (maybe this is no longer an issue?):
the old logic (and the remaining comment in check_typedef) is outer-wins
on conflict, otherwise inherit from the inner typedef.

Always clearing the RHS and having `merge` never take aspace/class from
it fixes the outer-qualified case, but drops an aspace that appears only
on an inner typedef.

How about encoding outer-wins in `merge` instead, and dropping the 
clearing in check_typedef? That would preserve the previous behavior
(and match the comment).

For example:

type_instance_flags::merge:

    if (harvard_aspace == HARVARD_ASPACE_NONE)
      harvard_aspace = other.harvard_aspace;
    if (address_class == 0)
      address_class = other.address_class;

and check_typedef:

    instance_flags.merge (type->instance_flags ());

I completely agree with the naming change to `merge'. That is
certainly clearer for me.

Thanks,
Keith