At least for function calls we can use their location info
to generate better diagnostics.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-04-29  Marek Polacek  <pola...@redhat.com>

        PR c/56989
        * c-typeck.c (default_conversion): Use better location for
        error call.

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

diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 62c72df..0eee40a 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -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;
     }
 
diff --git gcc/testsuite/gcc.dg/pr56989.c gcc/testsuite/gcc.dg/pr56989.c
index e69de29..beb9806 100644
--- gcc/testsuite/gcc.dg/pr56989.c
+++ gcc/testsuite/gcc.dg/pr56989.c
@@ -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;
+}

        Marek

Reply via email to