public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR c/37186 -Wno-error=pointer-sign does not work
@ 2008-08-22 11:57 Manuel López-Ibáñez
  2008-08-25  8:38 ` Manuel López-Ibáñez
  2008-08-28 21:55 ` Joseph S. Myers
  0 siblings, 2 replies; 6+ messages in thread
From: Manuel López-Ibáñez @ 2008-08-22 11:57 UTC (permalink / raw)
  To: Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
--enable-languages=all,ada

OK for trunk?

2008-08-22  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR c/37186
	* c-typeck.c (WARN_FOR_ASSIGNMENT): Add OPT parameter.
	(convert_for_assignment): Pass corrent OPT_W* parameter to
	WARN_FOR_ASSIGNMENT.
testsuite/
	* gcc.dg/pr37186.c: New.

[-- Attachment #2: fix-pr37186.diff --]
[-- Type: text/plain, Size: 6167 bytes --]

Index: gcc/testsuite/gcc.dg/pr37186.c
===================================================================
--- gcc/testsuite/gcc.dg/pr37186.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr37186.c	(revision 0)
@@ -0,0 +1,9 @@
+/* PR 37186 */
+/* { dg-do compile } */
+/* { dg-options "-Wall -Werror -Wno-error=pointer-sign" } */
+
+int foo(signed char *);
+int bar(unsigned char *p)
+{
+  return foo(p); /* { dg-warning "pointer targets in passing argument 1 of 'foo' differ in signedness" } */
+}
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c	(revision 139401)
+++ gcc/c-typeck.c	(working copy)
@@ -3950,28 +3950,28 @@ convert_for_assignment (tree type, tree 
     }
 
   /* This macro is used to emit diagnostics to ensure that all format
      strings are complete sentences, visible to gettext and checked at
      compile time.  */
-#define WARN_FOR_ASSIGNMENT(LOCATION, AR, AS, IN, RE)	\
+#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE)	\
   do {						\
     switch (errtype)				\
       {						\
       case ic_argpass:				\
-	pedwarn (LOCATION, 0, AR, parmnum, rname);	\
+	pedwarn (LOCATION, OPT, AR, parmnum, rname);	\
 	break;					\
       case ic_argpass_nonproto:			\
-	warning (0, AR, parmnum, rname);	\
+	warning (OPT, AR, parmnum, rname);	\
 	break;					\
       case ic_assign:				\
-	pedwarn (LOCATION, 0, AS);			\
+	pedwarn (LOCATION, OPT, AS);			\
 	break;					\
       case ic_init:				\
-	pedwarn (LOCATION, 0, IN);			\
+	pedwarn (LOCATION, OPT, IN);			\
 	break;					\
       case ic_return:				\
-	pedwarn (LOCATION, 0, RE);			\
+	pedwarn (LOCATION, OPT, RE);			\
 	break;					\
       default:					\
 	gcc_unreachable ();			\
       }						\
   } while (0)
@@ -4149,11 +4149,11 @@ convert_for_assignment (tree type, tree 
 		     restrictions that say the function will not do
 		     certain things, it is okay to use a const or volatile
 		     function where an ordinary one is wanted, but not
 		     vice-versa.  */
 		  if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
-		    WARN_FOR_ASSIGNMENT (input_location,
+		    WARN_FOR_ASSIGNMENT (input_location, 0,
 					 G_("passing argument %d of %qE "
 					    "makes qualified function "
 					    "pointer from unqualified"),
 					 G_("assignment makes qualified "
 					    "function pointer from "
@@ -4163,11 +4163,11 @@ convert_for_assignment (tree type, tree 
 					    "unqualified"),
 					 G_("return makes qualified function "
 					    "pointer from unqualified"));
 		}
 	      else if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl))
-		WARN_FOR_ASSIGNMENT (input_location,
+		WARN_FOR_ASSIGNMENT (input_location, 0,
 				     G_("passing argument %d of %qE discards "
 					"qualifiers from pointer target type"),
 				     G_("assignment discards qualifiers "
 					"from pointer target type"),
 				     G_("initialization discards qualifiers "
@@ -4263,11 +4263,11 @@ convert_for_assignment (tree type, tree 
 	      && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
 		  ||
 		  (VOID_TYPE_P (ttr)
 		   && !null_pointer_constant_p (rhs)
 		   && TREE_CODE (ttl) == FUNCTION_TYPE)))
-	    WARN_FOR_ASSIGNMENT (input_location,
+	    WARN_FOR_ASSIGNMENT (input_location, OPT_pedantic,
 				 G_("ISO C forbids passing argument %d of "
 				    "%qE between function pointer "
 				    "and %<void *%>"),
 				 G_("ISO C forbids assignment between "
 				    "function pointer and %<void *%>"),
@@ -4301,11 +4301,11 @@ convert_for_assignment (tree type, tree 
 	      else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
 		       || target_cmp)
 		;
 	      /* If there is a mismatch, do warn.  */
 	      else if (warn_pointer_sign)
-		WARN_FOR_ASSIGNMENT (input_location,
+		WARN_FOR_ASSIGNMENT (input_location, OPT_Wpointer_sign,
 				     G_("pointer targets in passing argument "
 					"%d of %qE differ in signedness"),
 				     G_("pointer targets in assignment "
 					"differ in signedness"),
 				     G_("pointer targets in initialization "
@@ -4319,11 +4319,11 @@ convert_for_assignment (tree type, tree 
 	      /* Because const and volatile on functions are restrictions
 		 that say the function will not do certain things,
 		 it is okay to use a const or volatile function
 		 where an ordinary one is wanted, but not vice-versa.  */
 	      if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
-		WARN_FOR_ASSIGNMENT (input_location,
+		WARN_FOR_ASSIGNMENT (input_location, 0,
 				     G_("passing argument %d of %qE makes "
 					"qualified function pointer "
 					"from unqualified"),
 				     G_("assignment makes qualified function "
 					"pointer from unqualified"),
@@ -4334,11 +4334,11 @@ convert_for_assignment (tree type, tree 
 	    }
 	}
       else
 	/* Avoid warning about the volatile ObjC EH puts on decls.  */
 	if (!objc_ok)
-	  WARN_FOR_ASSIGNMENT (input_location,
+	  WARN_FOR_ASSIGNMENT (input_location, 0,
 			       G_("passing argument %d of %qE from "
 				  "incompatible pointer type"),
 			       G_("assignment from incompatible pointer type"),
 			       G_("initialization from incompatible "
 				  "pointer type"),
@@ -4357,11 +4357,11 @@ convert_for_assignment (tree type, tree 
     {
       /* An explicit constant 0 can convert to a pointer,
 	 or one that results from arithmetic, even including
 	 a cast to integer type.  */
       if (!null_pointer_constant_p (rhs))
-	WARN_FOR_ASSIGNMENT (input_location,
+	WARN_FOR_ASSIGNMENT (input_location, 0,
 			     G_("passing argument %d of %qE makes "
 				"pointer from integer without a cast"),
 			     G_("assignment makes pointer from integer "
 				"without a cast"),
 			     G_("initialization makes pointer from "
@@ -4371,11 +4371,11 @@ convert_for_assignment (tree type, tree 
 
       return convert (type, rhs);
     }
   else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
     {
-      WARN_FOR_ASSIGNMENT (input_location,
+      WARN_FOR_ASSIGNMENT (input_location, 0,
 			   G_("passing argument %d of %qE makes integer "
 			      "from pointer without a cast"),
 			   G_("assignment makes integer from pointer "
 			      "without a cast"),
 			   G_("initialization makes integer from pointer "

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/37186 -Wno-error=pointer-sign does not work
  2008-08-22 11:57 PR c/37186 -Wno-error=pointer-sign does not work Manuel López-Ibáñez
@ 2008-08-25  8:38 ` Manuel López-Ibáñez
  2008-08-28 21:55 ` Joseph S. Myers
  1 sibling, 0 replies; 6+ messages in thread
From: Manuel López-Ibáñez @ 2008-08-25  8:38 UTC (permalink / raw)
  To: Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 541 bytes --]

PING: http://gcc.gnu.org/ml/gcc-patches/2008-08/msg01634.html

2008/8/22 Manuel López-Ibáñez <lopezibanez@gmail.com>:
> Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
> --enable-languages=all,ada
>
> OK for trunk?
>
> 2008-08-22  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
>
>        PR c/37186
>        * c-typeck.c (WARN_FOR_ASSIGNMENT): Add OPT parameter.
>        (convert_for_assignment): Pass corrent OPT_W* parameter to
>        WARN_FOR_ASSIGNMENT.
> testsuite/
>        * gcc.dg/pr37186.c: New.
>

[-- Attachment #2: fix-pr37186.diff --]
[-- Type: text/plain, Size: 6167 bytes --]

Index: gcc/testsuite/gcc.dg/pr37186.c
===================================================================
--- gcc/testsuite/gcc.dg/pr37186.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr37186.c	(revision 0)
@@ -0,0 +1,9 @@
+/* PR 37186 */
+/* { dg-do compile } */
+/* { dg-options "-Wall -Werror -Wno-error=pointer-sign" } */
+
+int foo(signed char *);
+int bar(unsigned char *p)
+{
+  return foo(p); /* { dg-warning "pointer targets in passing argument 1 of 'foo' differ in signedness" } */
+}
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c	(revision 139401)
+++ gcc/c-typeck.c	(working copy)
@@ -3950,28 +3950,28 @@ convert_for_assignment (tree type, tree 
     }
 
   /* This macro is used to emit diagnostics to ensure that all format
      strings are complete sentences, visible to gettext and checked at
      compile time.  */
-#define WARN_FOR_ASSIGNMENT(LOCATION, AR, AS, IN, RE)	\
+#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE)	\
   do {						\
     switch (errtype)				\
       {						\
       case ic_argpass:				\
-	pedwarn (LOCATION, 0, AR, parmnum, rname);	\
+	pedwarn (LOCATION, OPT, AR, parmnum, rname);	\
 	break;					\
       case ic_argpass_nonproto:			\
-	warning (0, AR, parmnum, rname);	\
+	warning (OPT, AR, parmnum, rname);	\
 	break;					\
       case ic_assign:				\
-	pedwarn (LOCATION, 0, AS);			\
+	pedwarn (LOCATION, OPT, AS);			\
 	break;					\
       case ic_init:				\
-	pedwarn (LOCATION, 0, IN);			\
+	pedwarn (LOCATION, OPT, IN);			\
 	break;					\
       case ic_return:				\
-	pedwarn (LOCATION, 0, RE);			\
+	pedwarn (LOCATION, OPT, RE);			\
 	break;					\
       default:					\
 	gcc_unreachable ();			\
       }						\
   } while (0)
@@ -4149,11 +4149,11 @@ convert_for_assignment (tree type, tree 
 		     restrictions that say the function will not do
 		     certain things, it is okay to use a const or volatile
 		     function where an ordinary one is wanted, but not
 		     vice-versa.  */
 		  if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
-		    WARN_FOR_ASSIGNMENT (input_location,
+		    WARN_FOR_ASSIGNMENT (input_location, 0,
 					 G_("passing argument %d of %qE "
 					    "makes qualified function "
 					    "pointer from unqualified"),
 					 G_("assignment makes qualified "
 					    "function pointer from "
@@ -4163,11 +4163,11 @@ convert_for_assignment (tree type, tree 
 					    "unqualified"),
 					 G_("return makes qualified function "
 					    "pointer from unqualified"));
 		}
 	      else if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl))
-		WARN_FOR_ASSIGNMENT (input_location,
+		WARN_FOR_ASSIGNMENT (input_location, 0,
 				     G_("passing argument %d of %qE discards "
 					"qualifiers from pointer target type"),
 				     G_("assignment discards qualifiers "
 					"from pointer target type"),
 				     G_("initialization discards qualifiers "
@@ -4263,11 +4263,11 @@ convert_for_assignment (tree type, tree 
 	      && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
 		  ||
 		  (VOID_TYPE_P (ttr)
 		   && !null_pointer_constant_p (rhs)
 		   && TREE_CODE (ttl) == FUNCTION_TYPE)))
-	    WARN_FOR_ASSIGNMENT (input_location,
+	    WARN_FOR_ASSIGNMENT (input_location, OPT_pedantic,
 				 G_("ISO C forbids passing argument %d of "
 				    "%qE between function pointer "
 				    "and %<void *%>"),
 				 G_("ISO C forbids assignment between "
 				    "function pointer and %<void *%>"),
@@ -4301,11 +4301,11 @@ convert_for_assignment (tree type, tree 
 	      else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
 		       || target_cmp)
 		;
 	      /* If there is a mismatch, do warn.  */
 	      else if (warn_pointer_sign)
-		WARN_FOR_ASSIGNMENT (input_location,
+		WARN_FOR_ASSIGNMENT (input_location, OPT_Wpointer_sign,
 				     G_("pointer targets in passing argument "
 					"%d of %qE differ in signedness"),
 				     G_("pointer targets in assignment "
 					"differ in signedness"),
 				     G_("pointer targets in initialization "
@@ -4319,11 +4319,11 @@ convert_for_assignment (tree type, tree 
 	      /* Because const and volatile on functions are restrictions
 		 that say the function will not do certain things,
 		 it is okay to use a const or volatile function
 		 where an ordinary one is wanted, but not vice-versa.  */
 	      if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
-		WARN_FOR_ASSIGNMENT (input_location,
+		WARN_FOR_ASSIGNMENT (input_location, 0,
 				     G_("passing argument %d of %qE makes "
 					"qualified function pointer "
 					"from unqualified"),
 				     G_("assignment makes qualified function "
 					"pointer from unqualified"),
@@ -4334,11 +4334,11 @@ convert_for_assignment (tree type, tree 
 	    }
 	}
       else
 	/* Avoid warning about the volatile ObjC EH puts on decls.  */
 	if (!objc_ok)
-	  WARN_FOR_ASSIGNMENT (input_location,
+	  WARN_FOR_ASSIGNMENT (input_location, 0,
 			       G_("passing argument %d of %qE from "
 				  "incompatible pointer type"),
 			       G_("assignment from incompatible pointer type"),
 			       G_("initialization from incompatible "
 				  "pointer type"),
@@ -4357,11 +4357,11 @@ convert_for_assignment (tree type, tree 
     {
       /* An explicit constant 0 can convert to a pointer,
 	 or one that results from arithmetic, even including
 	 a cast to integer type.  */
       if (!null_pointer_constant_p (rhs))
-	WARN_FOR_ASSIGNMENT (input_location,
+	WARN_FOR_ASSIGNMENT (input_location, 0,
 			     G_("passing argument %d of %qE makes "
 				"pointer from integer without a cast"),
 			     G_("assignment makes pointer from integer "
 				"without a cast"),
 			     G_("initialization makes pointer from "
@@ -4371,11 +4371,11 @@ convert_for_assignment (tree type, tree 
 
       return convert (type, rhs);
     }
   else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
     {
-      WARN_FOR_ASSIGNMENT (input_location,
+      WARN_FOR_ASSIGNMENT (input_location, 0,
 			   G_("passing argument %d of %qE makes integer "
 			      "from pointer without a cast"),
 			   G_("assignment makes integer from pointer "
 			      "without a cast"),
 			   G_("initialization makes integer from pointer "

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/37186 -Wno-error=pointer-sign does not work
  2008-08-22 11:57 PR c/37186 -Wno-error=pointer-sign does not work Manuel López-Ibáñez
  2008-08-25  8:38 ` Manuel López-Ibáñez
@ 2008-08-28 21:55 ` Joseph S. Myers
  2008-08-29  0:14   ` Paolo Carlini
  1 sibling, 1 reply; 6+ messages in thread
From: Joseph S. Myers @ 2008-08-28 21:55 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: Gcc Patch List

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 495 bytes --]

On Fri, 22 Aug 2008, Manuel López-Ibáñez wrote:

> Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
> --enable-languages=all,ada
> 
> OK for trunk?
> 
> 2008-08-22  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
> 
> 	PR c/37186
> 	* c-typeck.c (WARN_FOR_ASSIGNMENT): Add OPT parameter.
> 	(convert_for_assignment): Pass corrent OPT_W* parameter to
> 	WARN_FOR_ASSIGNMENT.
> testsuite/
> 	* gcc.dg/pr37186.c: New.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/37186 -Wno-error=pointer-sign does not work
  2008-08-28 21:55 ` Joseph S. Myers
@ 2008-08-29  0:14   ` Paolo Carlini
  2008-08-29  0:17     ` Manuel López-Ibáñez
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Carlini @ 2008-08-29  0:14 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Manuel López-Ibáñez, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

Joseph S. Myers wrote:
> On Fri, 22 Aug 2008, Manuel L�pez-Ib��ez wrote:
>
>   
>> Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
>> --enable-languages=all,ada
>>
>> OK for trunk?
>>
>> 2008-08-22  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
>>
>> 	PR c/37186
>> 	* c-typeck.c (WARN_FOR_ASSIGNMENT): Add OPT parameter.
>> 	(convert_for_assignment): Pass corrent OPT_W* parameter to
>> 	WARN_FOR_ASSIGNMENT.
>> testsuite/
>> 	* gcc.dg/pr37186.c: New.
>>     
> OK.
>   
I committed as obvious the below to unbreak a C/C++ bootstrap. Apologies 
in case my patchlet isn't fully correct.

Paolo.

////////////


[-- Attachment #2: CL_boot --]
[-- Type: text/plain, Size: 159 bytes --]

2008-08-27  Paolo Carlini  <paolo.carlini@oracle.com>

	* c-typeck.c (convert_for_assignment): Adjust WARN_FOR_ASSIGNMENT
	use not updated in the last change.

[-- Attachment #3: patch_boot --]
[-- Type: text/plain, Size: 950 bytes --]

Index: c-typeck.c
===================================================================
*** c-typeck.c	(revision 139687)
--- c-typeck.c	(working copy)
*************** convert_for_assignment (tree type, tree
*** 4286,4292 ****
  		     qualifier are acceptable if the 'volatile' has been added
  		     in by the Objective-C EH machinery.  */
  		  if (!objc_type_quals_match (ttl, ttr))
! 		    WARN_FOR_ASSIGNMENT (input_location,
  					 G_("passing argument %d of %qE discards "
  					    "qualifiers from pointer target type"),
  					 G_("assignment discards qualifiers "
--- 4286,4292 ----
  		     qualifier are acceptable if the 'volatile' has been added
  		     in by the Objective-C EH machinery.  */
  		  if (!objc_type_quals_match (ttl, ttr))
! 		    WARN_FOR_ASSIGNMENT (input_location, 0,
  					 G_("passing argument %d of %qE discards "
  					    "qualifiers from pointer target type"),
  					 G_("assignment discards qualifiers "

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/37186 -Wno-error=pointer-sign does not work
  2008-08-29  0:14   ` Paolo Carlini
@ 2008-08-29  0:17     ` Manuel López-Ibáñez
  2008-08-30 10:08       ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Manuel López-Ibáñez @ 2008-08-29  0:17 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: Joseph S. Myers, Gcc Patch List

2008/8/28 Paolo Carlini <paolo.carlini@oracle.com>:
>
> I committed as obvious the below to unbreak a C/C++ bootstrap. Apologies in
> case my patchlet isn't fully correct.

The patch is correct but it is weird because I did a full bootstrap
with --enable-languages=all,ada.

Cheers,

Manuel.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/37186 -Wno-error=pointer-sign does not work
  2008-08-29  0:17     ` Manuel López-Ibáñez
@ 2008-08-30 10:08       ` H.J. Lu
  0 siblings, 0 replies; 6+ messages in thread
From: H.J. Lu @ 2008-08-30 10:08 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Paolo Carlini, Joseph S. Myers, Gcc Patch List

On Wed, Aug 27, 2008 at 5:48 PM, Manuel López-Ibáñez
<lopezibanez@gmail.com> wrote:
> 2008/8/28 Paolo Carlini <paolo.carlini@oracle.com>:
>>
>> I committed as obvious the below to unbreak a C/C++ bootstrap. Apologies in
>> case my patchlet isn't fully correct.
>
> The patch is correct but it is weird because I did a full bootstrap
> with --enable-languages=all,ada.
>

Hi,

It caused

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37271

-- 
H.J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-08-29  0:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-22 11:57 PR c/37186 -Wno-error=pointer-sign does not work Manuel López-Ibáñez
2008-08-25  8:38 ` Manuel López-Ibáñez
2008-08-28 21:55 ` Joseph S. Myers
2008-08-29  0:14   ` Paolo Carlini
2008-08-29  0:17     ` Manuel López-Ibáñez
2008-08-30 10:08       ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).