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. 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.
> 2021-03-09 David Lamparter <[email protected]>
>
> PR c/99526
> * c-typeck.c (build_c_cast): retain (unqualified) typedefs in
> casts rather than stripping down to basic type.
Jakub