Patchwork [C] Another column info tweak (PR c/56989)

login
register
mail settings
Submitter Marek Polacek
Date April 29, 2014, 9:19 p.m.
Message ID <20140429211957.GE11802@redhat.com>
Download mbox | patch
Permalink /patch/344001/
State New
Headers show

Comments

Marek Polacek - April 29, 2014, 9:19 p.m.
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  <polacek@redhat.com>

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

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


	Marek
Jeff Law - April 30, 2014, 9:13 p.m.
On 04/29/14 15:19, Marek Polacek wrote:
> 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  <polacek@redhat.com>
>
> 	PR c/56989
> 	* c-typeck.c (default_conversion): Use better location for
> 	error call.
>
> 	* gcc.dg/pr56989.c: New test.
OK.  Thanks
Jeff

Patch

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;
+}