On Thu, 26 Nov 2020, Jakub Jelinek wrote:

> Hi!
> 
> On Wed, Nov 25, 2020 at 12:26:17PM -0500, Jason Merrill wrote:
> > I think you want to check DECL_PADDING_P here; the C and C++ front ends set
> > it on unnamed bit-fields, and that's what is_empty_type looks at.
> 
> While the above has been written in the context of __builtin_bit_cast patch,
> I think it applies to __builtin_clear_padding too.
> 
> So this patch implements that.  The C FE sets DECL_PADDING_P solely on the
> DECL_BIT_FIELD !DECL_NAME FIELD_DECLs, the C++ FE sets it on those and in
> another spot I haven't really figured out what it is about.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richard.

> 2020-11-26  Jakub Jelinek  <ja...@redhat.com>
> 
>       * gimple-fold.c (clear_padding_union): Ignore DECL_PADDING_P
>       fields.
>       (clear_padding_type): Ignore DECL_PADDING_P fields, rather than
>       DECL_BIT_FIELD with NULL DECL_NAME.
> 
> --- gcc/gimple-fold.c.jj      2020-11-25 10:37:44.997297061 +0100
> +++ gcc/gimple-fold.c 2020-11-25 18:45:04.380442914 +0100
> @@ -4327,7 +4327,7 @@ clear_padding_union (clear_padding_struc
>      }
>  
>    for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
> -    if (TREE_CODE (field) == FIELD_DECL)
> +    if (TREE_CODE (field) == FIELD_DECL && !DECL_PADDING_P (field))
>        {
>       if (DECL_SIZE_UNIT (field) == NULL_TREE)
>         {
> @@ -4455,13 +4455,11 @@ clear_padding_type (clear_padding_struct
>        HOST_WIDE_INT cur_pos;
>        cur_pos = 0;
>        for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN 
> (field))
> -     if (TREE_CODE (field) == FIELD_DECL)
> +     if (TREE_CODE (field) == FIELD_DECL && !DECL_PADDING_P (field))
>         {
>           tree ftype = TREE_TYPE (field);
>           if (DECL_BIT_FIELD (field))
>             {
> -             if (DECL_NAME (field) == NULL_TREE)
> -               continue;
>               HOST_WIDE_INT fldsz = TYPE_PRECISION (ftype);
>               if (fldsz == 0)
>                 continue;
> 
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imend

Reply via email to