]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
invoke.texi: Document -Wint-conversion.
authorMarek Polacek <polacek@redhat.com>
Tue, 1 Jul 2014 08:53:12 +0000 (08:53 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 1 Jul 2014 08:53:12 +0000 (08:53 +0000)
* 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

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wint-conversion.c [new file with mode: 0644]

index 76dc43c715ca09734f0a76d09a2de9cc1cc40adc..14d19098562ec580cc9e9ae37b8a15addf5708cc 100644 (file)
@@ -1,3 +1,7 @@
+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
index e8d2942482ad062926b1d1972e8349b92e6fd20d..25acae88e95b4871f3910611a91533e83d3c0fa9 100644 (file)
@@ -1,3 +1,7 @@
+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
index 6448b1b9495c526adda10965f575aa6c234bedd1..c89040abf9ee962fb379c50a907b0d0b93b4a25d 100644 (file)
@@ -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
index c64c553a5aad79ee3527a907e0ae45a4a1bc9b7d..1c1936245d86ef0388a0df413c0991ecc9edf2bb 100644 (file)
@@ -1,3 +1,8 @@
+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
index fff26a3993ab3777eb81834549a5064cb79f80d9..35bfd1498769e4991b99d65422d4844969d8dedc 100644 (file)
@@ -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 "
index 409fa1716a86421a6014099b583165aab5f9ccc8..b1f6f4bcb57620495548fd41eed3a8f0d16063b6 100644 (file)
@@ -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
index 6dc8f950bfa05e89d3a02cf0069b9eb5034aa94a..0bb4e903ab7376bd7167f91b2865ff048809f953 100644 (file)
@@ -1,3 +1,7 @@
+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
diff --git a/gcc/testsuite/gcc.dg/Wint-conversion.c b/gcc/testsuite/gcc.dg/Wint-conversion.c
new file mode 100644 (file)
index 0000000..1b7a03e
--- /dev/null
@@ -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;
+}