From a37d67b62172f4835d32a83bf54c8c1b4d171271 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 30 Nov 2012 22:36:07 +0000 Subject: [PATCH] stor-layout.c (bit_field_mode_iterator::bit_field_mode_iterator): Deal with degenerate cases where the bitsize isn't positive. * stor-layout.c (bit_field_mode_iterator::bit_field_mode_iterator): Deal with degenerate cases where the bitsize isn't positive. Rework comment. From-SVN: r194009 --- gcc/ChangeLog | 5 +++++ gcc/stor-layout.c | 12 ++++++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/specs/pack9.ads | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/specs/pack9.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c80c41a8a6f..356bb36bce2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2012-11-30 Eric Botcazou + + * stor-layout.c (bit_field_mode_iterator::bit_field_mode_iterator): Deal + with degenerate cases where the bitsize isn't positive. Rework comment. + 2012-11-30 David Edelsohn * xcoffout.c (xcoff_tls_data_section_name): Define. diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 3d97796da5c..4227694a4be 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2648,10 +2648,14 @@ bit_field_mode_iterator { if (!bitregion_end_) { - /* We can assume that any aligned chunk of UNITS bits that overlaps - the bitfield is mapped and won't trap. */ - unsigned HOST_WIDE_INT units = MIN (align, MAX (BIGGEST_ALIGNMENT, - BITS_PER_WORD)); + /* We can assume that any aligned chunk of ALIGN bits that overlaps + the bitfield is mapped and won't trap, provided that ALIGN isn't + too large. The cap is the biggest required alignment for data, + or at least the word size. And force one such chunk at least. */ + unsigned HOST_WIDE_INT units + = MIN (align, MAX (BIGGEST_ALIGNMENT, BITS_PER_WORD)); + if (bitsize <= 0) + bitsize = 1; bitregion_end_ = bitpos + bitsize + units - 1; bitregion_end_ -= bitregion_end_ % units + 1; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6bfa0933eef..573e3906357 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-11-30 Eric Botcazou + + * gnat.dg/specs/pack9.ads: New test. + 2012-11-30 Martin Jambor PR middle-end/52890 diff --git a/gcc/testsuite/gnat.dg/specs/pack9.ads b/gcc/testsuite/gnat.dg/specs/pack9.ads new file mode 100644 index 00000000000..9d5e02764be --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/pack9.ads @@ -0,0 +1,15 @@ +-- { dg-do compile } + +package Pack9 is + + subtype Zero is Natural range 0 .. 0; + + type Rec (D : Boolean) is record + case D is + when True => Z : Zero; + when False => null; + end case; + end record; + pragma Pack (Rec); + +end Pack9;