aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2006-10-23 16:36:51 +0000
committerPaul Brook <pbrook@gcc.gnu.org>2006-10-23 16:36:51 +0000
commit353293e7f758be575d88aa78edb9ccddb7816cba (patch)
treeb5a2423de4a0bde33164ad736843458ea9f47818
parent6915c1cea268ed78af4db03fe631e927d63fdf0c (diff)
downloadgcc-353293e7f758be575d88aa78edb9ccddb7816cba.zip
gcc-353293e7f758be575d88aa78edb9ccddb7816cba.tar.gz
gcc-353293e7f758be575d88aa78edb9ccddb7816cba.tar.bz2
stor-layout.c (start_record_layout): maximum_field_alignment overrides STRUCTURE_SIZE_BOUNDARY.
2006-10-23 Paul Brook <paul@codesourcery.com> gcc/ * stor-layout.c (start_record_layout): maximum_field_alignment overrides STRUCTURE_SIZE_BOUNDARY. gcc/testsuite/ * gcc.dg/pragma-pack-5.c: New test. From-SVN: r117977
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/stor-layout.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/pragma-pack-5.c10
4 files changed, 28 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4c022e5..6e9c9f5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-23 Paul Brook <paul@codesourcery.com>
+
+ * stor-layout.c (start_record_layout): maximum_field_alignment
+ overrides STRUCTURE_SIZE_BOUNDARY.
+
2006-10-23 Ulrich Weigand <uweigand@de.ibm.com>
* config/s390/predicates.md ("bras_sym_operand"): Do not accept
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index d1e18a2..51db310 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 b5cd901..d6acf66 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2006-10-23 Paul Brook <paul@codesourcery.com>
+
+ * gcc.dg/pragma-pack-5.c: New test.
+
2006-10-23 Ulrich Weigand <uweigand@de.ibm.com>
* 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 0000000..897686f
--- /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];