From: Marek Polacek Date: Tue, 1 Jul 2014 08:53:12 +0000 (+0000) Subject: invoke.texi: Document -Wint-conversion. X-Git-Tag: releases/gcc-5.1.0~6549 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=52ec0ea334753fbe7a81c15c17636fb22a3c7d2d;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 76dc43c715ca..14d19098562e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2014-07-01 Marek Polacek + + * doc/invoke.texi: Document -Wint-conversion. + 2014-07-01 Marek Polacek PR c/58286 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e8d2942482ad..25acae88e95b 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2014-07-01 Marek Polacek + + * c.opt (Wint-conversion): New option. + 2014-07-01 Marek Polacek PR c/58286 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 6448b1b9495c..c89040abf9ee 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 c64c553a5aad..1c1936245d86 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2014-07-01 Marek Polacek + + * c-typeck.c (convert_for_assignment): Pass OPT_Wint_conversion + instead of 0 to WARN_FOR_ASSIGNMENT. + 2014-07-01 Marek Polacek PR c/58286 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index fff26a3993ab..35bfd1498769 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 409fa1716a86..b1f6f4bcb576 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 6dc8f950bfa0..0bb4e903ab73 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-07-01 Marek Polacek + + * gcc.dg/Wint-conversion.c: New test. + 2014-07-01 Marek Polacek PR c/58286 diff --git a/gcc/testsuite/gcc.dg/Wint-conversion.c b/gcc/testsuite/gcc.dg/Wint-conversion.c new file mode 100644 index 000000000000..1b7a03e43112 --- /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; +}