diff options
author | Joseph Myers <jsm28@gcc.gnu.org> | 2005-04-20 02:10:00 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2005-04-20 02:10:00 +0100 |
commit | 53a2494eea417253a25732b427963ac080923edd (patch) | |
tree | 14947a42d28eff84a4539188551c43e15026cc3f /gcc/c-typeck.c | |
parent | 7195b4148a916bab2451894b84e1298b5c42b8fe (diff) | |
download | gcc-53a2494eea417253a25732b427963ac080923edd.zip gcc-53a2494eea417253a25732b427963ac080923edd.tar.gz gcc-53a2494eea417253a25732b427963ac080923edd.tar.bz2 |
c.opt (Wint-to-pointer-cast, [...]): New options.
2005-04-20 Michael Pogue <michael.pogue@sun.com>
Joseph S. Myers <joseph@codesourcery.com>
* c.opt (Wint-to-pointer-cast, Wpointer-to-int-cast): New options.
* c-typeck.c (build_c_cast): Check these options.
* doc/invoke.texi: Document these options.
testsuite:
* gcc.dg/Wint-to-pointer-cast-1.c,
gcc.dg/Wint-to-pointer-cast-2.c, gcc.dg/Wint-to-pointer-cast-3.c,
gcc.dg/Wpointer-to-int-cast-1.c, gcc.dg/Wpointer-to-int-cast-2.c,
gcc.dg/Wpointer-to-int-cast-3.c: New tests.
From-SVN: r98429
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 9c82bbe..a39d703 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -3259,7 +3259,8 @@ build_c_cast (tree type, tree expr) && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype))) warning ("cast increases required alignment of target type"); - if (TREE_CODE (type) == INTEGER_TYPE + if (warn_pointer_to_int_cast + && TREE_CODE (type) == INTEGER_TYPE && TREE_CODE (otype) == POINTER_TYPE && TYPE_PRECISION (type) != TYPE_PRECISION (otype) && !TREE_CONSTANT (value)) @@ -3271,7 +3272,8 @@ build_c_cast (tree type, tree expr) warning ("cast from function call of type %qT to non-matching " "type %qT", otype, type); - if (TREE_CODE (type) == POINTER_TYPE + if (warn_int_to_pointer_cast + && TREE_CODE (type) == POINTER_TYPE && TREE_CODE (otype) == INTEGER_TYPE && TYPE_PRECISION (type) != TYPE_PRECISION (otype) /* Don't warn about converting any constant. */ |