Commit 296c53ac by Marek Polacek Committed by Marek Polacek

re PR c/81233 (--Wdiscarded-qualifiers and Wincompatible-pointer-types missing important detail)

	PR c/81233
	* c-typeck.c (pedwarn_init): Make the function take a variable list.
	Call emit_diagnostic_valist instead of pedwarn.
	(convert_for_assignment): Unroll the PEDWARN_FOR_ASSIGNMENT macro.
	Print the relevant types in diagnostics.

	* diagnostic-core.h (emit_diagnostic_valist): Add declaration.
	* diagnostic.c (emit_diagnostic): Add a comment.
	(emit_diagnostic_valist): New function.

	* gcc.dg/diagnostic-types-1.c: New test.
	* gcc.dg/assign-warn-1.c: Update warning messages.
	* gcc.dg/assign-warn-2.c: Likewise.
	* gcc.dg/c90-const-expr-5.c: Likewise.
	* gcc.dg/c99-const-expr-5.c: Likewise.
	* gcc.dg/conv-2.c: Likewise.
	* gcc.dg/init-bad-7.c: Likewise.
	* gcc.dg/overflow-warn-1.c: Likewise.
	* gcc.dg/overflow-warn-2.c: Likewise.
	* gcc.dg/overflow-warn-3.c: Likewise.
	* gcc.dg/overflow-warn-4.c: Likewise.
	* gcc.dg/pointer-array-atomic.c: Likewise.
	* gcc.dg/pr26865.c: Likewise.
	* gcc.dg/pr61162-2.c: Likewise.
	* gcc.dg/pr61162.c: Likewise.
	* gcc.dg/pr67730-2.c: Likewise.
	* gcc.dg/pr69156.c: Likewise.
	* gcc.dg/pr70174.c: Likewise.
	* objc.dg/proto-lossage-4.m: Likewise.

From-SVN: r250985
parent a32c8316
2017-08-09 Marek Polacek <polacek@redhat.com> 2017-08-09 Marek Polacek <polacek@redhat.com>
PR c/81233
* diagnostic-core.h (emit_diagnostic_valist): Add declaration.
* diagnostic.c (emit_diagnostic): Add a comment.
(emit_diagnostic_valist): New function.
2017-08-09 Marek Polacek <polacek@redhat.com>
PR c/81417 PR c/81417
* input.c (make_location): New overload. * input.c (make_location): New overload.
* input.h (make_location): Declare. * input.h (make_location): Declare.
......
2017-08-09 Marek Polacek <polacek@redhat.com> 2017-08-09 Marek Polacek <polacek@redhat.com>
PR c/81233
* c-typeck.c (pedwarn_init): Make the function take a variable list.
Call emit_diagnostic_valist instead of pedwarn.
(convert_for_assignment): Unroll the PEDWARN_FOR_ASSIGNMENT macro.
Print the relevant types in diagnostics.
2017-08-09 Marek Polacek <polacek@redhat.com>
PR c/81417 PR c/81417
* c-array-notation.c (fix_builtin_array_notation_fn): Update calls to * c-array-notation.c (fix_builtin_array_notation_fn): Update calls to
build_conditional_expr. build_conditional_expr.
......
...@@ -6065,20 +6065,19 @@ error_init (location_t loc, const char *gmsgid) ...@@ -6065,20 +6065,19 @@ error_init (location_t loc, const char *gmsgid)
it is unconditionally given. GMSGID identifies the message. The it is unconditionally given. GMSGID identifies the message. The
component name is taken from the spelling stack. */ component name is taken from the spelling stack. */
static void static void ATTRIBUTE_GCC_DIAG (3,0)
pedwarn_init (location_t loc, int opt, const char *gmsgid) pedwarn_init (location_t loc, int opt, const char *gmsgid, ...)
{ {
char *ofwhat;
bool warned;
/* Use the location where a macro was expanded rather than where /* Use the location where a macro was expanded rather than where
it was defined to make sure macros defined in system headers it was defined to make sure macros defined in system headers
but used incorrectly elsewhere are diagnosed. */ but used incorrectly elsewhere are diagnosed. */
source_location exploc = expansion_point_location_if_in_system_header (loc); source_location exploc = expansion_point_location_if_in_system_header (loc);
/* The gmsgid may be a format string with %< and %>. */ va_list ap;
warned = pedwarn (exploc, opt, gmsgid); va_start (ap, gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); bool warned = emit_diagnostic_valist (DK_PEDWARN, exploc, opt, gmsgid, &ap);
va_end (ap);
char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat && warned) if (*ofwhat && warned)
inform (exploc, "(near initialization for %qs)", ofwhat); inform (exploc, "(near initialization for %qs)", ofwhat);
} }
...@@ -6311,17 +6310,33 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, ...@@ -6311,17 +6310,33 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
if (checktype != error_mark_node if (checktype != error_mark_node
&& TREE_CODE (type) == ENUMERAL_TYPE && TREE_CODE (type) == ENUMERAL_TYPE
&& TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (type)) && TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (type))
{ switch (errtype)
PEDWARN_FOR_ASSIGNMENT (location, expr_loc, OPT_Wc___compat, {
G_("enum conversion when passing argument " case ic_argpass:
"%d of %qE is invalid in C++"), if (pedwarn (expr_loc, OPT_Wc___compat, "enum conversion when "
G_("enum conversion in assignment is " "passing argument %d of %qE is invalid in C++",
"invalid in C++"), parmnum, rname))
G_("enum conversion in initialization is " inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
"invalid in C++"), ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
G_("enum conversion in return is " "expected %qT but argument is of type %qT",
"invalid in C++")); type, rhstype);
} break;
case ic_assign:
pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
"%qT in assignment is invalid in C++", rhstype, type);
break;
case ic_init:
pedwarn_init (location, OPT_Wc___compat, "enum conversion from "
"%qT to %qT in initialization is invalid in C++",
rhstype, type);
break;
case ic_return:
pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
"%qT in return is invalid in C++", rhstype, type);
break;
default:
gcc_unreachable ();
}
} }
if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype)) if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
...@@ -6727,15 +6742,36 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, ...@@ -6727,15 +6742,36 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
; ;
/* If there is a mismatch, do warn. */ /* If there is a mismatch, do warn. */
else if (warn_pointer_sign) else if (warn_pointer_sign)
PEDWARN_FOR_ASSIGNMENT (location, expr_loc, OPT_Wpointer_sign, switch (errtype)
G_("pointer targets in passing argument " {
"%d of %qE differ in signedness"), case ic_argpass:
G_("pointer targets in assignment " if (pedwarn (expr_loc, OPT_Wpointer_sign,
"differ in signedness"), "pointer targets in passing argument %d of "
G_("pointer targets in initialization " "%qE differ in signedness", parmnum, rname))
"differ in signedness"), inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
G_("pointer targets in return differ " ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
"in signedness")); "expected %qT but argument is of type %qT",
type, rhstype);
break;
case ic_assign:
pedwarn (location, OPT_Wpointer_sign,
"pointer targets in assignment from %qT to %qT "
"differ in signedness", rhstype, type);
break;
case ic_init:
pedwarn_init (location, OPT_Wpointer_sign,
"pointer targets in initialization of %qT "
"from %qT differ in signedness", type,
rhstype);
break;
case ic_return:
pedwarn (location, OPT_Wpointer_sign, "pointer targets in "
"returning %qT from a function with return type "
"%qT differ in signedness", rhstype, type);
break;
default:
gcc_unreachable ();
}
} }
else if (TREE_CODE (ttl) == FUNCTION_TYPE else if (TREE_CODE (ttl) == FUNCTION_TYPE
&& TREE_CODE (ttr) == FUNCTION_TYPE) && TREE_CODE (ttr) == FUNCTION_TYPE)
...@@ -6760,17 +6796,39 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, ...@@ -6760,17 +6796,39 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr)); TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
} }
} }
else /* Avoid warning about the volatile ObjC EH puts on decls. */
/* Avoid warning about the volatile ObjC EH puts on decls. */ else if (!objc_ok)
if (!objc_ok) {
PEDWARN_FOR_ASSIGNMENT (location, expr_loc, switch (errtype)
OPT_Wincompatible_pointer_types, {
G_("passing argument %d of %qE from " case ic_argpass:
"incompatible pointer type"), if (pedwarn (expr_loc, OPT_Wincompatible_pointer_types,
G_("assignment from incompatible pointer type"), "passing argument %d of %qE from incompatible "
G_("initialization from incompatible " "pointer type", parmnum, rname))
"pointer type"), inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
G_("return from incompatible pointer type")); ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
"expected %qT but argument is of type %qT",
type, rhstype);
break;
case ic_assign:
pedwarn (location, OPT_Wincompatible_pointer_types,
"assignment to %qT from incompatible pointer type %qT",
type, rhstype);
break;
case ic_init:
pedwarn_init (location, OPT_Wincompatible_pointer_types,
"initialization of %qT from incompatible pointer "
"type %qT", type, rhstype);
break;
case ic_return:
pedwarn (location, OPT_Wincompatible_pointer_types,
"returning %qT from a function with incompatible "
"return type %qT", rhstype, type);
break;
default:
gcc_unreachable ();
}
}
return convert (type, rhs); return convert (type, rhs);
} }
...@@ -6787,31 +6845,70 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, ...@@ -6787,31 +6845,70 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
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) if (!null_pointer_constant)
PEDWARN_FOR_ASSIGNMENT (location, expr_loc, switch (errtype)
OPT_Wint_conversion, {
G_("passing argument %d of %qE makes " case ic_argpass:
"pointer from integer without a cast"), if (pedwarn (expr_loc, OPT_Wint_conversion,
G_("assignment makes pointer from integer " "passing argument %d of %qE makes pointer from "
"without a cast"), "integer without a cast", parmnum, rname))
G_("initialization makes pointer from " inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
"integer without a cast"), ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
G_("return makes pointer from integer " "expected %qT but argument is of type %qT",
"without a cast")); type, rhstype);
break;
case ic_assign:
pedwarn (location, OPT_Wint_conversion,
"assignment to %qT from %qT makes pointer from integer "
"without a cast", type, rhstype);
break;
case ic_init:
pedwarn_init (location, OPT_Wint_conversion,
"initialization of %qT from %qT makes pointer from "
"integer without a cast", type, rhstype);
break;
case ic_return:
pedwarn (location, OPT_Wint_conversion, "returning %qT from a "
"function with return type %qT makes pointer from "
"integer without a cast", rhstype, type);
break;
default:
gcc_unreachable ();
}
return convert (type, rhs); return convert (type, rhs);
} }
else if (codel == INTEGER_TYPE && coder == POINTER_TYPE) else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
{ {
PEDWARN_FOR_ASSIGNMENT (location, expr_loc, switch (errtype)
OPT_Wint_conversion, {
G_("passing argument %d of %qE makes integer " case ic_argpass:
"from pointer without a cast"), if (pedwarn (expr_loc, OPT_Wint_conversion,
G_("assignment makes integer from pointer " "passing argument %d of %qE makes integer from "
"without a cast"), "pointer without a cast", parmnum, rname))
G_("initialization makes integer from pointer " inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
"without a cast"), ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
G_("return makes integer from pointer " "expected %qT but argument is of type %qT",
"without a cast")); type, rhstype);
break;
case ic_assign:
pedwarn (location, OPT_Wint_conversion,
"assignment to %qT from %qT makes integer from pointer "
"without a cast", type, rhstype);
break;
case ic_init:
pedwarn_init (location, OPT_Wint_conversion,
"initialization of %qT from %qT makes integer from "
"pointer without a cast", type, rhstype);
break;
case ic_return:
pedwarn (location, OPT_Wint_conversion, "returning %qT from a "
"function with return type %qT makes integer from "
"pointer without a cast", rhstype, type);
break;
default:
gcc_unreachable ();
}
return convert (type, rhs); return convert (type, rhs);
} }
else if (codel == BOOLEAN_TYPE && coder == POINTER_TYPE) else if (codel == BOOLEAN_TYPE && coder == POINTER_TYPE)
......
...@@ -93,6 +93,8 @@ extern void inform_n (location_t, int, const char *, const char *, ...) ...@@ -93,6 +93,8 @@ extern void inform_n (location_t, int, const char *, const char *, ...)
extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern bool emit_diagnostic (diagnostic_t, location_t, int, extern bool emit_diagnostic (diagnostic_t, location_t, int,
const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
extern bool emit_diagnostic_valist (diagnostic_t, location_t, int, const char *,
va_list *) ATTRIBUTE_GCC_DIAG (4,0);
extern bool seen_error (void); extern bool seen_error (void);
#ifdef BUFSIZ #ifdef BUFSIZ
......
...@@ -1128,6 +1128,8 @@ diagnostic_n_impl (location_t location, int opt, int n, ...@@ -1128,6 +1128,8 @@ diagnostic_n_impl (location_t location, int opt, int n,
singular_gmsgid, plural_gmsgid, ap, kind); singular_gmsgid, plural_gmsgid, ap, kind);
} }
/* Wrapper around diagnostic_impl taking a variable argument list. */
bool bool
emit_diagnostic (diagnostic_t kind, location_t location, int opt, emit_diagnostic (diagnostic_t kind, location_t location, int opt,
const char *gmsgid, ...) const char *gmsgid, ...)
...@@ -1140,6 +1142,16 @@ emit_diagnostic (diagnostic_t kind, location_t location, int opt, ...@@ -1140,6 +1142,16 @@ emit_diagnostic (diagnostic_t kind, location_t location, int opt,
return ret; return ret;
} }
/* Wrapper around diagnostic_impl taking a va_list parameter. */
bool
emit_diagnostic_valist (diagnostic_t kind, location_t location, int opt,
const char *gmsgid, va_list *ap)
{
rich_location richloc (line_table, location);
return diagnostic_impl (&richloc, opt, gmsgid, ap, kind);
}
/* An informative note at LOCATION. Use this for additional details on an error /* An informative note at LOCATION. Use this for additional details on an error
message. */ message. */
void void
......
2017-08-09 Marek Polacek <polacek@redhat.com> 2017-08-09 Marek Polacek <polacek@redhat.com>
PR c/81233
* gcc.dg/diagnostic-types-1.c: New test.
* gcc.dg/assign-warn-1.c: Update warning messages.
* gcc.dg/assign-warn-2.c: Likewise.
* gcc.dg/c90-const-expr-5.c: Likewise.
* gcc.dg/c99-const-expr-5.c: Likewise.
* gcc.dg/conv-2.c: Likewise.
* gcc.dg/init-bad-7.c: Likewise.
* gcc.dg/overflow-warn-1.c: Likewise.
* gcc.dg/overflow-warn-2.c: Likewise.
* gcc.dg/overflow-warn-3.c: Likewise.
* gcc.dg/overflow-warn-4.c: Likewise.
* gcc.dg/pointer-array-atomic.c: Likewise.
* gcc.dg/pr26865.c: Likewise.
* gcc.dg/pr61162-2.c: Likewise.
* gcc.dg/pr61162.c: Likewise.
* gcc.dg/pr67730-2.c: Likewise.
* gcc.dg/pr69156.c: Likewise.
* gcc.dg/pr70174.c: Likewise.
* objc.dg/proto-lossage-4.m: Likewise.
2017-08-09 Marek Polacek <polacek@redhat.com>
PR c/81417 PR c/81417
* Wsign-compare-1.c: New test. * Wsign-compare-1.c: New test.
* gcc.dg/compare1.c: Adjust dg-bogus. * gcc.dg/compare1.c: Adjust dg-bogus.
......
...@@ -50,63 +50,63 @@ TESTRET(dfe, void *, fp); /* { dg-warning "ISO C forbids return between function ...@@ -50,63 +50,63 @@ TESTRET(dfe, void *, fp); /* { dg-warning "ISO C forbids return between function
TESTARG(sua, int *, unsigned int *); /* { dg-warning "pointer targets in passing argument 1 of 'suaF' differ in signedness" } */ TESTARG(sua, int *, unsigned int *); /* { dg-warning "pointer targets in passing argument 1 of 'suaF' differ in signedness" } */
TESTARP(sub, int *, unsigned int *); /* { dg-warning "pointer targets in passing argument 1 of 'subFp.x' differ in signedness" } */ TESTARP(sub, int *, unsigned int *); /* { dg-warning "pointer targets in passing argument 1 of 'subFp.x' differ in signedness" } */
TESTASS(suc, int *, unsigned int *); /* { dg-warning "pointer targets in assignment differ in signedness" } */ TESTASS(suc, int *, unsigned int *); /* { dg-warning "pointer targets in assignment from 'unsigned int \\*' to 'int \\*' differ in signedness" } */
TESTINI(sud, int *, unsigned int *); /* { dg-warning "pointer targets in initialization differ in signedness" } */ TESTINI(sud, int *, unsigned int *); /* { dg-warning "pointer targets in initialization of 'int \\*' from 'unsigned int \\*' differ in signedness" } */
TESTRET(sue, int *, unsigned int *); /* { dg-warning "pointer targets in return differ in signedness" } */ TESTRET(sue, int *, unsigned int *); /* { dg-warning "pointer targets in returning 'unsigned int \\*' from a function with return type 'int \\*' differ in signedness" } */
TESTARG(usa, unsigned int *, int *); /* { dg-warning "pointer targets in passing argument 1 of 'usaF' differ in signedness" } */ TESTARG(usa, unsigned int *, int *); /* { dg-warning "pointer targets in passing argument 1 of 'usaF' differ in signedness" } */
TESTARP(usb, unsigned int *, int *); /* { dg-warning "pointer targets in passing argument 1 of 'usbFp.x' differ in signedness" } */ TESTARP(usb, unsigned int *, int *); /* { dg-warning "pointer targets in passing argument 1 of 'usbFp.x' differ in signedness" } */
TESTASS(usc, unsigned int *, int *); /* { dg-warning "pointer targets in assignment differ in signedness" } */ TESTASS(usc, unsigned int *, int *); /* { dg-warning "pointer targets in assignment from 'int \\*' to 'unsigned int \\*' differ in signedness" } */
TESTINI(usd, unsigned int *, int *); /* { dg-warning "pointer targets in initialization differ in signedness" } */ TESTINI(usd, unsigned int *, int *); /* { dg-warning "pointer targets in initialization of 'unsigned int \\*' from 'int \\*' differ in signedness" } */
TESTRET(use, unsigned int *, int *); /* { dg-warning "pointer targets in return differ in signedness" } */ TESTRET(use, unsigned int *, int *); /* { dg-warning "pointer targets in returning 'int \\*' from a function with return type 'unsigned int \\*' differ in signedness" } */
TESTARG(cua, char *, unsigned char *); /* { dg-warning "pointer targets in passing argument 1 of 'cuaF' differ in signedness" } */ TESTARG(cua, char *, unsigned char *); /* { dg-warning "pointer targets in passing argument 1 of 'cuaF' differ in signedness" } */
TESTARP(cub, char *, unsigned char *); /* { dg-warning "pointer targets in passing argument 1 of 'cubFp.x' differ in signedness" } */ TESTARP(cub, char *, unsigned char *); /* { dg-warning "pointer targets in passing argument 1 of 'cubFp.x' differ in signedness" } */
TESTASS(cuc, char *, unsigned char *); /* { dg-warning "pointer targets in assignment differ in signedness" } */ TESTASS(cuc, char *, unsigned char *); /* { dg-warning "pointer targets in assignment from 'unsigned char \\*' to 'char \\*' differ in signedness" } */
TESTINI(cud, char *, unsigned char *); /* { dg-warning "pointer targets in initialization differ in signedness" } */ TESTINI(cud, char *, unsigned char *); /* { dg-warning "pointer targets in initialization of 'char \\*' from 'unsigned char \\*' differ in signedness" } */
TESTRET(cue, char *, unsigned char *); /* { dg-warning "pointer targets in return differ in signedness" } */ TESTRET(cue, char *, unsigned char *); /* { dg-warning "pointer targets in returning 'unsigned char \\*' from a function with return type 'char \\*' differ in signedness" } */
TESTARG(uca, unsigned char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'ucaF' differ in signedness" } */ TESTARG(uca, unsigned char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'ucaF' differ in signedness" } */
TESTARP(ucb, unsigned char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'ucbFp.x' differ in signedness" } */ TESTARP(ucb, unsigned char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'ucbFp.x' differ in signedness" } */
TESTASS(ucc, unsigned char *, char *); /* { dg-warning "pointer targets in assignment differ in signedness" } */ TESTASS(ucc, unsigned char *, char *); /* { dg-warning "pointer targets in assignment from 'char \\*' to 'unsigned char \\*' differ in signedness" } */
TESTINI(ucd, unsigned char *, char *); /* { dg-warning "pointer targets in initialization differ in signedness" } */ TESTINI(ucd, unsigned char *, char *); /* { dg-warning "pointer targets in initialization of 'unsigned char \\*' from 'char \\*' differ in signedness" } */
TESTRET(uce, unsigned char *, char *); /* { dg-warning "pointer targets in return differ in signedness" } */ TESTRET(uce, unsigned char *, char *); /* { dg-warning "pointer targets in returning 'char \\*' from a function with return type 'unsigned char \\*' differ in signedness" } */
TESTARG(csa, char *, signed char *); /* { dg-warning "pointer targets in passing argument 1 of 'csaF' differ in signedness" } */ TESTARG(csa, char *, signed char *); /* { dg-warning "pointer targets in passing argument 1 of 'csaF' differ in signedness" } */
TESTARP(csb, char *, signed char *); /* { dg-warning "pointer targets in passing argument 1 of 'csbFp.x' differ in signedness" } */ TESTARP(csb, char *, signed char *); /* { dg-warning "pointer targets in passing argument 1 of 'csbFp.x' differ in signedness" } */
TESTASS(csc, char *, signed char *); /* { dg-warning "pointer targets in assignment differ in signedness" } */ TESTASS(csc, char *, signed char *); /* { dg-warning "pointer targets in assignment from 'signed char \\*' to 'char \\*' differ in signedness" } */
TESTINI(csd, char *, signed char *); /* { dg-warning "pointer targets in initialization differ in signedness" } */ TESTINI(csd, char *, signed char *); /* { dg-warning "pointer targets in initialization of 'char \\*' from 'signed char \\*' differ in signedness" } */
TESTRET(cse, char *, signed char *); /* { dg-warning "pointer targets in return differ in signedness" } */ TESTRET(cse, char *, signed char *); /* { dg-warning "pointer targets in returning 'signed char \\*' from a function with return type 'char \\*' differ in signedness" } */
TESTARG(sca, signed char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'scaF' differ in signedness" } */ TESTARG(sca, signed char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'scaF' differ in signedness" } */
TESTARP(scb, signed char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'scbFp.x' differ in signedness" } */ TESTARP(scb, signed char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'scbFp.x' differ in signedness" } */
TESTASS(scc, signed char *, char *); /* { dg-warning "pointer targets in assignment differ in signedness" } */ TESTASS(scc, signed char *, char *); /* { dg-warning "pointer targets in assignment from 'char \\*' to 'signed char \\*' differ in signedness" } */
TESTINI(scd, signed char *, char *); /* { dg-warning "pointer targets in initialization differ in signedness" } */ TESTINI(scd, signed char *, char *); /* { dg-warning "pointer targets in initialization of 'signed char \\*' from 'char \\*' differ in signedness" } */
TESTRET(sce, signed char *, char *); /* { dg-warning "pointer targets in return differ in signedness" } */ TESTRET(sce, signed char *, char *); /* { dg-warning "pointer targets in returning 'char \\*' from a function with return type 'signed char \\*' differ in signedness" } */
TESTARG(cia, char *, int *); /* { dg-warning "passing argument 1 of 'ciaF' from incompatible pointer type" } */ TESTARG(cia, char *, int *); /* { dg-warning "passing argument 1 of 'ciaF' from incompatible pointer type" } */
TESTARP(cib, char *, int *); /* { dg-warning "passing argument 1 of 'cibFp.x' from incompatible pointer type" } */ TESTARP(cib, char *, int *); /* { dg-warning "passing argument 1 of 'cibFp.x' from incompatible pointer type" } */
TESTASS(cic, char *, int *); /* { dg-warning "assignment from incompatible pointer type" } */ TESTASS(cic, char *, int *); /* { dg-warning "assignment to 'char \\*' from incompatible pointer type 'int \\*'" } */
TESTINI(cid, char *, int *); /* { dg-warning "initialization from incompatible pointer type" } */ TESTINI(cid, char *, int *); /* { dg-warning "initialization of 'char \\*' from incompatible pointer type 'int \\*'" } */
TESTRET(cie, char *, int *); /* { dg-warning "return from incompatible pointer type" } */ TESTRET(cie, char *, int *); /* { dg-warning "returning 'int \\*' from a function with incompatible return type 'char \\*'" } */
TESTARG(ica, int *, char *); /* { dg-warning "passing argument 1 of 'icaF' from incompatible pointer type" } */ TESTARG(ica, int *, char *); /* { dg-warning "passing argument 1 of 'icaF' from incompatible pointer type" } */
TESTARP(icb, int *, char *); /* { dg-warning "passing argument 1 of 'icbFp.x' from incompatible pointer type" } */ TESTARP(icb, int *, char *); /* { dg-warning "passing argument 1 of 'icbFp.x' from incompatible pointer type" } */
TESTASS(icc, int *, char *); /* { dg-warning "assignment from incompatible pointer type" } */ TESTASS(icc, int *, char *); /* { dg-warning "assignment to 'int \\*' from incompatible pointer type 'char \\*'" } */
TESTINI(icd, int *, char *); /* { dg-warning "initialization from incompatible pointer type" } */ TESTINI(icd, int *, char *); /* { dg-warning "initialization of 'int \\*' from incompatible pointer type 'char \\*'" } */
TESTRET(ice, int *, char *); /* { dg-warning "return from incompatible pointer type" } */ TESTRET(ice, int *, char *); /* { dg-warning "returning 'char \\*' from a function with incompatible return type 'int \\*'" } */
TESTARG(ciia, char *, int); /* { dg-warning "passing argument 1 of 'ciiaF' makes pointer from integer without a cast" } */ TESTARG(ciia, char *, int); /* { dg-warning "passing argument 1 of 'ciiaF' makes pointer from integer without a cast" } */
TESTARP(ciib, char *, int); /* { dg-warning "passing argument 1 of 'ciibFp.x' makes pointer from integer without a cast" } */ TESTARP(ciib, char *, int); /* { dg-warning "passing argument 1 of 'ciibFp.x' makes pointer from integer without a cast" } */
TESTASS(ciic, char *, int); /* { dg-warning "assignment makes pointer from integer without a cast" } */ TESTASS(ciic, char *, int); /* { dg-warning "assignment to 'char \\*' from 'int' makes pointer from integer without a cast" } */
TESTINI(ciid, char *, int); /* { dg-warning "initialization makes pointer from integer without a cast" } */ TESTINI(ciid, char *, int); /* { dg-warning "initialization of 'char \\*' from 'int' makes pointer from integer without a cast" } */
TESTRET(ciie, char *, int); /* { dg-warning "return makes pointer from integer without a cast" } */ TESTRET(ciie, char *, int); /* { dg-warning "returning 'int' from a function with return type 'char \\*' makes pointer from integer without a cast" } */
TESTARG(iica, int, char *); /* { dg-warning "passing argument 1 of 'iicaF' makes integer from pointer without a cast" } */ TESTARG(iica, int, char *); /* { dg-warning "passing argument 1 of 'iicaF' makes integer from pointer without a cast" } */
TESTARP(iicb, int, char *); /* { dg-warning "passing argument 1 of 'iicbFp.x' makes integer from pointer without a cast" } */ TESTARP(iicb, int, char *); /* { dg-warning "passing argument 1 of 'iicbFp.x' makes integer from pointer without a cast" } */
TESTASS(iicc, int, char *); /* { dg-warning "assignment makes integer from pointer without a cast" } */ TESTASS(iicc, int, char *); /* { dg-warning "assignment to 'int' from 'char \\*' makes integer from pointer without a cast" } */
TESTINI(iicd, int, char *); /* { dg-warning "initialization makes integer from pointer without a cast" } */ TESTINI(iicd, int, char *); /* { dg-warning "initialization of 'int' from 'char \\*' makes integer from pointer without a cast" } */
TESTRET(iice, int, char *); /* { dg-warning "return makes integer from pointer without a cast" } */ TESTRET(iice, int, char *); /* { dg-warning "returning 'char \\*' from a function with return type 'int' makes integer from pointer without a cast" } */
struct s { int a; }; struct s { int a; };
......
...@@ -51,63 +51,63 @@ TESTRET(dfe, void *, fp); /* { dg-error "ISO C forbids return between function p ...@@ -51,63 +51,63 @@ TESTRET(dfe, void *, fp); /* { dg-error "ISO C forbids return between function p
TESTARG(sua, int *, unsigned int *); /* { dg-error "pointer targets in passing argument 1 of 'suaF' differ in signedness" } */ TESTARG(sua, int *, unsigned int *); /* { dg-error "pointer targets in passing argument 1 of 'suaF' differ in signedness" } */
TESTARP(sub, int *, unsigned int *); /* { dg-error "pointer targets in passing argument 1 of 'subFp.x' differ in signedness" } */ TESTARP(sub, int *, unsigned int *); /* { dg-error "pointer targets in passing argument 1 of 'subFp.x' differ in signedness" } */
TESTASS(suc, int *, unsigned int *); /* { dg-error "pointer targets in assignment differ in signedness" } */ TESTASS(suc, int *, unsigned int *); /* { dg-error "pointer targets in assignment from 'unsigned int \\*' to 'int \\*' differ in signedness" } */
TESTINI(sud, int *, unsigned int *); /* { dg-error "pointer targets in initialization differ in signedness" } */ TESTINI(sud, int *, unsigned int *); /* { dg-error "pointer targets in initialization of 'int \\*' from 'unsigned int \\*' differ in signedness" } */
TESTRET(sue, int *, unsigned int *); /* { dg-error "pointer targets in return differ in signedness" } */ TESTRET(sue, int *, unsigned int *); /* { dg-error "pointer targets in returning 'unsigned int \\*' from a function with return type 'int \\*' differ in signedness" } */
TESTARG(usa, unsigned int *, int *); /* { dg-error "pointer targets in passing argument 1 of 'usaF' differ in signedness" } */ TESTARG(usa, unsigned int *, int *); /* { dg-error "pointer targets in passing argument 1 of 'usaF' differ in signedness" } */
TESTARP(usb, unsigned int *, int *); /* { dg-error "pointer targets in passing argument 1 of 'usbFp.x' differ in signedness" } */ TESTARP(usb, unsigned int *, int *); /* { dg-error "pointer targets in passing argument 1 of 'usbFp.x' differ in signedness" } */
TESTASS(usc, unsigned int *, int *); /* { dg-error "pointer targets in assignment differ in signedness" } */ TESTASS(usc, unsigned int *, int *); /* { dg-error "pointer targets in assignment from 'int \\*' to 'unsigned int \\*' differ in signedness" } */
TESTINI(usd, unsigned int *, int *); /* { dg-error "pointer targets in initialization differ in signedness" } */ TESTINI(usd, unsigned int *, int *); /* { dg-error "pointer targets in initialization of 'unsigned int \\*' from 'int \\*' differ in signedness" } */
TESTRET(use, unsigned int *, int *); /* { dg-error "pointer targets in return differ in signedness" } */ TESTRET(use, unsigned int *, int *); /* { dg-error "pointer targets in returning 'int \\*' from a function with return type 'unsigned int \\*' differ in signedness" } */
TESTARG(cua, char *, unsigned char *); /* { dg-error "pointer targets in passing argument 1 of 'cuaF' differ in signedness" } */ TESTARG(cua, char *, unsigned char *); /* { dg-error "pointer targets in passing argument 1 of 'cuaF' differ in signedness" } */
TESTARP(cub, char *, unsigned char *); /* { dg-error "pointer targets in passing argument 1 of 'cubFp.x' differ in signedness" } */ TESTARP(cub, char *, unsigned char *); /* { dg-error "pointer targets in passing argument 1 of 'cubFp.x' differ in signedness" } */
TESTASS(cuc, char *, unsigned char *); /* { dg-error "pointer targets in assignment differ in signedness" } */ TESTASS(cuc, char *, unsigned char *); /* { dg-error "pointer targets in assignment from 'unsigned char \\*' to 'char \\*' differ in signedness" } */
TESTINI(cud, char *, unsigned char *); /* { dg-error "pointer targets in initialization differ in signedness" } */ TESTINI(cud, char *, unsigned char *); /* { dg-error "pointer targets in initialization of 'char \\*' from 'unsigned char \\*' differ in signedness" } */
TESTRET(cue, char *, unsigned char *); /* { dg-error "pointer targets in return differ in signedness" } */ TESTRET(cue, char *, unsigned char *); /* { dg-error "pointer targets in returning 'unsigned char \\*' from a function with return type 'char \\*' differ in signedness" } */
TESTARG(uca, unsigned char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'ucaF' differ in signedness" } */ TESTARG(uca, unsigned char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'ucaF' differ in signedness" } */
TESTARP(ucb, unsigned char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'ucbFp.x' differ in signedness" } */ TESTARP(ucb, unsigned char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'ucbFp.x' differ in signedness" } */
TESTASS(ucc, unsigned char *, char *); /* { dg-error "pointer targets in assignment differ in signedness" } */ TESTASS(ucc, unsigned char *, char *); /* { dg-error "pointer targets in assignment from 'char \\*' to 'unsigned char \\*' differ in signedness" } */
TESTINI(ucd, unsigned char *, char *); /* { dg-error "pointer targets in initialization differ in signedness" } */ TESTINI(ucd, unsigned char *, char *); /* { dg-error "pointer targets in initialization of 'unsigned char \\*' from 'char \\*' differ in signedness" } */
TESTRET(uce, unsigned char *, char *); /* { dg-error "pointer targets in return differ in signedness" } */ TESTRET(uce, unsigned char *, char *); /* { dg-error "pointer targets in returning 'char \\*' from a function with return type 'unsigned char \\*' differ in signedness" } */
TESTARG(csa, char *, signed char *); /* { dg-error "pointer targets in passing argument 1 of 'csaF' differ in signedness" } */ TESTARG(csa, char *, signed char *); /* { dg-error "pointer targets in passing argument 1 of 'csaF' differ in signedness" } */
TESTARP(csb, char *, signed char *); /* { dg-error "pointer targets in passing argument 1 of 'csbFp.x' differ in signedness" } */ TESTARP(csb, char *, signed char *); /* { dg-error "pointer targets in passing argument 1 of 'csbFp.x' differ in signedness" } */
TESTASS(csc, char *, signed char *); /* { dg-error "pointer targets in assignment differ in signedness" } */ TESTASS(csc, char *, signed char *); /* { dg-error "pointer targets in assignment from 'signed char \\*' to 'char \\*' differ in signedness" } */
TESTINI(csd, char *, signed char *); /* { dg-error "pointer targets in initialization differ in signedness" } */ TESTINI(csd, char *, signed char *); /* { dg-error "pointer targets in initialization of 'char \\*' from 'signed char \\*' differ in signedness" } */
TESTRET(cse, char *, signed char *); /* { dg-error "pointer targets in return differ in signedness" } */ TESTRET(cse, char *, signed char *); /* { dg-error "pointer targets in returning 'signed char \\*' from a function with return type 'char \\*' differ in signedness" } */
TESTARG(sca, signed char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'scaF' differ in signedness" } */ TESTARG(sca, signed char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'scaF' differ in signedness" } */
TESTARP(scb, signed char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'scbFp.x' differ in signedness" } */ TESTARP(scb, signed char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'scbFp.x' differ in signedness" } */
TESTASS(scc, signed char *, char *); /* { dg-error "pointer targets in assignment differ in signedness" } */ TESTASS(scc, signed char *, char *); /* { dg-error "pointer targets in assignment from 'char \\*' to 'signed char \\*' differ in signedness" } */
TESTINI(scd, signed char *, char *); /* { dg-error "pointer targets in initialization differ in signedness" } */ TESTINI(scd, signed char *, char *); /* { dg-error "pointer targets in initialization of 'signed char \\*' from 'char \\*' differ in signedness" } */
TESTRET(sce, signed char *, char *); /* { dg-error "pointer targets in return differ in signedness" } */ TESTRET(sce, signed char *, char *); /* { dg-error "pointer targets in returning 'char \\*' from a function with return type 'signed char \\*' differ in signedness" } */
TESTARG(cia, char *, int *); /* { dg-error "passing argument 1 of 'ciaF' from incompatible pointer type" } */ TESTARG(cia, char *, int *); /* { dg-error "passing argument 1 of 'ciaF' from incompatible pointer type" } */
TESTARP(cib, char *, int *); /* { dg-error "passing argument 1 of 'cibFp.x' from incompatible pointer type" } */ TESTARP(cib, char *, int *); /* { dg-error "passing argument 1 of 'cibFp.x' from incompatible pointer type" } */
TESTASS(cic, char *, int *); /* { dg-error "assignment from incompatible pointer type" } */ TESTASS(cic, char *, int *); /* { dg-error "assignment to 'char \\*' from incompatible pointer type 'int \\*'" } */
TESTINI(cid, char *, int *); /* { dg-error "initialization from incompatible pointer type" } */ TESTINI(cid, char *, int *); /* { dg-error "initialization of 'char \\*' from incompatible pointer type 'int \\*'" } */
TESTRET(cie, char *, int *); /* { dg-error "return from incompatible pointer type" } */ TESTRET(cie, char *, int *); /* { dg-error "returning 'int \\*' from a function with incompatible return type 'char \\*'" } */
TESTARG(ica, int *, char *); /* { dg-error "passing argument 1 of 'icaF' from incompatible pointer type" } */ TESTARG(ica, int *, char *); /* { dg-error "passing argument 1 of 'icaF' from incompatible pointer type" } */
TESTARP(icb, int *, char *); /* { dg-error "passing argument 1 of 'icbFp.x' from incompatible pointer type" } */ TESTARP(icb, int *, char *); /* { dg-error "passing argument 1 of 'icbFp.x' from incompatible pointer type" } */
TESTASS(icc, int *, char *); /* { dg-error "assignment from incompatible pointer type" } */ TESTASS(icc, int *, char *); /* { dg-error "assignment to 'int \\*' from incompatible pointer type 'char \\*'" } */
TESTINI(icd, int *, char *); /* { dg-error "initialization from incompatible pointer type" } */ TESTINI(icd, int *, char *); /* { dg-error "initialization of 'int \\*' from incompatible pointer type 'char \\*'" } */
TESTRET(ice, int *, char *); /* { dg-error "return from incompatible pointer type" } */ TESTRET(ice, int *, char *); /* { dg-error "returning 'char \\*' from a function with incompatible return type 'int \\*'" } */
TESTARG(ciia, char *, int); /* { dg-error "passing argument 1 of 'ciiaF' makes pointer from integer without a cast" } */ TESTARG(ciia, char *, int); /* { dg-error "passing argument 1 of 'ciiaF' makes pointer from integer without a cast" } */
TESTARP(ciib, char *, int); /* { dg-error "passing argument 1 of 'ciibFp.x' makes pointer from integer without a cast" } */ TESTARP(ciib, char *, int); /* { dg-error "passing argument 1 of 'ciibFp.x' makes pointer from integer without a cast" } */
TESTASS(ciic, char *, int); /* { dg-error "assignment makes pointer from integer without a cast" } */ TESTASS(ciic, char *, int); /* { dg-error "assignment to 'char \\*' from 'int' makes pointer from integer without a cast" } */
TESTINI(ciid, char *, int); /* { dg-error "initialization makes pointer from integer without a cast" } */ TESTINI(ciid, char *, int); /* { dg-error "initialization of 'char \\*' from 'int' makes pointer from integer without a cast" } */
TESTRET(ciie, char *, int); /* { dg-error "return makes pointer from integer without a cast" } */ TESTRET(ciie, char *, int); /* { dg-error "returning 'int' from a function with return type 'char \\*' makes pointer from integer without a cast" } */
TESTARG(iica, int, char *); /* { dg-error "passing argument 1 of 'iicaF' makes integer from pointer without a cast" } */ TESTARG(iica, int, char *); /* { dg-error "passing argument 1 of 'iicaF' makes integer from pointer without a cast" } */
TESTARP(iicb, int, char *); /* { dg-error "passing argument 1 of 'iicbFp.x' makes integer from pointer without a cast" } */ TESTARP(iicb, int, char *); /* { dg-error "passing argument 1 of 'iicbFp.x' makes integer from pointer without a cast" } */
TESTASS(iicc, int, char *); /* { dg-error "assignment makes integer from pointer without a cast" } */ TESTASS(iicc, int, char *); /* { dg-error "assignment to 'int' from 'char \\*' makes integer from pointer without a cast" } */
TESTINI(iicd, int, char *); /* { dg-error "initialization makes integer from pointer without a cast" } */ TESTINI(iicd, int, char *); /* { dg-error "initialization of 'int' from 'char \\*' makes integer from pointer without a cast" } */
TESTRET(iice, int, char *); /* { dg-error "return makes integer from pointer without a cast" } */ TESTRET(iice, int, char *); /* { dg-error "returning 'char \\*' from a function with return type 'int' makes integer from pointer without a cast" } */
struct s { int a; }; struct s { int a; };
......
...@@ -15,8 +15,8 @@ f (void) ...@@ -15,8 +15,8 @@ f (void)
{ {
/* (V *)0 is a null pointer constant, so the assignment should be /* (V *)0 is a null pointer constant, so the assignment should be
diagnosed. */ diagnosed. */
q = (j ? p : (V *)0); /* { dg-error "5:assignment from incompatible pointer type" } */ q = (j ? p : (V *)0); /* { dg-error "5:assignment to 'long int \\*' from incompatible pointer type 'int \\*'" } */
q = (j ? p : (void *)0); /* { dg-error "5:assignment from incompatible pointer type" } */ q = (j ? p : (void *)0); /* { dg-error "5:assignment to 'long int \\*' from incompatible pointer type 'int \\*'" } */
/* And this conversion should be valid. */ /* And this conversion should be valid. */
(void (*)(void))(V *)0; (void (*)(void))(V *)0;
(void (*)(void))(void *)0; (void (*)(void))(void *)0;
......
...@@ -15,8 +15,8 @@ f (void) ...@@ -15,8 +15,8 @@ f (void)
{ {
/* (V *)0 is a null pointer constant, so the assignment should be /* (V *)0 is a null pointer constant, so the assignment should be
diagnosed. */ diagnosed. */
q = (j ? p : (V *)0); /* { dg-error "assignment from incompatible pointer type" } */ q = (j ? p : (V *)0); /* { dg-error "assignment to 'long int \\*' from incompatible pointer type 'int \\*'" } */
q = (j ? p : (void *)0); /* { dg-error "assignment from incompatible pointer type" } */ q = (j ? p : (void *)0); /* { dg-error "assignment to 'long int \\*' from incompatible pointer type 'int \\*'" } */
/* And this conversion should be valid. */ /* And this conversion should be valid. */
(void (*)(void))(V *)0; (void (*)(void))(V *)0;
(void (*)(void))(void *)0; (void (*)(void))(void *)0;
......
...@@ -12,15 +12,15 @@ int main() ...@@ -12,15 +12,15 @@ int main()
unsigned char *ucp; unsigned char *ucp;
signed char *scp; signed char *scp;
ulp = lp; /* { dg-warning " pointer targets in assignment differ in signedness" } */ ulp = lp; /* { dg-warning " pointer targets in assignment from 'long int \\*' to 'long unsigned int \\*' differ in signedness" } */
lp = ulp; /* { dg-warning " pointer targets in assignment differ in signedness" } */ lp = ulp; /* { dg-warning " pointer targets in assignment from 'long unsigned int \\*' to 'long int \\*' differ in signedness" } */
f1(ulp); /* { dg-warning " differ in signedness" } */ f1(ulp); /* { dg-warning " differ in signedness" } */
f2(lp); /* { dg-warning " differ in signedness" } */ f2(lp); /* { dg-warning " differ in signedness" } */
cp = ucp; /* { dg-warning " pointer targets in assignment differ in signedness" } */ cp = ucp; /* { dg-warning " pointer targets in assignment from 'unsigned char \\*' to 'char \\*' differ in signedness" } */
cp = scp; /* { dg-warning " pointer targets in assignment differ in signedness" } */ cp = scp; /* { dg-warning " pointer targets in assignment from 'signed char \\*' to 'char \\*' differ in signedness" } */
ucp = scp; /* { dg-warning " pointer targets in assignment differ in signedness" } */ ucp = scp; /* { dg-warning " pointer targets in assignment from 'signed char \\*' to 'unsigned char \\*' differ in signedness" } */
ucp = cp; /* { dg-warning " pointer targets in assignment differ in signedness" } */ ucp = cp; /* { dg-warning " pointer targets in assignment from 'char \\*' to 'unsigned char \\*' differ in signedness" } */
scp = ucp; /* { dg-warning " pointer targets in assignment differ in signedness" } */ scp = ucp; /* { dg-warning " pointer targets in assignment from 'unsigned char \\*' to 'signed char \\*' differ in signedness" } */
scp = cp; /* { dg-warning " pointer targets in assignment differ in signedness" } */ scp = cp; /* { dg-warning " pointer targets in assignment from 'char \\*' to 'signed char \\*' differ in signedness" } */
} }
/* PR c/81233 */
/* { dg-do compile } */
/* { dg-options "-Wc++-compat -Wpedantic" } */
/* Test we're printing the types, like the good compiler we are. */
enum E1 { A } e;
enum E2 { B };
extern void foo_E (enum E1); /* { dg-message "expected 'enum E1' but argument is of type 'int'" } */
extern void foo (char *); /* { dg-message "expected 'char \\*' but argument is of type 'int \\*'" } */
extern void foo2 (int *); /* { dg-message "expected 'int \\*' but argument is of type 'int'" } */
extern void foo3 (int); /* { dg-message "expected 'int' but argument is of type 'int \\*'" } */
extern void foo4 (int *); /* { dg-message "expected 'int \\*' but argument is of type 'unsigned int \\*'" } */
char *
fn0 (int *p, char *q)
{
p = q; /* { dg-warning "assignment to 'int \\*' from incompatible pointer type 'char \\*'" } */
int *r = q; /* { dg-warning "initialization of 'int \\*' from incompatible pointer type 'char \\*'" } */
foo (r); /* { dg-warning "passing argument 1 of 'foo' from incompatible pointer type" } */
return p; /* { dg-warning "returning 'int \\*' from a function with incompatible return type 'char \\*'" } */
}
int *
fn1 (int *p)
{
p = 1; /* { dg-warning "assignment to 'int \\*' from 'int' makes pointer from integer without a cast" } */
int *q = 1; /* { dg-warning "initialization of 'int \\*' from 'int' makes pointer from integer without a cast" } */
foo2 (1); /* { dg-warning "passing argument 1 of 'foo2' makes pointer from integer without a cast" } */
return 1; /* { dg-warning "returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */
}
int
fn2 (int i, int *p)
{
i = p; /* { dg-warning "assignment to 'int' from 'int \\*' makes integer from pointer without a cast" } */
int j = p; /* { dg-warning "initialization of 'int' from 'int \\*' makes integer from pointer without a cast" } */
foo3 (p); /* { dg-warning "passing argument 1 of 'foo3' makes integer from pointer without a cast" } */
return p; /* { dg-warning "returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */
}
int *
fn3 (int *p, unsigned int *u)
{
p = u; /* { dg-warning "pointer targets in assignment from 'unsigned int \\*' to 'int \\*' differ in signedness" } */
int *q = u; /* { dg-warning "pointer targets in initialization of 'int \\*' from 'unsigned int \\*' differ in signedness" } */
foo4 (u); /* { dg-warning "pointer targets in passing argument 1 of 'foo4' differ in signedness" } */
return u; /* { dg-warning "pointer targets in returning 'unsigned int \\*' from a function with return type 'int \\*' differ in signedness" } */
}
enum E1
fn4 (void)
{
foo_E (B); /* { dg-warning "enum conversion when passing argument" } */
e = 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in assignment is invalid" } */
enum E1 f = 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in initialization is invalid" } */
return 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in return is invalid" } */
}
...@@ -8,4 +8,4 @@ struct f ...@@ -8,4 +8,4 @@ struct f
}; };
char b[10]; char b[10];
struct f g = {b}; /* { dg-warning "initialization from incompatible pointer type|near initialization for" } */ struct f g = {b}; /* { dg-warning "initialization of 'int \\*' from incompatible pointer type|near initialization for" } */
...@@ -47,10 +47,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "25:integer overflow in expression" ...@@ -47,10 +47,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "25:integer overflow in expression"
constants. The third has the overflow in an unevaluated constants. The third has the overflow in an unevaluated
subexpression, so is a null pointer constant. */ subexpression, so is a null pointer constant. */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } .-1 } */ /* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-1 } */
void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
/* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ /* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */
/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ /* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */
void *r = (1 ? 0 : INT_MAX+1); void *r = (1 ? 0 : INT_MAX+1);
void void
......
...@@ -47,10 +47,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } ...@@ -47,10 +47,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" }
constants. The third has the overflow in an unevaluated constants. The third has the overflow in an unevaluated
subexpression, so is a null pointer constant. */ subexpression, so is a null pointer constant. */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } .-1 } */ /* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-1 } */
void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
/* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ /* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */
/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ /* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */
void *r = (1 ? 0 : INT_MAX+1); void *r = (1 ? 0 : INT_MAX+1);
void void
......
...@@ -53,10 +53,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } ...@@ -53,10 +53,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" }
subexpression, so is a null pointer constant. */ subexpression, so is a null pointer constant. */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */ /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */
/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ /* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */
void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
/* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ /* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */
/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ /* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */
void *r = (1 ? 0 : INT_MAX+1); void *r = (1 ? 0 : INT_MAX+1);
void void
......
...@@ -53,10 +53,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } ...@@ -53,10 +53,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" }
subexpression, so is a null pointer constant. */ subexpression, so is a null pointer constant. */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
/* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ /* { dg-error "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */
void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
/* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ /* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */
/* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ /* { dg-error "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */
void *r = (1 ? 0 : INT_MAX+1); void *r = (1 ? 0 : INT_MAX+1);
void void
......
...@@ -6,8 +6,8 @@ void transpose0(double* out, _Atomic double* in) { } ...@@ -6,8 +6,8 @@ void transpose0(double* out, _Atomic double* in) { }
void transpose1(double out[2][2], _Atomic double in[2][2]) { } void transpose1(double out[2][2], _Atomic double in[2][2]) { }
void transpose2(double out[2][2][2], _Atomic double in[2][2][2]) { } void transpose2(double out[2][2][2], _Atomic double in[2][2][2]) { }
// return // return
int (*x2(_Atomic int x[3][3]))[3] { return x; } /* { dg-warning "return from incompatible pointer type" } */ int (*x2(_Atomic int x[3][3]))[3] { return x; } /* { dg-warning "returning '_Atomic int \\(\\*\\)\\\[3\\\]' from a function with incompatible return type" } */
_Atomic int (*x3(int x[3][3]))[3] { return x; } /* { dg-warning "return from incompatible pointer type" } */ _Atomic int (*x3(int x[3][3]))[3] { return x; } /* { dg-warning "returning 'int \\(\\*\\)\\\[3\\\]' from a function with incompatible return type" } */
void test(void) void test(void)
{ {
double x0[2]; double x0[2];
...@@ -31,13 +31,13 @@ void test(void) ...@@ -31,13 +31,13 @@ void test(void)
transpose2(y2, o2); /* { dg-warning "passing argument 2 of 'transpose2' from incompatible pointer type" } */ transpose2(y2, o2); /* { dg-warning "passing argument 2 of 'transpose2' from incompatible pointer type" } */
transpose2(y2, x2); /* { dg-warning "passing argument 2 of 'transpose2' from incompatible pointer type" } */ transpose2(y2, x2); /* { dg-warning "passing argument 2 of 'transpose2' from incompatible pointer type" } */
// initialization // initialization
_Atomic double (*x0p) = x0; /* { dg-warning "initialization from incompatible pointer type" } */ _Atomic double (*x0p) = x0; /* { dg-warning "initialization of '_Atomic double \\*' from incompatible pointer type" } */
_Atomic double (*x1p)[2] = x1; /* { dg-warning "initialization from incompatible pointer type" } */ _Atomic double (*x1p)[2] = x1; /* { dg-warning "initialization of '_Atomic double \\(\\*\\)\\\[2\\\]' from incompatible pointer type" } */
_Atomic double (*x2p)[2][2] = x2; /* { dg-warning "initialization from incompatible pointer type" } */ _Atomic double (*x2p)[2][2] = x2; /* { dg-warning "initialization of '_Atomic double \\(\\*\\)\\\[2\\\]\\\[2\\\]' from incompatible pointer type" } */
// assignment // assignment
x0p = x0; /* { dg-warning "assignment from incompatible pointer type" } */ x0p = x0; /* { dg-warning "assignment to '_Atomic double \\*' from incompatible pointer type" } */
x1p = x1; /* { dg-warning "assignment from incompatible pointer type" } */ x1p = x1; /* { dg-warning "assignment to '_Atomic double \\(\\*\\)\\\[2\\\]' from incompatible pointer type" } */
x2p = x2; /* { dg-warning "assignment from incompatible pointer type" } */ x2p = x2; /* { dg-warning "assignment to '_Atomic double \\(\\*\\)\\\[2\\\]\\\[2\\\]' from incompatible pointer type" } */
// subtraction // subtraction
&(x0[1]) - &(z0[0]); /* { dg-error "invalid operands to binary" } */ &(x0[1]) - &(z0[0]); /* { dg-error "invalid operands to binary" } */
&(x1[1]) - &(z1[0]); /* { dg-error "invalid operands to binary" } */ &(x1[1]) - &(z1[0]); /* { dg-error "invalid operands to binary" } */
......
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
void void
foo (void) foo (void)
{ {
char *e = alloca (100); /* { dg-warning "implicit declaration|initialization makes" } */ char *e = alloca (100); /* { dg-warning "implicit declaration|initialization of 'char \\*' from 'int' makes" } */
} }
...@@ -8,7 +8,7 @@ struct s { int a; }; ...@@ -8,7 +8,7 @@ struct s { int a; };
enum e enum e
fn1 (void) fn1 (void)
{ {
return 0; /* { dg-warning "10:enum conversion in return" } */ return 0; /* { dg-warning "10:enum conversion from 'int' to 'enum e' in return" } */
} }
int int
...@@ -26,19 +26,19 @@ fn3 (void) ...@@ -26,19 +26,19 @@ fn3 (void)
int int
fn4 (int *a) fn4 (int *a)
{ {
return a; /* { dg-warning "10:return makes integer from pointer without a cast" } */ return a; /* { dg-warning "10:returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */
} }
int * int *
fn5 (int a) fn5 (int a)
{ {
return a; /* { dg-warning "10:return makes pointer from integer without a cast" } */ return a; /* { dg-warning "10:returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */
} }
unsigned int * unsigned int *
fn6 (int *i) fn6 (int *i)
{ {
return i; /* { dg-warning "10:pointer targets in return differ" } */ return i; /* { dg-warning "10:pointer targets in returning 'int \\*' from a function with return type 'unsigned int \\*' differ" } */
} }
void * void *
......
...@@ -6,7 +6,7 @@ enum e { A }; ...@@ -6,7 +6,7 @@ enum e { A };
enum e enum e
fn1 (void) fn1 (void)
{ {
enum e e, q = 0; /* { dg-warning "17:enum conversion in initialization is invalid" } */ enum e e, q = 0; /* { dg-warning "17:enum conversion from 'int' to 'enum e' in initialization is invalid" } */
e = 0; /* { dg-warning "5:enum conversion in assignment is invalid" } */ e = 0; /* { dg-warning "5:enum conversion from 'int' to 'enum e' in assignment is invalid" } */
1; return 0; /* { dg-warning "13:enum conversion in return is invalid" } */ 1; return 0; /* { dg-warning "13:enum conversion from 'int' to 'enum e' in return is invalid" } */
} }
...@@ -9,14 +9,14 @@ extern void bar (int); ...@@ -9,14 +9,14 @@ extern void bar (int);
int int
fn1 (void) fn1 (void)
{ {
int a = NULL; /* { dg-warning "initialization makes integer from pointer" } */ int a = NULL; /* { dg-warning "initialization of 'int' from 'void \\*' makes integer from pointer" } */
a = NULL; /* { dg-warning "assignment makes integer from pointer" } */ a = NULL; /* { dg-warning "assignment to 'int' from 'void \\*' makes integer from pointer" } */
bar (NULL); /* { dg-warning "passing argument 1" } */ bar (NULL); /* { dg-warning "passing argument 1" } */
return NULL; /* { dg-warning "return makes integer from pointer" } */ return NULL; /* { dg-warning "returning 'void \\*' from a function with return type 'int' makes integer from pointer" } */
} }
int int
fn2 (void) fn2 (void)
{ {
RETURN; /* { dg-warning "return makes integer from pointer" } */ RETURN; /* { dg-warning "returning 'void \\*' from a function with return type 'int' makes integer from pointer" } */
} }
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
_Bool _Bool
foo () foo ()
{ {
_Bool (*f) () = __builtin_abs; /* { dg-warning "initialization from incompatible pointer type" } */ _Bool (*f) () = __builtin_abs; /* { dg-warning "initialization of '_Bool \\(\\*\\)\\(\\)' from incompatible pointer type" } */
return f (0); return f (0);
} }
...@@ -7,5 +7,5 @@ struct S { int f : 4; } a; ...@@ -7,5 +7,5 @@ struct S { int f : 4; } a;
void void
foo (void) foo (void)
{ {
a.f = foo; /* { dg-warning "assignment makes integer from pointer without a cast" } */ a.f = foo; /* { dg-warning "assignment to 'signed char:4' from 'void \\(\\*\\)\\(void\\)' makes integer from pointer without a cast" } */
} }
...@@ -28,13 +28,13 @@ long foo(void) { ...@@ -28,13 +28,13 @@ long foo(void) {
receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .intptr_t." } */ receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .intptr_t." } */
receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } .-1 } */ /* { dg-warning "assignment to 'intptr_t {aka long int}' from 'id' makes integer from pointer without a cast" "" { target *-*-* } .-1 } */
receiver += [(Obj *)receiver anotherValue]; receiver += [(Obj *)receiver anotherValue];
receiver += [(Obj <Proto> *)receiver someValue]; receiver += [(Obj <Proto> *)receiver someValue];
receiver += [(Obj <Proto> *)receiver anotherValue]; receiver += [(Obj <Proto> *)receiver anotherValue];
receiver += [objrcvr someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ receiver += [objrcvr someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } .-1 } */ /* { dg-warning "assignment to 'intptr_t {aka long int}' from 'id' makes integer from pointer without a cast" "" { target *-*-* } .-1 } */
receiver += [objrcvr anotherValue]; receiver += [objrcvr anotherValue];
receiver += [(Obj <Proto> *)objrcvr someValue]; receiver += [(Obj <Proto> *)objrcvr someValue];
...@@ -42,7 +42,7 @@ long foo(void) { ...@@ -42,7 +42,7 @@ long foo(void) {
receiver += [objrcvr2 someValue]; receiver += [objrcvr2 someValue];
receiver += [objrcvr2 anotherValue]; receiver += [objrcvr2 anotherValue];
receiver += [(Obj *)objrcvr2 someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ receiver += [(Obj *)objrcvr2 someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } .-1 } */ /* { dg-warning "assignment to 'intptr_t {aka long int}' from 'id' makes integer from pointer without a cast" "" { target *-*-* } .-1 } */
receiver += [(Obj *)objrcvr2 anotherValue]; receiver += [(Obj *)objrcvr2 anotherValue];
......
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