From: Manuel López-Ibáñez Date: Thu, 28 Aug 2008 19:34:36 +0000 (+0000) Subject: re PR c/30949 ("incompatible pointer type" warning does not point to declaration) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1e053dfe577da6b8b252d33b0df8eee62a8ad1e6;p=gcc.git re PR c/30949 ("incompatible pointer type" warning does not point to declaration) 2008-08-28 Manuel Lopez-Ibanez PR c/30949 * c-typeck.c (convert_for_assignment): Give a note describing what was passed and what was expected. testsuite/ * gcc.dg/pr30949.c: New. * gcc.dg/transparent-union-1.c: Update. * gcc.dg/cleanup-1.c: Update. * gcc.dg/assign-warn-2.c: Update. * gcc.dg/conv-2.c: Update. * gcc.dg/Wpointer-sign-pedantic.c: Update. * gcc.dg/Wpointer-sign-Wall.c: Update. * gcc.dg/assign-warn-1.c: Update. * gcc.dg/dfp/composite-type.c: Update. * gcc.dg/noncompile/20020213-1.c: Update. From-SVN: r139729 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5e93e9d9659..2fe77890a0e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-28 Manuel Lopez-Ibanez + + PR c/30949 + * c-typeck.c (convert_for_assignment): Give a note describing what + was passed and what was expected. + 2008-08-28 Joey Ye * doc/extend.texi: Document AVX built-in functions. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 9f725884e46..85a94443a6e 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -3952,28 +3952,31 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, /* 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, OPT, AR, AS, IN, RE) \ - do { \ - switch (errtype) \ - { \ - case ic_argpass: \ - pedwarn (LOCATION, OPT, AR, parmnum, rname); \ - break; \ - case ic_argpass_nonproto: \ - warning (OPT, AR, parmnum, rname); \ - break; \ - case ic_assign: \ - pedwarn (LOCATION, OPT, AS); \ - break; \ - case ic_init: \ - pedwarn (LOCATION, OPT, IN); \ - break; \ - case ic_return: \ - pedwarn (LOCATION, OPT, RE); \ - break; \ - default: \ - gcc_unreachable (); \ - } \ +#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE) \ + do { \ + switch (errtype) \ + { \ + case ic_argpass: \ + if (pedwarn (LOCATION, OPT, AR, parmnum, rname)) \ + inform (fundecl ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \ + "expected %qT but argument is of type %qT", \ + type, rhstype); \ + break; \ + case ic_argpass_nonproto: \ + warning (OPT, AR, parmnum, rname); \ + break; \ + case ic_assign: \ + pedwarn (LOCATION, OPT, AS); \ + break; \ + case ic_init: \ + pedwarn (LOCATION, OPT, IN); \ + break; \ + case ic_return: \ + pedwarn (LOCATION, OPT, RE); \ + break; \ + default: \ + gcc_unreachable (); \ + } \ } while (0) STRIP_TYPE_NOPS (rhs); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6af70c550c2..30b43234013 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,17 @@ +2008-08-28 Manuel Lopez-Ibanez + + PR c/30949 + * gcc.dg/pr30949.c: New. + * gcc.dg/transparent-union-1.c: Update. + * gcc.dg/cleanup-1.c: Update. + * gcc.dg/assign-warn-2.c: Update. + * gcc.dg/conv-2.c: Update. + * gcc.dg/Wpointer-sign-pedantic.c: Update. + * gcc.dg/Wpointer-sign-Wall.c: Update. + * gcc.dg/assign-warn-1.c: Update. + * gcc.dg/dfp/composite-type.c: Update. + * gcc.dg/noncompile/20020213-1.c: Update. + 2008-08-28 Daniel Kraft * gfortran.dg/typebound_call_1.f03: New test. diff --git a/gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c b/gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c index e72d37a18ce..302d50e5cf1 100644 --- a/gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c +++ b/gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c @@ -2,7 +2,8 @@ /* { dg-options "-Wall" } */ -void foo(unsigned long* ulp); +void foo(unsigned long* ulp); /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 5 } */ + void bar(long* lp) { foo(lp); /* { dg-warning "differ in signedness" } */ diff --git a/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c b/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c index 25e25209e52..8b92110988d 100644 --- a/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c +++ b/gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c @@ -2,7 +2,7 @@ /* { dg-options "-pedantic" } */ -void foo(unsigned long* ulp); +void foo(unsigned long* ulp);/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 5 } */ void bar(long* lp) { foo(lp); /* { dg-warning "differ in signedness" } */ diff --git a/gcc/testsuite/gcc.dg/assign-warn-1.c b/gcc/testsuite/gcc.dg/assign-warn-1.c index 1587c20d7b4..4c603829d59 100644 --- a/gcc/testsuite/gcc.dg/assign-warn-1.c +++ b/gcc/testsuite/gcc.dg/assign-warn-1.c @@ -121,3 +121,6 @@ TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 o TESTASS(istrc, int, struct s); /* { dg-error "incompatible types in assignment" } */ TESTINI(istrd, int, struct s); /* { dg-error "incompatible types in initialization" } */ TESTRET(istre, int, struct s); /* { dg-error "incompatible types in return" } */ + +/* Match all extra informative notes. */ +/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.dg/assign-warn-2.c b/gcc/testsuite/gcc.dg/assign-warn-2.c index 0ef6ebe33b3..4656961f6c4 100644 --- a/gcc/testsuite/gcc.dg/assign-warn-2.c +++ b/gcc/testsuite/gcc.dg/assign-warn-2.c @@ -122,3 +122,4 @@ TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 o TESTASS(istrc, int, struct s); /* { dg-error "incompatible types in assignment" } */ TESTINI(istrd, int, struct s); /* { dg-error "incompatible types in initialization" } */ TESTRET(istre, int, struct s); /* { dg-error "incompatible types in return" } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.dg/cleanup-1.c b/gcc/testsuite/gcc.dg/cleanup-1.c index e5853c4baa8..dd571635baf 100644 --- a/gcc/testsuite/gcc.dg/cleanup-1.c +++ b/gcc/testsuite/gcc.dg/cleanup-1.c @@ -10,10 +10,10 @@ static void f2() { } static void f3(void) { } static void f4(void *x U) { } static void f5(int *x U) { } -static void f6(double *x U) { } +static void f6(double *x U) { } /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ static void f7(const int *x U) { } static void f8(const int *x U, int y U) { } -static void f9(int x U) { } +static void f9(int x U) { } /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ void test(void) { diff --git a/gcc/testsuite/gcc.dg/conv-2.c b/gcc/testsuite/gcc.dg/conv-2.c index ac95584e3a6..388dee3d746 100644 --- a/gcc/testsuite/gcc.dg/conv-2.c +++ b/gcc/testsuite/gcc.dg/conv-2.c @@ -1,8 +1,8 @@ /* { dg-do compile } */ /* { dg-options "-Wpointer-sign" } */ -void f1(long *); -void f2(unsigned long *); +void f1(long *); /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ +void f2(unsigned long *); /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ int main() { diff --git a/gcc/testsuite/gcc.dg/dfp/composite-type.c b/gcc/testsuite/gcc.dg/dfp/composite-type.c index 56991add7f3..b2e7632e62a 100644 --- a/gcc/testsuite/gcc.dg/dfp/composite-type.c +++ b/gcc/testsuite/gcc.dg/dfp/composite-type.c @@ -33,8 +33,16 @@ do \ } while(0) DECIMAL_COMPOSITE_DECL(32); /* { dg-error "incompatible types in assignment" } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 35 } */ + + DECIMAL_COMPOSITE_DECL(64); /* { dg-error "incompatible types in assignment" } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 39 } */ + + DECIMAL_COMPOSITE_DECL(128); /* { dg-error "incompatible types in assignment" } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 43 } */ + int main() { diff --git a/gcc/testsuite/gcc.dg/noncompile/20020213-1.c b/gcc/testsuite/gcc.dg/noncompile/20020213-1.c index c1de5663ace..41480f0794d 100644 --- a/gcc/testsuite/gcc.dg/noncompile/20020213-1.c +++ b/gcc/testsuite/gcc.dg/noncompile/20020213-1.c @@ -25,7 +25,10 @@ int main () } /* { dg-warning "passing argument 2 of" "2nd incompatible" { target *-*-* } 15 } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 5 } */ /* { dg-warning "passing argument 1 of" "1st incompatible" { target *-*-* } 16 } */ /* { dg-warning "passing argument 2 of" "2nd incompatible" { target *-*-* } 16 } */ /* { dg-warning "passing argument 1 of" "1st incompatible" { target *-*-* } 18 } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 6 } */ /* { dg-warning "passing argument 1 of" "1st incompatible" { target *-*-* } 20 } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 7 } */ diff --git a/gcc/testsuite/gcc.dg/pr30949.c b/gcc/testsuite/gcc.dg/pr30949.c new file mode 100644 index 00000000000..a3f6a14132c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr30949.c @@ -0,0 +1,11 @@ +/* PR30949 */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +int func (int x); +void recv (int (* funcptr) (double x)); /* { dg-message "note: expected 'int .\\\*..double.' but argument is of type 'int .\\\*..int.'" } */ +void call (void) +{ + recv (func); /* { dg-error "passing argument 1 of 'recv' from incompatible pointer type" } */ +} + diff --git a/gcc/testsuite/gcc.dg/transparent-union-1.c b/gcc/testsuite/gcc.dg/transparent-union-1.c index a43e07953d3..2360912e3c5 100644 --- a/gcc/testsuite/gcc.dg/transparent-union-1.c +++ b/gcc/testsuite/gcc.dg/transparent-union-1.c @@ -81,3 +81,5 @@ main (void) f13 (&l); return 0; } + +/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */