[multiple changes]
authorAndreas Jaeger <aj@gcc.gnu.org>
Tue, 18 Jan 2005 06:03:46 +0000 (07:03 +0100)
committerAndreas Jaeger <aj@gcc.gnu.org>
Tue, 18 Jan 2005 06:03:46 +0000 (07:03 +0100)
2005-01-18  Andi Kleen <ak@muc.de>

* c-typeck.c: (convert_for_assignment): Check warn_pointer_sign.
* c.opt (-Wpointer-sign): Add.
* doc/invoke.texi: (-Wpointer-sign): Add.

2005-01-18  Michael Matz  <matz@suse.de>

* gcc.dg/Wno-pointer-sign.c: New test for -Wno-pointer-sign.

From-SVN: r93813

gcc/c-typeck.c
gcc/c.opt
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wno-pointer-sign.c [new file with mode: 0644]

index 0d7c019cdbb1fedb562a50f0c065a351c65acf55..2b065023aa5d195fe3109d640a44fc18012e598b 100644 (file)
@@ -3651,7 +3651,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
                       || target_cmp)
                ;
              /* If there is a mismatch, do warn.  */
-             else
+             else if (warn_pointer_sign)
                WARN_FOR_ASSIGNMENT (N_("pointer targets in passing argument "
                                        "%d of %qE differ in signedness"),
                                     N_("pointer targets in assignment "
index c93fe7e895a538716a6e82baa17d322d17ce71d7..8267e0ee49786c3a63c1b5be2c0bc4cfa3a1fb66 100644 (file)
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -1,5 +1,5 @@
 ; Options for the C, ObjC, C++ and ObjC++ front ends.
-; Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
 ;
 ; This file is part of GCC.
 ;
@@ -430,6 +430,10 @@ Wwrite-strings
 C ObjC C++ ObjC++
 Give strings the type \"array of char\"
 
+Wpointer-sign
+C ObjC Var(warn_pointer_sign) Init(1)
+Warn when a pointer differs in signedness in an assignment.
+
 ansi
 C ObjC C++ ObjC++
 A synonym for -std=c89.  In a future version of GCC it will become synonymous with -std=c99 instead
index db2c795421e81531645d41e2cd1d31413ff79fa5..d13feda555e150721129d7b44531e54dfc158334 100644 (file)
@@ -1,12 +1,12 @@
 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-@c 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+@c 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
 
 @ignore
 @c man begin COPYRIGHT
 Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
-1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
@@ -242,7 +242,7 @@ Objective-C and Objective-C++ Dialects}.
 @gccoptlist{-Wbad-function-cast  -Wmissing-declarations @gol
 -Wmissing-prototypes  -Wnested-externs  -Wold-style-definition @gol
 -Wstrict-prototypes  -Wtraditional @gol
--Wdeclaration-after-statement}
+-Wdeclaration-after-statement -Wno-pointer-sign}
 
 @item Debugging Options
 @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
@@ -3135,6 +3135,12 @@ effectively.  Often, the problem is that your code is too big or too
 complex; GCC will refuse to optimize programs when the optimization
 itself is likely to take inordinate amounts of time.
 
+@item -Wno-pointer-sign
+@opindex Wno-pointer-sign
+Don't warn for pointer argument passing or assignment with different signedness.
+Only useful in the negative form since this warning is enabled by default.
+This option is only supported for C and Objective-C@.
+
 @item -Werror
 @opindex Werror
 Make all warnings into errors.
@@ -10900,7 +10906,7 @@ However, when @option{-mbackchain} is also in effect, the topmost word of
 the save area is always used to store the backchain, and the return address
 register is always saved two words below the backchain.
 
-As long as the stack frame backchain is not used, code generated with 
+As long as the stack frame backchain is not used, code generated with
 @option{-mpacked-stack} is call-compatible with code generated with
 @option{-mno-packed-stack}.  Note that some non-FSF releases of GCC 2.95 for
 S/390 or zSeries generated code that uses the stack frame backchain at run
index 3c1611399e655d1ec231b3eefa717f7ebc21124e..06441c8ac7c06023ef34d93e6d5020d29f26fb91 100644 (file)
@@ -1,3 +1,7 @@
+2005-01-18  Michael Matz  <matz@suse.de>
+
+       * gcc.dg/Wno-pointer-sign.c: New test for -Wno-pointer-sign.
+
 2005-01-17  Diego Novillo  <dnovillo@redhat.com>
 
        PR tree-optimization/19121
diff --git a/gcc/testsuite/gcc.dg/Wno-pointer-sign.c b/gcc/testsuite/gcc.dg/Wno-pointer-sign.c
new file mode 100644 (file)
index 0000000..780c9d4
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-Wno-pointer-sign" } */
+
+void f1(long *);
+void f2(unsigned long *);
+
+int main()
+{
+  long *lp;
+  unsigned long *ulp;
+  char *cp;
+  unsigned char *ucp;
+  signed char *scp;
+
+  ulp = lp;    /* { dg-bogus " pointer targets in assignment differ in signedness" } */
+  lp = ulp;    /* { dg-bogus " pointer targets in assignment differ in signedness" } */
+  f1(ulp);     /* { dg-bogus " differ in signedness" } */
+  f2(lp);      /* { dg-bogus " differ in signedness" } */
+
+  cp = ucp;    /* { dg-bogus " pointer targets in assignment differ in signedness" } */
+  cp = scp;    /* { dg-bogus " pointer targets in assignment differ in signedness" } */
+  ucp = scp;   /* { dg-bogus " pointer targets in assignment differ in signedness" } */
+  ucp = cp;    /* { dg-bogus " pointer targets in assignment differ in signedness" } */
+  scp = ucp;   /* { dg-bogus " pointer targets in assignment differ in signedness" } */
+  scp = cp;    /* { dg-bogus " pointer targets in assignment differ in signedness" } */
+}