Commit 5c1bc275 by Marek Polacek Committed by Marek Polacek

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

	PR c/56724
	* c-typeck.c (convert_arguments): Get location of a parameter.  Change
	error and warning calls to error_at and warning_at.  Pass location of
	a parameter to it.  Call warning_at with OPT_Wtraditional_conversion.
	(convert_for_assignment): Add parameter to WARN_FOR_ASSIGNMENT and
	WARN_FOR_QUALIFIERS.  Pass expr_loc to those.

	* gcc.dg/pr56724-1.c: New test.
	* gcc.dg/pr56724-2.c: New test.
	* gcc.dg/wtr-conversion-1.c: Use -Wtraditional-conversion instead of
	-Wtraditional.
	* gcc.dg/dfp/wtr-conversion-1.c: Likewise.

From-SVN: r210980
parent d378c07e
2014-05-27 Marek Polacek <polacek@redhat.com>
PR c/56724
* c-typeck.c (convert_arguments): Get location of a parameter. Change
error and warning calls to error_at and warning_at. Pass location of
a parameter to it. Call warning_at with OPT_Wtraditional_conversion.
(convert_for_assignment): Add parameter to WARN_FOR_ASSIGNMENT and
WARN_FOR_QUALIFIERS. Pass expr_loc to those.
2014-05-26 Igor Zamyatin <igor.zamyatin@intel.com> 2014-05-26 Igor Zamyatin <igor.zamyatin@intel.com>
PR c/61191 PR c/61191
......
2014-05-27 Marek Polacek <polacek@redhat.com>
PR c/56724
* gcc.dg/pr56724-1.c: New test.
* gcc.dg/pr56724-2.c: New test.
* gcc.dg/wtr-conversion-1.c: Use -Wtraditional-conversion instead of
-Wtraditional.
* gcc.dg/dfp/wtr-conversion-1.c: Likewise.
2014-05-27 Eric Botcazou <ebotcazou@adacore.com> 2014-05-27 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/fold-compare-8.c: New test. * gcc.dg/fold-compare-8.c: New test.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Based on gcc.dg/wtr-conversion-1.c */ Based on gcc.dg/wtr-conversion-1.c */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-Wtraditional" } */ /* { dg-options "-Wtraditional-conversion" } */
extern void foo_i (int); extern void foo_i (int);
extern void foo_f (float); extern void foo_f (float);
......
/* PR c/56724 */
/* { dg-do compile } */
/* { dg-options "-Wtraditional-conversion" } */
extern void foo (int p[2][]); /* { dg-error "array type has incomplete element type" } */
extern void foo_i (int, int);
extern void foo_u (unsigned int);
extern void foo_f (int, float);
extern void foo_ll (long long);
extern void foo_cd (int, int, __complex__ double);
extern signed char sc;
extern int i;
extern unsigned int u;
extern float f;
extern double d;
extern __complex__ double cd;
void
fn ()
{
int p[1][1];
foo (p); /* { dg-error "8:type of formal parameter" } */
foo_i (1, f); /* { dg-warning "13:passing argument" } */
foo_i (1, cd); /* { dg-warning "13:passing argument" } */
foo_cd (1, 2, f); /* { dg-warning "17:passing argument" } */
foo_f (9, i); /* { dg-warning "13:passing argument" } */
foo_cd (2, 2, i); /* { dg-warning "17:passing argument" } */
foo_f (2, cd); /* { dg-warning "13:passing argument" } */
foo_f (2, d); /* { dg-warning "13:passing argument" } */
foo_ll (sc); /* { dg-warning "11:passing argument" } */
foo_u (i); /* { dg-warning "10:passing argument" } */
foo_i (1, u); /* { dg-warning "13:passing argument" } */
}
/* PR c/56724 */
/* { dg-do compile } */
/* { dg-options "-Wc++-compat -Wpedantic" } */
enum E1 { A };
enum E2 { B };
extern void foo_E (enum E1);
extern void foo_v (void *p);
extern void foo_sc (int, int, signed char *);
extern unsigned char *uc;
extern signed char sc;
extern const signed char *csc;
extern float *f;
void
foo (void)
{
void (*fp)(void);
const void (*ffp)(void);
foo_v (fp); /* { dg-warning "10:ISO C forbids passing argument" } */
foo_E (B); /* { dg-warning "10:enum conversion when passing argument" } */
foo_sc (1, 2, uc); /* { dg-warning "17:pointer targets in passing argument" } */
foo_sc (1, 2, f); /* { dg-warning "17:passing argument" } */
foo_sc (1, 2, sc); /* { dg-warning "17:passing argument" } */
foo_sc (uc, 2, &sc); /* { dg-warning "11:passing argument" } */
foo_sc (1, 2, csc); /* { dg-warning "17:passing argument" } */
}
typedef void (*fp)(void);
typedef void (*nrfp)(void) __attribute__((noreturn));
void f1 (nrfp); void f2 (fp x) { f1 (x); } extern int e; /* { dg-warning "38:passing argument" } */
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Note, gcc should omit these warnings in system header files. Note, gcc should omit these warnings in system header files.
By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 4/09/2001. */ By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 4/09/2001. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-Wtraditional" } */ /* { dg-options "-Wtraditional-conversion" } */
extern void foo_i (int); extern void foo_i (int);
extern void foo_f (float); extern void foo_f (float);
......
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