re PR c/30949 ("incompatible pointer type" warning does not point to declaration)

2008-08-28  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	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
parent 31cb596a
2008-08-28 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
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 <joey.ye@intel.com> 2008-08-28 Joey Ye <joey.ye@intel.com>
* doc/extend.texi: Document AVX built-in functions. * doc/extend.texi: Document AVX built-in functions.
......
...@@ -3952,28 +3952,31 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, ...@@ -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 /* 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, OPT, 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, OPT, AR, parmnum, rname); \ if (pedwarn (LOCATION, OPT, AR, parmnum, rname)) \
break; \ inform (fundecl ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \
case ic_argpass_nonproto: \ "expected %qT but argument is of type %qT", \
warning (OPT, AR, parmnum, rname); \ type, rhstype); \
break; \ break; \
case ic_assign: \ case ic_argpass_nonproto: \
pedwarn (LOCATION, OPT, AS); \ warning (OPT, AR, parmnum, rname); \
break; \ break; \
case ic_init: \ case ic_assign: \
pedwarn (LOCATION, OPT, IN); \ pedwarn (LOCATION, OPT, AS); \
break; \ break; \
case ic_return: \ case ic_init: \
pedwarn (LOCATION, OPT, RE); \ pedwarn (LOCATION, OPT, IN); \
break; \ break; \
default: \ case ic_return: \
gcc_unreachable (); \ pedwarn (LOCATION, OPT, RE); \
} \ break; \
default: \
gcc_unreachable (); \
} \
} while (0) } while (0)
STRIP_TYPE_NOPS (rhs); STRIP_TYPE_NOPS (rhs);
......
2008-08-28 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
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 <d@domob.eu> 2008-08-28 Daniel Kraft <d@domob.eu>
* gfortran.dg/typebound_call_1.f03: New test. * gfortran.dg/typebound_call_1.f03: New test.
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
/* { dg-options "-Wall" } */ /* { 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) { void bar(long* lp) {
foo(lp); /* { dg-warning "differ in signedness" } */ foo(lp); /* { dg-warning "differ in signedness" } */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* { dg-options "-pedantic" } */ /* { 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) { void bar(long* lp) {
foo(lp); /* { dg-warning "differ in signedness" } */ foo(lp); /* { dg-warning "differ in signedness" } */
......
...@@ -121,3 +121,6 @@ TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 o ...@@ -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" } */ TESTASS(istrc, int, struct s); /* { dg-error "incompatible types in assignment" } */
TESTINI(istrd, int, struct s); /* { dg-error "incompatible types in initialization" } */ TESTINI(istrd, int, struct s); /* { dg-error "incompatible types in initialization" } */
TESTRET(istre, int, struct s); /* { dg-error "incompatible types in return" } */ 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 } */
...@@ -122,3 +122,4 @@ TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 o ...@@ -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" } */ TESTASS(istrc, int, struct s); /* { dg-error "incompatible types in assignment" } */
TESTINI(istrd, int, struct s); /* { dg-error "incompatible types in initialization" } */ TESTINI(istrd, int, struct s); /* { dg-error "incompatible types in initialization" } */
TESTRET(istre, int, struct s); /* { dg-error "incompatible types in return" } */ 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 } */
...@@ -10,10 +10,10 @@ static void f2() { } ...@@ -10,10 +10,10 @@ static void f2() { }
static void f3(void) { } static void f3(void) { }
static void f4(void *x U) { } static void f4(void *x U) { }
static void f5(int *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 f7(const int *x U) { }
static void f8(const int *x U, int y 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) void test(void)
{ {
......
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-Wpointer-sign" } */ /* { dg-options "-Wpointer-sign" } */
void f1(long *); void f1(long *); /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */
void f2(unsigned long *); void f2(unsigned long *); /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */
int main() int main()
{ {
......
...@@ -33,8 +33,16 @@ do \ ...@@ -33,8 +33,16 @@ do \
} while(0) } while(0)
DECIMAL_COMPOSITE_DECL(32); /* { dg-error "incompatible types in assignment" } */ 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" } */ 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" } */ 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() int main()
{ {
......
...@@ -25,7 +25,10 @@ int main () ...@@ -25,7 +25,10 @@ int main ()
} }
/* { dg-warning "passing argument 2 of" "2nd incompatible" { target *-*-* } 15 } */ /* { 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 1 of" "1st incompatible" { target *-*-* } 16 } */
/* { dg-warning "passing argument 2 of" "2nd incompatible" { target *-*-* } 16 } */ /* { dg-warning "passing argument 2 of" "2nd incompatible" { target *-*-* } 16 } */
/* { dg-warning "passing argument 1 of" "1st incompatible" { target *-*-* } 18 } */ /* { 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-warning "passing argument 1 of" "1st incompatible" { target *-*-* } 20 } */
/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 7 } */
/* 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" } */
}
...@@ -81,3 +81,5 @@ main (void) ...@@ -81,3 +81,5 @@ main (void)
f13 (&l); f13 (&l);
return 0; return 0;
} }
/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */
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