This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C PATCH] Fix up composite_types (PR c/70280)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>, Marek Polacek <polacek at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 17 Mar 2016 20:32:14 +0100
- Subject: [C PATCH] Fix up composite_types (PR c/70280)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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 <jakub@redhat.com>
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.000000000 +0100
+++ gcc/c/c-typeck.c 2016-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