diff options
author | Marek Polacek <polacek@redhat.com> | 2014-07-01 08:53:12 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-07-01 08:53:12 +0000 |
commit | 52ec0ea334753fbe7a81c15c17636fb22a3c7d2d (patch) | |
tree | 98e47da6bde5358750ba0aac6b53b099e2e8eee6 | |
parent | d5c3d343bdc26d8d16d2a3b20c25dce3c619ff69 (diff) | |
download | gcc-52ec0ea334753fbe7a81c15c17636fb22a3c7d2d.zip gcc-52ec0ea334753fbe7a81c15c17636fb22a3c7d2d.tar.gz gcc-52ec0ea334753fbe7a81c15c17636fb22a3c7d2d.tar.bz2 |
invoke.texi: Document -Wint-conversion.
* doc/invoke.texi: Document -Wint-conversion.
c-family/
* c.opt (Wint-conversion): New option.
c/
* c-typeck.c (convert_for_assignment): Pass OPT_Wint_conversion
instead of 0 to WARN_FOR_ASSIGNMENT.
testsuite/
* gcc.dg/Wint-conversion.c: New test.
From-SVN: r212193
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 4 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 6 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wint-conversion.c | 22 |
8 files changed, 56 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 76dc43c..14d1909 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2014-07-01 Marek Polacek <polacek@redhat.com> + * doc/invoke.texi: Document -Wint-conversion. + +2014-07-01 Marek Polacek <polacek@redhat.com> + PR c/58286 * doc/invoke.texi: Document -Wincompatible-pointer-types. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e8d2942..25acae8 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,5 +1,9 @@ 2014-07-01 Marek Polacek <polacek@redhat.com> + * c.opt (Wint-conversion): New option. + +2014-07-01 Marek Polacek <polacek@redhat.com> + PR c/58286 * c.opt (Wincompatible-pointer-types): New option. diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 6448b1b..c89040a 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -474,6 +474,10 @@ Winherited-variadic-ctor C++ ObjC++ Var(warn_inh_var_ctor) Init(1) Warning Warn about C++11 inheriting constructors when the base has a variadic constructor +Wint-conversion +C ObjC Var(warn_int_conversion) Init(1) Warning +Warn about incompatible integer to pointer and pointer to integer conversions + Wint-to-pointer-cast C ObjC C++ ObjC++ Var(warn_int_to_pointer_cast) Init(1) Warning Warn when there is a cast to a pointer from an integer of a different size diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c64c553..1c19362 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,10 @@ 2014-07-01 Marek Polacek <polacek@redhat.com> + * c-typeck.c (convert_for_assignment): Pass OPT_Wint_conversion + instead of 0 to WARN_FOR_ASSIGNMENT. + +2014-07-01 Marek Polacek <polacek@redhat.com> + PR c/58286 * c-typeck.c (convert_for_assignment): Pass OPT_Wincompatible_pointer_types instead of 0 to WARN_FOR_ASSIGNMENT. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index fff26a3..35bfd14 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -6213,7 +6213,8 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, or one that results from arithmetic, even including a cast to integer type. */ if (!null_pointer_constant) - WARN_FOR_ASSIGNMENT (location, expr_loc, 0, + WARN_FOR_ASSIGNMENT (location, expr_loc, + OPT_Wint_conversion, G_("passing argument %d of %qE makes " "pointer from integer without a cast"), G_("assignment makes pointer from integer " @@ -6227,7 +6228,8 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, } else if (codel == INTEGER_TYPE && coder == POINTER_TYPE) { - WARN_FOR_ASSIGNMENT (location, expr_loc, 0, + WARN_FOR_ASSIGNMENT (location, expr_loc, + OPT_Wint_conversion, G_("passing argument %d of %qE makes integer " "from pointer without a cast"), G_("assignment makes integer from pointer " diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 409fa17..b1f6f4b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -253,7 +253,7 @@ Objective-C and Objective-C++ Dialects}. -Wframe-larger-than=@var{len} -Wno-free-nonheap-object -Wjump-misses-init @gol -Wignored-qualifiers -Wincompatible-pointer-types @gol -Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol --Winit-self -Winline @gol +-Winit-self -Winline -Wno-int-conversion @gol -Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol -Winvalid-pch -Wlarger-than=@var{len} -Wunsafe-loop-optimizations @gol -Wlogical-op -Wlogical-not-parentheses -Wlong-long @gol @@ -4214,6 +4214,14 @@ Do not warn when there is a conversion between pointers that have incompatible types. This warning is for cases not covered by @option{-Wno-pointer-sign}, which warns for pointer argument passing or assignment with different signedness +@item -Wno-int-conversion @r{(C and Objective-C only)} +@opindex Wno-int-conversion +@opindex Wint-conversion +Do not warn about incompatible integer to pointer and pointer to integer +conversions. This warning is about implicit conversions; for explicit +conversions the warnings @option{-Wno-int-to-pointer-cast} and +@option{-Wno-pointer-to-int-cast} may be used. + @item -Wno-div-by-zero @opindex Wno-div-by-zero @opindex Wdiv-by-zero diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6dc8f95..0bb4e90 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2014-07-01 Marek Polacek <polacek@redhat.com> + * gcc.dg/Wint-conversion.c: New test. + +2014-07-01 Marek Polacek <polacek@redhat.com> + PR c/58286 * gcc.dg/Wincompatible-pointer-types.c: New test. diff --git a/gcc/testsuite/gcc.dg/Wint-conversion.c b/gcc/testsuite/gcc.dg/Wint-conversion.c new file mode 100644 index 0000000..1b7a03e --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wint-conversion.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-int-conversion" } */ + +int fn1 (int *), *fn2 (int); + +int +fn1 (int *p) +{ + int i = p; + i = p; + fn2 (p); + return p; +} + +int * +fn2 (int i) +{ + int *p = i; + p = i; + fn1 (i); + return i; +} |