diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4c022e5071b..6e9c9f583e4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2006-10-23 Paul Brook + + * stor-layout.c (start_record_layout): maximum_field_alignment + overrides STRUCTURE_SIZE_BOUNDARY. + 2006-10-23 Ulrich Weigand * config/s390/predicates.md ("bras_sym_operand"): Do not accept diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index d1e18a243d0..51db310bd48 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -531,7 +531,15 @@ start_record_layout (tree t) #ifdef STRUCTURE_SIZE_BOUNDARY /* Packed structures don't need to have minimum size. */ if (! TYPE_PACKED (t)) - rli->record_align = MAX (rli->record_align, (unsigned) STRUCTURE_SIZE_BOUNDARY); + { + unsigned tmp; + + /* #pragma pack overrides STRUCTURE_SIZE_BOUNDARY. */ + tmp = (unsigned) STRUCTURE_SIZE_BOUNDARY; + if (maximum_field_alignment != 0) + tmp = MIN (tmp, maximum_field_alignment); + rli->record_align = MAX (rli->record_align, tmp); + } #endif rli->offset = size_zero_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b5cd9012f62..d6acf665e19 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2006-10-23 Paul Brook + + * gcc.dg/pragma-pack-5.c: New test. + 2006-10-23 Ulrich Weigand * g++.dg/other/s390-1.C: New testcase. diff --git a/gcc/testsuite/gcc.dg/pragma-pack-5.c b/gcc/testsuite/gcc.dg/pragma-pack-5.c new file mode 100644 index 00000000000..897686f772a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pragma-pack-5.c @@ -0,0 +1,10 @@ +/* Check that pragma pack overrides STRUCTURE_SIZE_BOUNDARY. */ +/* { dg-do compile } */ + +#pragma pack(1) +struct S +{ + char a; +}; + +int test[sizeof(struct S) == 1 ? 1: -1];