diff options
author | Richard Guenther <rguenther@suse.de> | 2012-03-16 11:47:26 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2012-03-16 11:47:26 +0000 |
commit | 2447776cc92a53f18c9a439e198cfd1d8f9cb330 (patch) | |
tree | 12f156b2aa3208d9537ce80c5796aaa8041091a4 | |
parent | 86286a8a969979fabab15c052ad8540e44a61720 (diff) | |
download | gcc-2447776cc92a53f18c9a439e198cfd1d8f9cb330.zip gcc-2447776cc92a53f18c9a439e198cfd1d8f9cb330.tar.gz gcc-2447776cc92a53f18c9a439e198cfd1d8f9cb330.tar.bz2 |
stor-layout.c (finish_bitfield_representative): Fall back to the conservative maximum size if...
2012-03-16 Richard Guenther <rguenther@suse.de>
* stor-layout.c (finish_bitfield_representative): Fall back
to the conservative maximum size if we cannot compute the
size of the tail padding.
* gnat.dg/specs/pack7.ads: New testcase.
From-SVN: r185464
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/stor-layout.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/specs/pack7.ads | 13 |
4 files changed, 34 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5ba4e52..c827218 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-03-16 Richard Guenther <rguenther@suse.de> + + * stor-layout.c (finish_bitfield_representative): Fall back + to the conservative maximum size if we cannot compute the + size of the tail padding. + 2012-03-16 Tristan Gingold <gingold@adacore.com> * config/vms/vms.h (TARGET_OS_CPP_BUILTINS): Define diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 7c7fabc..98b7886 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1765,6 +1765,9 @@ finish_bitfield_representative (tree repr, tree field) - tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1) + tree_low_cst (DECL_SIZE (field), 1)); + /* Round up bitsize to multiples of BITS_PER_UNIT. */ + bitsize = (bitsize + BITS_PER_UNIT - 1) & ~(BITS_PER_UNIT - 1); + /* Now nothing tells us how to pad out bitsize ... */ nextf = DECL_CHAIN (field); while (nextf && TREE_CODE (nextf) != FIELD_DECL) @@ -1787,12 +1790,16 @@ finish_bitfield_representative (tree repr, tree field) { /* ??? If you consider that tail-padding of this struct might be re-used when deriving from it we cannot really do the following - and thus need to set maxsize to bitsize? */ + and thus need to set maxsize to bitsize? Also we cannot + generally rely on maxsize to fold to an integer constant, so + use bitsize as fallback for this case. */ tree maxsize = size_diffop (TYPE_SIZE_UNIT (DECL_CONTEXT (field)), DECL_FIELD_OFFSET (repr)); - gcc_assert (host_integerp (maxsize, 1)); - maxbitsize = (tree_low_cst (maxsize, 1) * BITS_PER_UNIT - - tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1)); + if (host_integerp (maxsize, 1)) + maxbitsize = (tree_low_cst (maxsize, 1) * BITS_PER_UNIT + - tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1)); + else + maxbitsize = bitsize; } /* Only if we don't artificially break up the representative in @@ -1801,9 +1808,6 @@ finish_bitfield_representative (tree repr, tree field) at byte offset. */ gcc_assert (maxbitsize % BITS_PER_UNIT == 0); - /* Round up bitsize to multiples of BITS_PER_UNIT. */ - bitsize = (bitsize + BITS_PER_UNIT - 1) & ~(BITS_PER_UNIT - 1); - /* Find the smallest nice mode to use. */ for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b79bdcc..eddbfac 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-03-16 Richard Guenther <rguenther@suse.de> + + * gnat.dg/specs/pack7.ads: New testcase. + 2012-03-15 Jakub Jelinek <jakub@redhat.com> PR target/52568 diff --git a/gcc/testsuite/gnat.dg/specs/pack7.ads b/gcc/testsuite/gnat.dg/specs/pack7.ads new file mode 100644 index 0000000..8a1250a --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/pack7.ads @@ -0,0 +1,13 @@ +-- { dg-do compile } + +package Pack7 is + + type R (D : Natural) is record + S : String (1 .. D); + N : Natural; + B : Boolean; + end record; + for R'Alignment use 4; + pragma Pack (R); + +end Pack7; |