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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212193
138bc75d-0d04-0410-961f-
82ee72b054a4
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.
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.
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
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.
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 "
}
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 "
-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
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
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.
--- /dev/null
+/* { 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;
+}