aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@gcc.gnu.org>2005-01-18 07:03:46 +0100
committerAndreas Jaeger <aj@gcc.gnu.org>2005-01-18 07:03:46 +0100
commitf2fd382112219f61042c6521d4b288888d52f8bc (patch)
tree682eabeadb86e7ed4277488a966cfaae164aead2 /gcc
parente1b83ac7fb32ca56fe0bf5ebfbb052b0054a39c3 (diff)
downloadgcc-f2fd382112219f61042c6521d4b288888d52f8bc.zip
gcc-f2fd382112219f61042c6521d4b288888d52f8bc.tar.gz
gcc-f2fd382112219f61042c6521d4b288888d52f8bc.tar.bz2
[multiple changes]
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c2
-rw-r--r--gcc/c.opt6
-rw-r--r--gcc/doc/invoke.texi14
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/Wno-pointer-sign.c26
5 files changed, 46 insertions, 6 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 0d7c019..2b06502 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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 "
diff --git a/gcc/c.opt b/gcc/c.opt
index c93fe7e..8267e0e 100644
--- 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
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index db2c795..d13feda 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3c16113..06441c8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..780c9d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wno-pointer-sign.c
@@ -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" } */
+}