diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2012-11-30 22:36:07 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2012-11-30 22:36:07 +0000 |
commit | a37d67b62172f4835d32a83bf54c8c1b4d171271 (patch) | |
tree | 8742e0d457e3f981f7a1906fe1a27dfb6a4e6600 | |
parent | d5651dcfe8b168b8e91a7fe1d32bc955187f9177 (diff) | |
download | gcc-a37d67b62172f4835d32a83bf54c8c1b4d171271.zip gcc-a37d67b62172f4835d32a83bf54c8c1b4d171271.tar.gz gcc-a37d67b62172f4835d32a83bf54c8c1b4d171271.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/stor-layout.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/specs/pack9.ads | 15 |
4 files changed, 32 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c80c41a..356bb36 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2012-11-30 Eric Botcazou <ebotcazou@adacore.com> + + * 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 <dje.gcc@gmail.com> * xcoffout.c (xcoff_tls_data_section_name): Define. diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 3d97796..4227694 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 6bfa093..573e390 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-11-30 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/specs/pack9.ads: New test. + 2012-11-30 Martin Jambor <mjambor@suse.cz> 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 0000000..9d5e027 --- /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; |