summaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorJ"orn Rennecke <joern.rennecke@st.com>2005-08-23 12:27:53 +0000
committerJoern Rennecke <amylaar@gcc.gnu.org>2005-08-23 13:27:53 +0100
commit39d67d5bd4adfe3af3e581dc4309f1a5319f8f21 (patch)
treeefb0232bd620d3f2ac48704c6333162375b44560 /gcc/stor-layout.c
parent9191d641185448ad719c02beefd994fc7c5dacbf (diff)
downloadgcc-39d67d5bd4adfe3af3e581dc4309f1a5319f8f21.tar.gz
re PR middle-end/23467 (alignment of member doesn't always carry over to alignment of struct.)
gcc: PR middle-end/23467 * stor-layout.c (finalize_type_size): Dont override existing alignment with a smaller alignment from the mode. testsuite: PR middle-end/23467 * gcc.c-torture/execute/pr23467.c: New test. From-SVN: r103394
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 321a4d24ca4..0ec818d7fbd 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1407,8 +1407,15 @@ finalize_type_size (tree type)
&& TREE_CODE (type) != QUAL_UNION_TYPE
&& TREE_CODE (type) != ARRAY_TYPE)))
{
- TYPE_ALIGN (type) = GET_MODE_ALIGNMENT (TYPE_MODE (type));
- TYPE_USER_ALIGN (type) = 0;
+ unsigned mode_align = GET_MODE_ALIGNMENT (TYPE_MODE (type));
+
+ /* Don't override a larger alignment requirement coming from a user
+ alignment of one of the fields. */
+ if (mode_align >= TYPE_ALIGN (type))
+ {
+ TYPE_ALIGN (type) = mode_align;
+ TYPE_USER_ALIGN (type) = 0;
+ }
}
/* Do machine-dependent extra alignment. */