re PR c/37186 (-Wno-error=pointer-sign does not work)

2008-08-27  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.

From-SVN: r139680
parent 9a424841
2008-08-27 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.
2008-08-27 Paolo Carlini <paolo.carlini@oracle.com> 2008-08-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/35321 PR c++/35321
......
...@@ -3952,24 +3952,24 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -3952,24 +3952,24 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
/* This macro is used to emit diagnostics to ensure that all format /* This macro is used to emit diagnostics to ensure that all format
strings are complete sentences, visible to gettext and checked at strings are complete sentences, visible to gettext and checked at
compile time. */ compile time. */
#define WARN_FOR_ASSIGNMENT(LOCATION, AR, AS, IN, RE) \ #define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE) \
do { \ do { \
switch (errtype) \ switch (errtype) \
{ \ { \
case ic_argpass: \ case ic_argpass: \
pedwarn (LOCATION, 0, AR, parmnum, rname); \ pedwarn (LOCATION, OPT, AR, parmnum, rname); \
break; \ break; \
case ic_argpass_nonproto: \ case ic_argpass_nonproto: \
warning (0, AR, parmnum, rname); \ warning (OPT, AR, parmnum, rname); \
break; \ break; \
case ic_assign: \ case ic_assign: \
pedwarn (LOCATION, 0, AS); \ pedwarn (LOCATION, OPT, AS); \
break; \ break; \
case ic_init: \ case ic_init: \
pedwarn (LOCATION, 0, IN); \ pedwarn (LOCATION, OPT, IN); \
break; \ break; \
case ic_return: \ case ic_return: \
pedwarn (LOCATION, 0, RE); \ pedwarn (LOCATION, OPT, RE); \
break; \ break; \
default: \ default: \
gcc_unreachable (); \ gcc_unreachable (); \
...@@ -4151,7 +4151,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -4151,7 +4151,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
function where an ordinary one is wanted, but not function where an ordinary one is wanted, but not
vice-versa. */ vice-versa. */
if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr)) if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
WARN_FOR_ASSIGNMENT (input_location, WARN_FOR_ASSIGNMENT (input_location, 0,
G_("passing argument %d of %qE " G_("passing argument %d of %qE "
"makes qualified function " "makes qualified function "
"pointer from unqualified"), "pointer from unqualified"),
...@@ -4165,7 +4165,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -4165,7 +4165,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
"pointer from unqualified")); "pointer from unqualified"));
} }
else if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl)) 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 " G_("passing argument %d of %qE discards "
"qualifiers from pointer target type"), "qualifiers from pointer target type"),
G_("assignment discards qualifiers " G_("assignment discards qualifiers "
...@@ -4265,7 +4265,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -4265,7 +4265,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
(VOID_TYPE_P (ttr) (VOID_TYPE_P (ttr)
&& !null_pointer_constant_p (rhs) && !null_pointer_constant_p (rhs)
&& TREE_CODE (ttl) == FUNCTION_TYPE))) && 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 " G_("ISO C forbids passing argument %d of "
"%qE between function pointer " "%qE between function pointer "
"and %<void *%>"), "and %<void *%>"),
...@@ -4303,7 +4303,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -4303,7 +4303,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
; ;
/* If there is a mismatch, do warn. */ /* If there is a mismatch, do warn. */
else if (warn_pointer_sign) else if (warn_pointer_sign)
WARN_FOR_ASSIGNMENT (input_location, WARN_FOR_ASSIGNMENT (input_location, OPT_Wpointer_sign,
G_("pointer targets in passing argument " G_("pointer targets in passing argument "
"%d of %qE differ in signedness"), "%d of %qE differ in signedness"),
G_("pointer targets in assignment " G_("pointer targets in assignment "
...@@ -4321,7 +4321,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -4321,7 +4321,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
it is okay to use a const or volatile function it is okay to use a const or volatile function
where an ordinary one is wanted, but not vice-versa. */ where an ordinary one is wanted, but not vice-versa. */
if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr)) 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 " G_("passing argument %d of %qE makes "
"qualified function pointer " "qualified function pointer "
"from unqualified"), "from unqualified"),
...@@ -4336,7 +4336,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -4336,7 +4336,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
else else
/* Avoid warning about the volatile ObjC EH puts on decls. */ /* Avoid warning about the volatile ObjC EH puts on decls. */
if (!objc_ok) if (!objc_ok)
WARN_FOR_ASSIGNMENT (input_location, WARN_FOR_ASSIGNMENT (input_location, 0,
G_("passing argument %d of %qE from " G_("passing argument %d of %qE from "
"incompatible pointer type"), "incompatible pointer type"),
G_("assignment from incompatible pointer type"), G_("assignment from incompatible pointer type"),
...@@ -4359,7 +4359,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -4359,7 +4359,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
or one that results from arithmetic, even including or one that results from arithmetic, even including
a cast to integer type. */ a cast to integer type. */
if (!null_pointer_constant_p (rhs)) if (!null_pointer_constant_p (rhs))
WARN_FOR_ASSIGNMENT (input_location, WARN_FOR_ASSIGNMENT (input_location, 0,
G_("passing argument %d of %qE makes " G_("passing argument %d of %qE makes "
"pointer from integer without a cast"), "pointer from integer without a cast"),
G_("assignment makes pointer from integer " G_("assignment makes pointer from integer "
...@@ -4373,7 +4373,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -4373,7 +4373,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
} }
else if (codel == INTEGER_TYPE && coder == POINTER_TYPE) 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 " G_("passing argument %d of %qE makes integer "
"from pointer without a cast"), "from pointer without a cast"),
G_("assignment makes integer from pointer " G_("assignment makes integer from pointer "
......
2008-08-27 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c/37186
* gcc.dg/pr37186.c: New.
2008-08-27 Janis Johnson <janis187@us.ibm.com> 2008-08-27 Janis Johnson <janis187@us.ibm.com>
* gcc.dg/torture/type-generic-1.c: Revert previous change. * gcc.dg/torture/type-generic-1.c: Revert previous change.
......
/* 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" } */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment