re PR c/30949 ("incompatible pointer type" warning does not point to declaration)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Thu, 28 Aug 2008 19:34:36 +0000 (19:34 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Thu, 28 Aug 2008 19:34:36 +0000 (19:34 +0000)
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

13 files changed:
gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wpointer-sign-Wall.c
gcc/testsuite/gcc.dg/Wpointer-sign-pedantic.c
gcc/testsuite/gcc.dg/assign-warn-1.c
gcc/testsuite/gcc.dg/assign-warn-2.c
gcc/testsuite/gcc.dg/cleanup-1.c
gcc/testsuite/gcc.dg/conv-2.c
gcc/testsuite/gcc.dg/dfp/composite-type.c
gcc/testsuite/gcc.dg/noncompile/20020213-1.c
gcc/testsuite/gcc.dg/pr30949.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/transparent-union-1.c

index 5e93e9d96593d79b2d6f60f06ce0120253dd2efc..2fe77890a0ea71433c70c2e0d51602eef6ddc773 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
        * doc/extend.texi: Document AVX built-in functions.
index 9f725884e462807f83a591ea7888f04cd5190af0..85a94443a6e92f21d23eecece7d9cc690a798289 100644 (file)
@@ -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);
index 6af70c550c2a3b5ad19c7568e48aa4b9c1f142cc..30b43234013e128ea7406f3808197f4655d06ce1 100644 (file)
@@ -1,3 +1,17 @@
+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>
 
        * gfortran.dg/typebound_call_1.f03: New test.
index e72d37a18ce5648598dd39af9cd1ac3e1d106d9f..302d50e5cf18ced18d6f87045d6dc56ea721cd12 100644 (file)
@@ -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" } */
index 25e25209e524d98220ae5a9f1e03ee434ddf1aa9..8b92110988d9c0c4944abe22d33aa644ea5d55f0 100644 (file)
@@ -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" } */
index 1587c20d7b4e115faf708203a73d7bda390eb0f3..4c603829d59586fa74e4289bed4479cddbd5000c 100644 (file)
@@ -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 } */
index 0ef6ebe33b351fdf8fb8cb3efc446ae714fddaca..4656961f6c45b1f0fe608d89bbd9df5311d5b927 100644 (file)
@@ -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 } */
index e5853c4baa82daa2be4b874badd7b6362da66706..dd571635baf8bd0ec79a2fb2fc200cd74bb9f510 100644 (file)
@@ -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)
 {
index ac95584e3a6a09ce6426406fa86ae84542258a9f..388dee3d7463eeb949c3515cdc6a5ba926c0aa85 100644 (file)
@@ -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()
 {
index 56991add7f32a2f27b50af8ea52a0623b1568400..b2e7632e62adaf96125486f49411db5c50663087 100644 (file)
@@ -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()
 {
index c1de5663acecff297bc35a8dc7b7b6a4964c9df1..41480f0794da53e9cee61e25b7fb8f4665876f42 100644 (file)
@@ -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 (file)
index 0000000..a3f6a14
--- /dev/null
@@ -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" } */
+}
+
index a43e07953d3e28b04cbdceafd96ba66612703e19..2360912e3c5f670f8c612ab5b236ade59efee244 100644 (file)
@@ -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 } */