Re: [C PATCH] Fix up composite_types (PR c/70280)

2016-03-19 Thread Joseph Myers
On Thu, 17 Mar 2016, Jakub Jelinek wrote:

> Hi!
> 
> Zdenek reported a compare debug issue, where it is dumping used function
> prototypes and there is a difference between -g0 and -g in
> -2:   static int BIO_vsnprintf (char *, size_t, const char *, struct  *, 
> void, ...);
> +2:   static int BIO_vsnprintf (char *, size_t, const char *, struct  *);
> The former is of course wrong, and the reason for that is that C FE's
> composite_type mishandles void_list_node - that should terminate the list
> if there are no varargs, it is not a void argument or something similar,
> and if the original lists are terminated by that, the new one should be too.
> Testcase is not included, as it is too large and reduction didn't work very
> well for that.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

OK.

-- 
Joseph S. Myers
jos...@codesourcery.com


[C PATCH] Fix up composite_types (PR c/70280)

2016-03-19 Thread Jakub Jelinek
Hi!

Zdenek reported a compare debug issue, where it is dumping used function
prototypes and there is a difference between -g0 and -g in
-2:   static int BIO_vsnprintf (char *, size_t, const char *, struct  *, void, 
...);
+2:   static int BIO_vsnprintf (char *, size_t, const char *, struct  *);
The former is of course wrong, and the reason for that is that C FE's
composite_type mishandles void_list_node - that should terminate the list
if there are no varargs, it is not a void argument or something similar,
and if the original lists are terminated by that, the new one should be too.
Testcase is not included, as it is too large and reduction didn't work very
well for that.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2016-03-17  Jakub Jelinek  

PR c/70280
* c-typeck.c (composite_type): Don't count void_list_node
into len, if the list is terminated by void_list_node, start
with void_list_node instead of NULL for newargs.  Stop
at void_list_node.

--- gcc/c/c-typeck.c.jj 2016-03-16 18:15:28.0 +0100
+++ gcc/c/c-typeck.c2016-03-17 18:14:58.840886755 +0100
@@ -518,15 +518,17 @@ composite_type (tree t1, tree t2)
/* If both args specify argument types, we must merge the two
   lists, argument by argument.  */
 
-   len = list_length (p1);
-   newargs = 0;
+   for (len = 0, newargs = p1;
+newargs && newargs != void_list_node;
+len++, newargs = TREE_CHAIN (newargs))
+ ;
 
for (i = 0; i < len; i++)
  newargs = tree_cons (NULL_TREE, NULL_TREE, newargs);
 
n = newargs;
 
-   for (; p1;
+   for (; p1 && p1 != void_list_node;
 p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n))
  {
/* A null type means arg type is not specified.

Jakub