https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128302
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For __builtin_clear_padding,
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -4781,6 +4781,23 @@ clear_padding_union (clear_padding_struct *buf, tree
type,
union_buf->size = start_size;
memset (union_buf->buf, ~0, start_size);
clear_padding_type (union_buf, TREE_TYPE (field), fldsz,
for_auto_init);
+ if (DECL_BIT_FIELD (field)
+ && (TYPE_PRECISION (TREE_TYPE (field)) % BITS_PER_UNIT) != 0)
+ {
+ HOST_WIDE_INT bits
+ = TYPE_PRECISION (TREE_TYPE (field)) % BITS_PER_UNIT;
+ if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN)
+ sorry_at (buf->loc, "PDP11 bit-field handling unsupported"
+ " in %qs", "__builtin_clear_padding");
+ else if (BYTES_BIG_ENDIAN)
+ /* Big endian. */
+ union_buf->buf[union_buf->size - 1]
+ |= ((1U << BITS_PER_UNIT) - 1) >> bits;
+ else
+ /* Little endian. */
+ union_buf->buf[union_buf->size - 1]
+ |= ~((1 << bits) - 1);
+ }
clear_padding_add_padding (union_buf, sz - fldsz);
clear_padding_flush (union_buf, true);
}
works for me (but will need to write testcases etc.).
Also discovered that
struct B { _BitInt(65535) a : 65531; } b;
void
foo ()
{
__builtin_clear_padding (&b);
}
ICEs, will need to fix that separately.