This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] Fix endless loop in the C FE initializer handling (PR c/85704)
- From: Richard Sandiford <richard dot sandiford at arm dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Marek Polacek <polacek at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Mar 2019 10:13:30 +0000
- Subject: Re: [C PATCH] Fix endless loop in the C FE initializer handling (PR c/85704)
- References: <20180724085756.GB17988@tucnak>
[Sorry for responding to such an old patch]
Jakub Jelinek <jakub@redhat.com> writes:
> +/* For two FIELD_DECLs in the same chain, return -1 if field1
> + comes before field2, 1 if field1 comes after field2 and
> + 0 if field1 == field2. */
> +
> +static int
> +field_decl_cmp (tree field1, tree field2)
> +{
> + if (field1 == field2)
> + return 0;
> +
> + tree bitpos1 = bit_position (field1);
> + tree bitpos2 = bit_position (field2);
> + if (tree_int_cst_equal (bitpos1, bitpos2))
> + {
> + /* If one of the fields has non-zero bitsize, then that
> + field must be the last one in a sequence of zero
> + sized fields, fields after it will have bigger
> + bit_position. */
> + if (TREE_TYPE (field1) != error_mark_node
> + && COMPLETE_TYPE_P (TREE_TYPE (field1))
> + && integer_nonzerop (TREE_TYPE (field1)))
> + return 1;
> + if (TREE_TYPE (field2) != error_mark_node
> + && COMPLETE_TYPE_P (TREE_TYPE (field2))
> + && integer_nonzerop (TREE_TYPE (field2)))
> + return -1;
Looks like these integer_nonzerop should be testing TYPE_SIZE or
TYPE_SIZE_UNIT -- not sure which is preferred here.
Thanks,
Richard