diff options
author | Roger Sayle <roger@eyesopen.com> | 2004-09-26 14:58:34 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2004-09-26 14:58:34 +0000 |
commit | 897f610ba4492354c4bab4d61f476dc8d27c9124 (patch) | |
tree | aa76381885409572a4b6e89bce34c27e9ce000c8 /gcc/stor-layout.c | |
parent | 5c8c573a86eddc5949d59c602704775d1671a8fb (diff) | |
download | gcc-897f610ba4492354c4bab4d61f476dc8d27c9124.zip gcc-897f610ba4492354c4bab4d61f476dc8d27c9124.tar.gz gcc-897f610ba4492354c4bab4d61f476dc8d27c9124.tar.bz2 |
re PR middle-end/17112 (Copying of packed bitfields is wrong)
PR middle-end/17112
* stor-layout.c (compute_record_mode): For records with a single
field, only use the field's mode if its size matches what we'd
have choosen for the record ourselves. This forces the use of
BLKmode for packed records that don't completely fill a mode.
* gcc.dg/pr17112-1.c: New test case.
Co-Authored-By: Giovanni Bajo <giovannibajo@gcc.gnu.org>
From-SVN: r88130
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index ccbca42..4ac9340 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1296,12 +1296,14 @@ compute_record_mode (tree type) #endif /* MEMBER_TYPE_FORCES_BLK */ } - /* If we only have one real field; use its mode. This only applies to - RECORD_TYPE. This does not apply to unions. */ - if (TREE_CODE (type) == RECORD_TYPE && mode != VOIDmode) + TYPE_MODE (type) = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1); + + /* If we only have one real field; use its mode if that mode's size + matches the type's size. This only applies to RECORD_TYPE. This + does not apply to unions. */ + if (TREE_CODE (type) == RECORD_TYPE && mode != VOIDmode + && GET_MODE_SIZE (mode) == GET_MODE_SIZE (TYPE_MODE (type))) TYPE_MODE (type) = mode; - else - TYPE_MODE (type) = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1); /* If structure's known alignment is less than what the scalar mode would need, and it matters, then stick with BLKmode. */ |