Commit 8ffcdea8 by Marek Polacek Committed by Marek Polacek

re PR c/56724 (sub-optimal location in error)

	PR c/56724
	* c-typeck.c (convert_for_assignment): Use expr_loc for ic_argpass.

	* gcc.dg/pr56724-3.c: New test.

From-SVN: r211261
parent 55097f65
2014-06-05 Marek Polacek <polacek@redhat.com>
PR c/56724
* c-typeck.c (convert_for_assignment): Use expr_loc for ic_argpass.
2014-06-05 Marek Polacek <polacek@redhat.com>
PR c/49706
* c-typeck.c (parser_build_binary_op): Warn when logical not is used
on the left hand side operand of a comparison.
......
......@@ -6025,8 +6025,9 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
where NULL is typically defined in C to be '(void *) 0'. */
if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
warning_at (location, OPT_Wc___compat,
"request for implicit conversion "
warning_at (errtype == ic_argpass ? expr_loc : location,
OPT_Wc___compat,
"request for implicit conversion "
"from %qT to %qT not permitted in C++", rhstype, type);
/* See if the pointers point to incompatible address spaces. */
......@@ -6038,7 +6039,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
switch (errtype)
{
case ic_argpass:
error_at (location, "passing argument %d of %qE from pointer to "
error_at (expr_loc, "passing argument %d of %qE from pointer to "
"non-enclosed address space", parmnum, rname);
break;
case ic_assign:
......@@ -6067,7 +6068,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
switch (errtype)
{
case ic_argpass:
warning_at (location, OPT_Wsuggest_attribute_format,
warning_at (expr_loc, OPT_Wsuggest_attribute_format,
"argument %d of %qE might be "
"a candidate for a format attribute",
parmnum, rname);
......@@ -6246,9 +6247,10 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
switch (errtype)
{
case ic_argpass:
error_at (location, "incompatible type for argument %d of %qE", parmnum, rname);
error_at (expr_loc, "incompatible type for argument %d of %qE", parmnum,
rname);
inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
? DECL_SOURCE_LOCATION (fundecl) : input_location,
? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
"expected %qT but argument is of type %qT", type, rhstype);
break;
case ic_assign:
......@@ -6257,12 +6259,12 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
break;
case ic_init:
error_at (location,
"incompatible types when initializing type %qT using type %qT",
"incompatible types when initializing type %qT using type %qT",
type, rhstype);
break;
case ic_return:
error_at (location,
"incompatible types when returning type %qT but %qT was "
"incompatible types when returning type %qT but %qT was "
"expected", rhstype, type);
break;
default:
......
2014-06-05 Marek Polacek <polacek@redhat.com>
PR c/56724
* gcc.dg/pr56724-3.c: New test.
2014-06-05 Andreas Schwab <schwab@suse.de>
* g++.dg/cpp0x/initlist86.C (main): Initialize i.
......
/* PR c/56724 */
/* { dg-do compile } */
/* { dg-options "-Wc++-compat" } */
extern void xfer (int, int, unsigned char *);
struct T { int a; } t;
void
call (int x, int y, void *arg)
{
unsigned char *uc = arg; /* { dg-warning "23:request for implicit conversion" } */
xfer (x, y, arg); /* { dg-warning "15:request for implicit conversion" } */
xfer (x, y, t); /* { dg-error "15:incompatible type for" } */
}
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