aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-02-05 18:53:59 +0100
committerJakub Jelinek <jakub@redhat.com>2024-02-05 18:53:59 +0100
commit194ab79b580b69554124cf8257b19c957690a8a8 (patch)
treed15717fc3151a140c35c598931f256f0b0adf602 /gcc/c
parent8ca585e56c1d6837f96ddd88c13ed1e815c74f93 (diff)
downloadgcc-194ab79b580b69554124cf8257b19c957690a8a8.zip
gcc-194ab79b580b69554124cf8257b19c957690a8a8.tar.gz
gcc-194ab79b580b69554124cf8257b19c957690a8a8.tar.bz2
c: Avoid ICE with _BitInt(N) : 0 bitfield [PR113740]
finish_struct already made sure not to call build_bitint_type for signed _BitInt(2) : 1; or signed _BitInt(2) : 0; bitfields (but instead build a zero precision integral type, we remove it later), this patch makes sure we do it also for unsigned _BitInt(1) : 0; because of the build_bitint_type assertion that precision is >= (unsigned ? 1 : 2). 2024-02-05 Jakub Jelinek <jakub@redhat.com> PR c/113740 * c-decl.cc (finish_struct): Only use build_bitint_type if bit-field has width larger or equal to minimum _BitInt precision. * gcc.dg/bitint-85.c: New test.
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/c-decl.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 934e557..fe20bc2 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -9555,7 +9555,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
if (width != TYPE_PRECISION (type))
{
if (TREE_CODE (type) == BITINT_TYPE
- && (width > 1 || TYPE_UNSIGNED (type)))
+ && width >= (TYPE_UNSIGNED (type) ? 1 : 2))
TREE_TYPE (field)
= build_bitint_type (width, TYPE_UNSIGNED (type));
else