diff options
author | Dale Johannesen <dalej@apple.com> | 2006-01-28 17:37:24 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2006-01-28 17:37:24 +0000 |
commit | 265648f9331cbfc03fd7a174726c51cb22dcc696 (patch) | |
tree | f6113faf5c9e05bd1c4f6a7fe0f10e7cbf5b5bfe | |
parent | a2ae0f3e13616f4421f45ce2ecb4aacd91d6cfeb (diff) |
2006-01-28 Dale Johannesen <dalej@apple.com>apple/gcc-5316
Radar 4420068
* gcc.apple/bitreverse-17.c: New.
2006-01-28 Dale Johannesen <dalej@apple.com>
Radar 4420068
* stor-layout.c (place_field): don't adjust
rli->bitpos and rli->offset after a non-bitfield
whose type is zero-sized.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/apple-local-200502-branch@110328 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog.apple-ppc | 7 | ||||
-rw-r--r-- | gcc/stor-layout.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog.apple-ppc | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.apple/bitreverse-17.c | 72 |
4 files changed, 95 insertions, 5 deletions
diff --git a/gcc/ChangeLog.apple-ppc b/gcc/ChangeLog.apple-ppc index be55f043322..5a70f1af4de 100644 --- a/gcc/ChangeLog.apple-ppc +++ b/gcc/ChangeLog.apple-ppc @@ -1,3 +1,10 @@ +2006-01-28 Dale Johannesen <dalej@apple.com> + + Radar 4420068 + * stor-layout.c (place_field): don't adjust + rli->bitpos and rli->offset after a non-bitfield + whose type is zero-sized. + 2006-01-27 Stuart Hastings <stuart@apple.com> Radar 4176531 diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 78c083e5b4d..4664171159e 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -918,7 +918,10 @@ place_field (record_layout_info rli, tree field) /* If the alignment is still within offset_align, just align the bit position. */ - if (desired_align < rli->offset_align) + /* APPLE LOCAL begin 4420068 */ + if (desired_align < rli->offset_align + && (!targetm.reverse_bitfields_p (rli->t) || rli->bitfield_seen)) + /* APPLE LOCAL end 4420068 */ rli->bitpos = round_up (rli->bitpos, desired_align); else { @@ -1272,9 +1275,9 @@ place_field (record_layout_info rli, tree field) { rli->bitpos = size_binop (PLUS_EXPR, rli->bitpos, DECL_SIZE (field)); normalize_rli (rli); - /* APPLE LOCAL begin 4401223 4401224 */ + /* APPLE LOCAL begin 4401223 4401224 4420068 */ if (targetm.reverse_bitfields_p (rli->t) && !DECL_BIT_FIELD_TYPE (field) - && !rli->bitfield_seen) + && !rli->bitfield_seen && !integer_zerop (TYPE_SIZE (TREE_TYPE (field)))) { tree tsize = TYPE_SIZE (TREE_TYPE (field)); /* If we've gone into the next word, move "offset" forward and @@ -1282,7 +1285,10 @@ place_field (record_layout_info rli, tree field) non-bitfields to get following bitfields laid out correctly. However, if we've already seen a bitfield earlier in the struct, don't do this compensation. This makes no sense - and results in overlapping fields, but is what CW does. */ + and results in overlapping fields, but is what CW does. + (If this field has a 0-sized type, we have not advanced from the + previous field, so there's no need to do anything. Conveniently, + this avoids an infinite loop here.) */ while (! INT_CST_LT_UNSIGNED (rli->bitpos, tsize)) { rli->offset = size_binop (PLUS_EXPR, rli->offset, @@ -1291,7 +1297,7 @@ place_field (record_layout_info rli, tree field) tsize); } } - /* APPLE LOCAL end 4401223 4401224 */ + /* APPLE LOCAL end 4401223 4401224 4420068 */ } } diff --git a/gcc/testsuite/ChangeLog.apple-ppc b/gcc/testsuite/ChangeLog.apple-ppc index 8d99ddbb85f..32667e45869 100644 --- a/gcc/testsuite/ChangeLog.apple-ppc +++ b/gcc/testsuite/ChangeLog.apple-ppc @@ -1,3 +1,8 @@ +2006-01-28 Dale Johannesen <dalej@apple.com> + + Radar 4420068 + * gcc.apple/bitreverse-17.c: New. + 2006-01-27 Stuart Hastings <stuart@apple.com> Radar 4176531 diff --git a/gcc/testsuite/gcc.apple/bitreverse-17.c b/gcc/testsuite/gcc.apple/bitreverse-17.c new file mode 100644 index 00000000000..bfc0c0f5a34 --- /dev/null +++ b/gcc/testsuite/gcc.apple/bitreverse-17.c @@ -0,0 +1,72 @@ +/* APPLE LOCAL file 4420068 */ +/* Exercise zero-length fields. */ + +/* { dg-do run { target powerpc*-*-darwin* } } */ +/* { dg-options "-std=gnu99" } */ + +#pragma reverse_bitfields on +struct empty {}; + +struct uc0 { unsigned char content[0]; }; + +struct nest_uc0 { struct uc0 foo; }; + +struct uc0_uib2 { unsigned char foo[0]; unsigned int xx : 2; }; + +struct nest_nest_uc0_uib3 { struct nest_uc0 xx; unsigned int yy : 3; }; + +struct nest_empty_uib3 { struct empty e; unsigned int zz : 3; }; + +union size0 { struct empty e; int i[0]; }; + +union u0 { struct uc0 ss; unsigned int i; }; + +union u1 { struct nest_uc0 ss; unsigned int i; }; + +union u2 { struct uc0_uib2 ss; unsigned int i; }; + +union u3 { struct nest_nest_uc0_uib3 ss; unsigned int i; }; + +union u4 { struct nest_empty_uib3 ss; unsigned int i; }; + +union u5 { union size0 ss; unsigned int i; }; + +struct advance { + char c; + int spacer[0]; + char d; +}; + +struct advance2 { + char c; + struct empty s; + char d; +}; + +struct advance3 { + char c; + union size0 u; + char d; +}; + +int main() { + + if (sizeof(struct empty) !=0 || + sizeof(struct uc0) !=0 + || sizeof(struct uc0_uib2) != 4 + || sizeof(struct nest_nest_uc0_uib3) != 4 + || sizeof(struct nest_empty_uib3) != 4 + || sizeof(union size0) != 0 + || sizeof(union u0) != 4 + || sizeof(union u1) != 4 + || sizeof(union u2) != 4 + || sizeof(union u3) != 4 + || sizeof(union u4) != 4 + || sizeof(union u5) != 4 + || sizeof(struct advance) != 8 + || sizeof(struct advance2) != 2 + || sizeof(struct advance3) != 8) + return 42; + return 0; +} +
\ No newline at end of file |