On Fri, Mar 12, 2021 at 09:35:44AM +0100, Jakub Jelinek wrote:
> On Fri, Mar 12, 2021 at 04:08:17AM +0100, David Lamparter wrote:
> > 
> > The TYPE_MAIN_VARIANT() here was, for casts to a typedef'd type name,
> > resulting in all information about the typedef's involvement getting
> > lost.  This drops necessary information for warnings and can make them
> > confusing or even misleading.  It also makes specialized warnings for
> > unspecified-size system types (pid_t, uid_t, ...) impossible.
> 
> I don't think you can/should do the lookup_name calls in build_c_cast,
> that just can't be right.  The lookups need to be done only when parsing
> the typedefs.

I don't have enough understanding of the GCC codebase to be able to make
a more complex change than this, but your feedback gave me another idea:

> Because, one certainly can have e.g.
> typedef ... A;
> typedef A ... B; // with some extra qualifiers or whatever
> void
> foo (void)
> {
>   typedef ... A; // Override in local scope A but not B
>   ... = (B) ...; // build_c_cast called
> }
> You don't want to find the overridden A, you need the original one.

... I could simply check the lookup result for equality against the type
being iterated over (without its qualifiers).  While this means that
shadowed types like in your example will be skipped, this kiiiinda makes
sense from a user perspective since there wouldn't be a distinguisher in
the report.

Patch following up to this mail.  It still does the lookup in
build_c_cast, do you think this altered approach is acceptable?

Cheers,


-David

Reply via email to