re PR c/56989 (wrong location in error message)
authorMarek Polacek <polacek@redhat.com>
Thu, 1 May 2014 07:08:19 +0000 (07:08 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 1 May 2014 07:08:19 +0000 (07:08 +0000)
PR c/56989
* c-typeck.c (default_conversion): Use better location for
error call.

* gcc.dg/pr56989.c: New test.

From-SVN: r209969

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr56989.c [new file with mode: 0644]

index bf61610e37cb2c7a7ecef29700186734f41d75c7..cee032969b622253aceb0332c957bd5fa2021acc 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c/56989
+       * c-typeck.c (default_conversion): Use better location for
+       error call.
+
 2014-04-30  Marek Polacek  <polacek@redhat.com>
 
        * c-typeck.c (build_binary_op): Call ubsan_instrument_division
index cb8ae44e3632cf613d49aaf183ebf8c9fedaa003..409b0a7b99cbeef4e6305aaadb8c9d1ef1c45d66 100644 (file)
@@ -2107,7 +2107,8 @@ default_conversion (tree exp)
 
   if (code == VOID_TYPE)
     {
-      error ("void value not ignored as it ought to be");
+      error_at (EXPR_LOC_OR_LOC (exp, input_location),
+               "void value not ignored as it ought to be");
       return error_mark_node;
     }
 
index a927fddbbf69cd11c4f7e17771d2b4ff555977f5..c62126e98dc3bd119155ac6a8c6221d6436271aa 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c/56989
+       * gcc.dg/pr56989.c: New test.
+
 2014-04-30  Ian Lance Taylor  <iant@google.com>
 
        * go.test/go-test.exp (go-gc-tests): For rundir, pass extra files
diff --git a/gcc/testsuite/gcc.dg/pr56989.c b/gcc/testsuite/gcc.dg/pr56989.c
new file mode 100644 (file)
index 0000000..beb9806
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR c/56989 */
+/* { dg-do compile } */
+
+extern void voidf (void);
+extern int intf (void);
+
+int
+f (void)
+{
+  if (intf () < 0
+      || voidf () < 0) /* { dg-error "10:void value not ignored as it ought to be" } */
+    return 1;
+
+  if (voidf () < 0 /* { dg-error "7:void value not ignored as it ought to be" } */
+      || intf () < 0)
+    return 1;
+
+  return 0;
+}