From: Andreas Jaeger Date: Tue, 18 Jan 2005 06:03:46 +0000 (+0100) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2fd382112219f61042c6521d4b288888d52f8bc;p=gcc.git [multiple changes] 2005-01-18 Andi Kleen * 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 * gcc.dg/Wno-pointer-sign.c: New test for -Wno-pointer-sign. From-SVN: r93813 --- diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 0d7c019cdbb..2b065023aa5 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 c93fe7e895a..8267e0ee497 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 db2c795421e..d13feda555e 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 3c1611399e6..06441c8ac7c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-01-18 Michael Matz + + * gcc.dg/Wno-pointer-sign.c: New test for -Wno-pointer-sign. + 2005-01-17 Diego Novillo 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 00000000000..780c9d4e207 --- /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" } */ +}