]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/58286 (Need option to make incompatible pointer type warnings into compiler...
authorMarek Polacek <polacek@redhat.com>
Tue, 1 Jul 2014 08:31:58 +0000 (08:31 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 1 Jul 2014 08:31:58 +0000 (08:31 +0000)
PR c/58286
* doc/invoke.texi: Document -Wincompatible-pointer-types.
c-family/
* c.opt (Wincompatible-pointer-types): New option.
c/
* c-typeck.c (convert_for_assignment): Pass
OPT_Wincompatible_pointer_types instead of 0 to WARN_FOR_ASSIGNMENT.
testsuite/
* gcc.dg/Wincompatible-pointer-types.c: New test.

From-SVN: r212192

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/Wincompatible-pointer-types.c [new file with mode: 0644]

index f5a242641a8ce25db7b7daa718270311bfa9c19b..76dc43c715ca09734f0a76d09a2de9cc1cc40adc 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c/58286
+       * doc/invoke.texi: Document -Wincompatible-pointer-types.
+
 2014-07-01  Martin Liska  <mliska@suse.cz>
 
        IPA REF alias refactoring
index 341df696859883b93f38af3c7da73fe1154539d6..e8d2942482ad062926b1d1972e8349b92e6fd20d 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c/58286
+       * c.opt (Wincompatible-pointer-types): New option.
+
 2014-06-30  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/51400
index 1d02bae30635a2956c68ab3e14b129131d49a048..6448b1b9495c526adda10965f575aa6c234bedd1 100644 (file)
@@ -443,6 +443,10 @@ Wignored-qualifiers
 C C++ Var(warn_ignored_qualifiers) Warning EnabledBy(Wextra)
 Warn whenever type qualifiers are ignored.
 
+Wincompatible-pointer-types
+C ObjC Var(warn_incompatible_pointer_types) Init(1) Warning
+Warn when there is a conversion between pointers that have incompatible types
+
 Winit-self
 C ObjC C++ ObjC++ Var(warn_init_self) Warning LangEnabledBy(C++ ObjC++,Wall)
 Warn about variables which are initialized to themselves
index 6740d513d660e1492a9c571d4e67426339970067..c64c553a5aad79ee3527a907e0ae45a4a1bc9b7d 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2014-06-30  Marek Polacek  <polacek@redhat.com>
 
        * c-decl.c (grokdeclarator): Don't instrument VLAs if the function
index b62e83012ee7f6c41a0f96371acf467f54448104..fff26a3993ab3777eb81834549a5064cb79f80d9 100644 (file)
@@ -6189,7 +6189,8 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
       else
        /* Avoid warning about the volatile ObjC EH puts on decls.  */
        if (!objc_ok)
-         WARN_FOR_ASSIGNMENT (location, expr_loc, 0,
+         WARN_FOR_ASSIGNMENT (location, expr_loc,
+                              OPT_Wincompatible_pointer_types,
                               G_("passing argument %d of %qE from "
                                  "incompatible pointer type"),
                               G_("assignment from incompatible pointer type"),
index dbc11328a9b53579fd51f6eab00ce66d6d6ee52b..409fa1716a86421a6014099b583165aab5f9ccc8 100644 (file)
@@ -251,7 +251,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
 -Wformat-security  -Wformat-signedness  -Wformat-y2k @gol
 -Wframe-larger-than=@var{len} -Wno-free-nonheap-object -Wjump-misses-init @gol
--Wignored-qualifiers @gol
+-Wignored-qualifiers  -Wincompatible-pointer-types @gol
 -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int @gol
 -Winit-self  -Winline @gol
 -Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol
@@ -4199,14 +4199,20 @@ This option is only active when @option{-ftree-vrp} is active
 (default for @option{-O2} and above). It warns about subscripts to arrays
 that are always out of bounds. This warning is enabled by @option{-Wall}.
 
-@item -Wno-discarded-qualifiers
+@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
 @opindex Wno-discarded-qualifiers
 @opindex Wdiscarded-qualifiers
 Do not warn if type qualifiers on pointers are being discarded.
 Typically, the compiler will warn if a @code{const char *} variable is
 passed to a function that takes @code{char *} parameter.  This option
-can be used to suppress such a warning.  This warning is only supported
-for C.
+can be used to suppress such a warning.
+
+@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
+@opindex Wno-incompatible-pointer-types
+@opindex Wincompatible-pointer-types
+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-div-by-zero
 @opindex Wno-div-by-zero
index 854f7cff6d613a9c5c225cd7ddb2f8875f56deed..6dc8f950bfa05e89d3a02cf0069b9eb5034aa94a 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c/58286
+       * gcc.dg/Wincompatible-pointer-types.c: New test.
+
 2014-06-30  David Holsgrove <david.holsgrove@xilinx.com>
 
        * gcc/testsuite/lib/scanasm.exp (dg-function-on-line): Add
diff --git a/gcc/testsuite/gcc.dg/Wincompatible-pointer-types.c b/gcc/testsuite/gcc.dg/Wincompatible-pointer-types.c
new file mode 100644 (file)
index 0000000..e765b27
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR c/58286 */
+/* { dg-do compile } */
+/* { dg-options "-Wno-incompatible-pointer-types" } */
+
+void
+fn2 (short *s, long *l)
+{
+}
+
+unsigned *
+fn1 (void)
+{
+  int (*fpi) (int);
+  int (*fpd) (double) = fpi;
+  fpi = fpd;
+  char *di;
+  float *dp = &di;
+  di = dp;
+  fn2 (dp, di);
+  return dp;
+}