This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [PR19090] Add -Wno-pointer-sign option


This patch adds a new option -Wno-pointer-sign to disable the 
"argument ... differs in pointer signedness" warning and related warnings.
This allows to disable a few thousand warnings that occur during a Linux
kernel build with gcc 4.0 which didn't occur with earlier compilers. 
The default is unchanged, the new flag just allows to go back to the
same state as earlier gcc compilers.

This fixes PR19090.

I don't have a CVS account so whoever approves it please commit too.

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.
	
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 02:33:44 -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 02:33:45 -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 02:33:50 -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 02:33:50 -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/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 02:33:59 -0000
@@ -3135,6 +3135,11 @@
 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.
+
 @item -Werror
 @opindex Werror
 Make all warnings into errors.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]