This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] pointer cast warnings when size matches

This patch updates -Wint-to-pointer-cast and -Wpointer-to-int-cast options to accept value to enable warnings when size matches. New attribute safe_pointer_cast is available to suppress such warnings for selected integral types.

* c.opt (Wint-to-pointer-cast=, Wpointer-to-int-cast=): New.
* c-typeck.c (build_c_cast): Check warn_pointer_to_int_cast value.
Check warn_int_to_pointer_cast value.
* c-opts.c (c_common_handle_option): Handle OPT_Wint_to_pointer_cast,
OPT_Wint_to_pointer_cast_, OPT_Wpointer_to_int_cast,
* c-common.c (handle_safe_ponter_cast_attribute): New.
(c_common_attribute): Add entry for safe_pointer_cast.

        * doc/invoke.texi: Document -Wpointer-to-int-cast=2 and
        * doc/extend.texi: Document safe_pointer_cast attribute.

        * gcc.dg/Wpointer-to-int-cast-4.c: New test.
        * gcc.dg/Wpointer-to-int-cast-5.c: New test.
        * gcc.dg/Wint-to-pointer-cast-4.c: New test.
        * gcc.dg/Wint-to-pointer-cast-5.c: New test.

Bootstrapped and tested on powerpc-apple-darwin.


Attachment: R2883585.diff
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]