This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR c/30949 "incompatible pointer type" warning does not point to declaration
- From: "Manuel López-Ibáñez" <lopezibanez at gmail dot com>
- To: "Gcc Patch List" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 22 Oct 2008 16:22:50 +0200
- Subject: PR c/30949 "incompatible pointer type" warning does not point to declaration
Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
--enable-languages=all
OK for trunk?
2008-10-22 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/30949
* c-typeck.c (convert_for_assignment): Do not give declaration's
location for builtins. Spell out which type was expected and which
was given.
testsuite/
* gcc.target/i386/sse-vect-types.c: Update.
* gcc.dg/simd-5.c: Update.
* gcc.dg/assign-warn-2.c: Update.
* gcc.dg/simd-2.c: Update.
* gcc.dg/simd-6.c: Update.
* gcc.dg/assign-warn-1.c: Update.
* gcc.dg/dfp/composite-type.c: Update.
* gcc.dg/simd-1.c: Update.
* gcc.dg/pr36997.c: Update.
Index: gcc/testsuite/gcc.target/i386/sse-vect-types.c
===================================================================
--- gcc/testsuite/gcc.target/i386/sse-vect-types.c (revision 141266)
+++ gcc/testsuite/gcc.target/i386/sse-vect-types.c (working copy)
@@ -8,5 +8,6 @@ __m128d foo1(__m128d z, __m128d a, int
for (i=0; i<N; i++) {
a = _mm_add_ps(z, a); /* { dg-error "incompatible type" } */
}
return a;
}
+/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 0 } */
Index: gcc/testsuite/gcc.dg/simd-5.c
===================================================================
--- gcc/testsuite/gcc.dg/simd-5.c (revision 141266)
+++ gcc/testsuite/gcc.dg/simd-5.c (working copy)
@@ -3,6 +3,6 @@
/* Ensure that we don't need a typedef to initialize a vector type. */
#define vector __attribute__ ((vector_size (8)))
vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */
vector char y = (vector short) {1,2,3,4}; /* { dg-message "note: use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts" } */
- /* { dg-error "incompatible types in initialization" "" { target *-*-* } 7 } */
+ /* { dg-error "incompatible types when initializing" "" { target *-*-* } 7 } */
Index: gcc/testsuite/gcc.dg/assign-warn-2.c
===================================================================
--- gcc/testsuite/gcc.dg/assign-warn-2.c (revision 141266)
+++ gcc/testsuite/gcc.dg/assign-warn-2.c (working copy)
@@ -111,15 +111,15 @@ TESTRET(iice, int, char *); /* { dg-erro
struct s { int a; };
TESTARG(stria, struct s, int); /* { dg-error "incompatible type for argument 1 of 'striaF'" } */
TESTARP(strib, struct s, int); /* { dg-error "incompatible type for argument 1 of 'stribFp.x'" } */
-TESTASS(stric, struct s, int); /* { dg-error "incompatible types in assignment" } */
+TESTASS(stric, struct s, int); /* { dg-error "incompatible types when assigning to type 'struct s' from type 'int'" } */
TESTINI(strid, struct s, int); /* { dg-error "invalid initializer" } */
-TESTRET(strie, struct s, int); /* { dg-error "incompatible types in return" } */
+TESTRET(strie, struct s, int); /* { dg-error "incompatible types when returning type 'int' but 'struct s' was expected" } */
TESTARG(istra, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istraF'" } */
TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istrbFp.x'" } */
-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" } */
+TESTASS(istrc, int, struct s); /* { dg-error "incompatible types when assigning to type 'int' from type 'struct s'" } */
+TESTINI(istrd, int, struct s); /* { dg-error "incompatible types when initializing type 'int' using type 'struct s'" } */
+TESTRET(istre, int, struct s); /* { dg-error "incompatible types when returning type 'struct s' but 'int' was expected" } */
/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 0 } */
Index: gcc/testsuite/gcc.dg/simd-2.c
===================================================================
--- gcc/testsuite/gcc.dg/simd-2.c (revision 141266)
+++ gcc/testsuite/gcc.dg/simd-2.c (working copy)
@@ -21,18 +21,18 @@ hanneke ()
{
/* Assignment. */
a = b;
/* Assignment of different types. */
- b = c; /* { dg-error "incompatible types in assignment" } */
- d = a; /* { dg-error "incompatible types in assignment" } */
+ b = c; /* { dg-error "incompatible types when assigning" } */
+ d = a; /* { dg-error "incompatible types when assigning" } */
/* Casting between SIMDs of the same size. */
e = (typeof (e)) a;
/* Assignment between scalar and SIMD of different size. */
- foo = a; /* { dg-error "incompatible types in assignment" } */
+ foo = a; /* { dg-error "incompatible types when assigning" } */
/* Casted assignment between scalar and SIMD of same size. */
foo = (typeof (foo)) foo2; /* { dg-error "aggregate value used where a float was expected" } */
/* Casted assignment between scalar and SIMD of different size. */
Index: gcc/testsuite/gcc.dg/simd-6.c
===================================================================
--- gcc/testsuite/gcc.dg/simd-6.c (revision 141266)
+++ gcc/testsuite/gcc.dg/simd-6.c (working copy)
@@ -3,6 +3,6 @@
/* Ensure that we don't need a typedef to initialize a vector type. */
#define vector __attribute__ ((vector_size (8)))
vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */
vector char y = (vector short) {1,2,3,4}; /* { dg-message "note: use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts" } */
- /* { dg-error "incompatible types in initialization" "" { target *-*-* } 7 } */
+ /* { dg-error "incompatible types when initializing" "" { target *-*-* } 7 } */
Index: gcc/testsuite/gcc.dg/assign-warn-1.c
===================================================================
--- gcc/testsuite/gcc.dg/assign-warn-1.c (revision 141266)
+++ gcc/testsuite/gcc.dg/assign-warn-1.c (working copy)
@@ -110,17 +110,19 @@ TESTRET(iice, int, char *); /* { dg-warn
struct s { int a; };
TESTARG(stria, struct s, int); /* { dg-error "incompatible type for argument 1 of 'striaF'" } */
TESTARP(strib, struct s, int); /* { dg-error "incompatible type for argument 1 of 'stribFp.x'" } */
-TESTASS(stric, struct s, int); /* { dg-error "incompatible types in assignment" } */
+TESTASS(stric, struct s, int); /* { dg-error "incompatible types when assigning to type 'struct s' from type 'int'" } */
TESTINI(strid, struct s, int); /* { dg-error "invalid initializer" } */
-TESTRET(strie, struct s, int); /* { dg-error "incompatible types in return" } */
+TESTRET(strie, struct s, int); /* { dg-error "incompatible types when returning type 'int' but 'struct s' was expected" } */
TESTARG(istra, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istraF'" } */
+/* dg-message "note: expected 'int' but argument is of type 'struct s'" "note" { target *-*-* } 119 } */
TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istrbFp.x'" } */
-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 'int' but argument is of type 'struct s'" "note" { target *-*-* } 121 } */
+TESTASS(istrc, int, struct s); /* { dg-error "incompatible types when assigning to type 'int' from type 'struct s'" } */
+TESTINI(istrd, int, struct s); /* { dg-error "incompatible types when initializing type 'int' using type 'struct s'" } */
+TESTRET(istre, int, struct s); /* { dg-error "incompatible types when returning type 'struct s' but 'int' was expected" } */
/* Match all extra informative notes. */
/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */
Index: gcc/testsuite/gcc.dg/dfp/composite-type.c
===================================================================
--- gcc/testsuite/gcc.dg/dfp/composite-type.c (revision 141266)
+++ gcc/testsuite/gcc.dg/dfp/composite-type.c (working copy)
@@ -30,19 +30,19 @@ do \
d##TYPE = f2_##TYPE(h1_##TYPE); \
d##TYPE = f2_##TYPE(h2_##TYPE); \
d##TYPE = f2_##TYPE(h3_##TYPE); \
} while(0)
-DECIMAL_COMPOSITE_DECL(32); /* { dg-error "incompatible types in assignment" } */
+DECIMAL_COMPOSITE_DECL(32); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
/* { 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 when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
/* { 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 when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 43 } */
int main()
{
Index: gcc/testsuite/gcc.dg/simd-1.c
===================================================================
--- gcc/testsuite/gcc.dg/simd-1.c (revision 141266)
+++ gcc/testsuite/gcc.dg/simd-1.c (working copy)
@@ -23,25 +23,25 @@ hanneke ()
{
/* Assignment. */
a = b;
/* Assignment of different types. */
- b = c; /* { dg-error "incompatible types in assignment" } */
- d = a; /* { dg-error "incompatible types in assignment" } */
+ b = c; /* { dg-error "incompatible types when assigning" } */
+ d = a; /* { dg-error "incompatible types when assigning" } */
/* Casting between SIMDs of the same size. */
e = (typeof (e)) a;
/* Different signed SIMD assignment. */
f = a; /* { dg-message "note: use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts" } */
- /* { dg-error "incompatible types in assignment" "" { target *-*-* } 35 } */
+ /* { dg-error "incompatible types when assigning" "" { target *-*-* } 35 } */
/* Casted different signed SIMD assignment. */
f = (uv4si) a;
/* Assignment between scalar and SIMD of different size. */
- foo = a; /* { dg-error "incompatible types in assignment" } */
+ foo = a; /* { dg-error "incompatible types when assigning" } */
/* Casted assignment between scalar and SIMD of same size. */
foo = (typeof (foo)) foo2;
/* Casted assignment between scalar and SIMD of different size. */
Index: gcc/testsuite/gcc.dg/pr36997.c
===================================================================
--- gcc/testsuite/gcc.dg/pr36997.c (revision 141266)
+++ gcc/testsuite/gcc.dg/pr36997.c (working copy)
@@ -3,6 +3,7 @@
typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__));
__m64 _mm_add_si64 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddq ((long long)__m1, (long long)__m2); /* { dg-error "incompatible type" } */
+ /* { dg-message "note: expected 'long long int __vector__' but argument is of type 'long long int'" "" { target *-*-* } 7 } */
}
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c (revision 141266)
+++ gcc/c-typeck.c (working copy)
@@ -4010,11 +4010,12 @@ convert_for_assignment (tree type, tree
do { \
switch (errtype) \
{ \
case ic_argpass: \
if (pedwarn (LOCATION, OPT, AR, parmnum, rname)) \
- inform (fundecl ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \
+ inform ((fundecl && !DECL_IS_BUILTIN (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); \
@@ -4449,19 +4450,25 @@ convert_for_assignment (tree type, tree
case ic_argpass:
case ic_argpass_nonproto:
/* ??? This should not be an error when inlining calls to
unprototyped functions. */
error ("incompatible type for argument %d of %qE", parmnum, rname);
+ inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
+ ? DECL_SOURCE_LOCATION (fundecl) : input_location,
+ "expected %qT but argument is of type %qT", type, rhstype);
break;
case ic_assign:
- error ("incompatible types in assignment");
+ error ("incompatible types when assigning to type %qT from type %qT",
+ type, rhstype);
break;
case ic_init:
- error ("incompatible types in initialization");
+ error ("incompatible types when initializing type %qT using type %qT",
+ type, rhstype);
break;
case ic_return:
- error ("incompatible types in return");
+ error ("incompatible types when returning type %qT but %qT was expected",
+ rhstype, type);
break;
default:
gcc_unreachable ();
}