diff mbox series

Print variadic C-functions properly in diagnostics

Message ID AM5PR0701MB265759B346184CAAEACEE1DAE4700@AM5PR0701MB2657.eurprd07.prod.outlook.com
State New
Headers show
Series Print variadic C-functions properly in diagnostics | expand

Commit Message

Bernd Edlinger Oct. 5, 2017, 4:16 p.m. UTC
Hi!

This fixes the c-pretty-printing of variadic function types by
adding ", ..." to the output of the function parameters.


Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.

Comments

Joseph Myers Oct. 5, 2017, 4:48 p.m. UTC | #1
On Thu, 5 Oct 2017, Bernd Edlinger wrote:

> Hi!
> 
> This fixes the c-pretty-printing of variadic function types by
> adding ", ..." to the output of the function parameters.
> 
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?

OK.
diff mbox series

Patch

c-family:
2017-10-05  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* c-pretty-print.c (pp_c_parameter_type_list): Print ... for variadic
	functions.

testsuite:
2017-10-05  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gcc.dg/Wincompatible-pointer-types-1.c: New test.


--- gcc/c-family/c-pretty-print.c	2017-08-07 10:37:07.000000000 +0200
+++ gcc/c-family/c-pretty-print.c	2017-10-04 12:38:09.412750910 +0200
@@ -521,6 +521,11 @@  pp_c_parameter_type_list (c_pretty_print
 	  else
 	    pp->abstract_declarator (TREE_VALUE (parms));
 	}
+      if (!first && !parms)
+	{
+	  pp_separate_with (pp, ',');
+	  pp_c_ws_string (pp, "...");
+	}
     }
   pp_c_right_paren (pp);
 }
--- /dev/null	2017-09-18 13:50:08.343098047 +0200
+++ gcc/testsuite/gcc.dg/Wincompatible-pointer-types-1.c	2017-10-04 18:05:24.172717734 +0200
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+void f (int, ...);
+
+int
+f1 (void)
+{
+  int (*x) ();
+  x = f; /* { dg-error "assignment to 'int \\(\\*\\)\\(\\)' from incompatible pointer type 'void \\(\\*\\)\\(int,  \.\.\.\\)'" } */
+  return x (1);
+}