diff options
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 11 |
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. */ |