[PATCH] c: don't drop typedef information in casts

David Lamparter equinox@diac24.net
Wed Mar 10 01:28:15 GMT 2021


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.

gcc/c/ChangeLog:
2021-03-09  David Lamparter  <equinox@diac24.net>

        * c-typeck.c (build_c_cast): retain (unqualified) typedefs in
          casts rather than stripping down to basic type.
---
 gcc/c/c-typeck.c              | 11 +++++++----
 gcc/testsuite/gcc.dg/cast-5.c | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/cast-5.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-c-don-t-drop-typedef-information-in-casts.patch
Type: text/x-patch
Size: 2669 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210310/d4f89dfb/attachment-0001.bin>


More information about the Gcc-patches mailing list