This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] [PR19090] Add -Wno-pointer-sign option
On Sun, Jan 09, 2005 at 09:46:14PM -0500, Andrew Pinski wrote:
>
> On Jan 9, 2005, at 9:44 PM, Andi Kleen wrote:
>
> >+@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.
>
> One comment from me, please add this only works with C and Objective-C
> since this section is for all warnings.
Here's a new patch with this changed.
-Andi
2005-01-10 Andi Kleen <ak@muc.de>
PR19090
* gcc/gcc/doc/invoke.texi (Warning Options): Document -Wno-pointer-sign.
* gcc/gcc/c-opts.c (c_common_handle_option): Handle warn_pointer_sign.
* gcc/gcc/c-typeck.c (convert_for_assignment): Check warn_pointer_sign.
* gcc/gcc/c-common.h: Add warn_pointer_sign
* gcc/gcc/c.opt (Wpointer-sign): Add.
? gcc/testsuite/gcc.dg/vect/vect-none.s
Index: gcc/c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.273
diff -u -u -r1.273 c-common.h
--- gcc/c-common.h 20 Dec 2004 20:11:17 -0000 1.273
+++ gcc/c-common.h 10 Jan 2005 03:33:42 -0000
@@ -444,6 +444,9 @@
extern int warn_main;
+/* Warn if pointer differs in signedness */
+
+extern int warn_pointer_sign;
/* ObjC language option variables. */
Index: gcc/c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.133
diff -u -u -r1.133 c-opts.c
--- gcc/c-opts.c 30 Nov 2004 14:10:08 -0000 1.133
+++ gcc/c-opts.c 10 Jan 2005 03:33:43 -0000
@@ -501,6 +501,10 @@
warn_write_strings = value;
break;
+ case OPT_Wpointer_sign:
+ warn_pointer_sign = value;
+ break;
+
case OPT_ansi:
if (!c_dialect_cxx ())
set_std_c89 (false, true);
Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.407
diff -u -u -r1.407 c-typeck.c
--- gcc/c-typeck.c 5 Jan 2005 15:22:38 -0000 1.407
+++ gcc/c-typeck.c 10 Jan 2005 03:33:47 -0000
@@ -63,6 +63,9 @@
/* The level of nesting inside "typeof". */
int in_typeof;
+/* Warn when a pointer differs in signedness. */
+int warn_pointer_sign = 1;
+
/* Nonzero if we've already printed a "missing braces around initializer"
message within this initializer. */
static int missing_braces_mentioned;
@@ -3654,7 +3657,7 @@
|| 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: gcc/c.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c.opt,v
retrieving revision 1.33
diff -u -u -r1.33 c.opt
--- gcc/c.opt 28 Aug 2004 02:33:48 -0000 1.33
+++ gcc/c.opt 10 Jan 2005 03:33:47 -0000
@@ -430,6 +430,10 @@
C ObjC C++ ObjC++
Give strings the type \"array of char\"
+Wpointer-sign
+C ObjC
+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: gcc/intl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/intl.c,v
retrieving revision 1.11
diff -u -u -r1.11 intl.c
--- gcc/intl.c 23 Jul 2004 06:59:34 -0000 1.11
+++ gcc/intl.c 10 Jan 2005 03:33:48 -0000
@@ -59,27 +59,6 @@
/* Closing quotation mark. */
close_quote = _("'");
-
- if (!strcmp (open_quote, "`") && !strcmp (close_quote, "'"))
- {
-#if defined HAVE_LANGINFO_CODESET
- const char *encoding;
-#endif
- /* Untranslated quotes that it may be possible to replace with
- U+2018 and U+2019; but otherwise use "'" instead of "`" as
- opening quote. */
- open_quote = "'";
-#if defined HAVE_LANGINFO_CODESET
- encoding = nl_langinfo (CODESET);
- if (encoding != NULL
- && (!strcasecmp (encoding, "utf-8")
- || !strcasecmp (encoding, "utf8")))
- {
- open_quote = "\xe2\x80\x98";
- close_quote = "\xe2\x80\x99";
- }
-#endif
- }
}
#if defined HAVE_WCHAR_H && defined HAVE_WORKING_MBSTOWCS && defined HAVE_WCSWIDTH
Index: gcc/doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.564
diff -u -u -r1.564 invoke.texi
--- gcc/doc/invoke.texi 5 Jan 2005 09:55:55 -0000 1.564
+++ gcc/doc/invoke.texi 10 Jan 2005 03:33:57 -0000
@@ -3135,6 +3135,12 @@
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.