diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2005-08-08 14:22:35 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2005-08-08 14:22:35 +0000 |
commit | f303a996311673f8c9178f6593bf4c804077a8ec (patch) | |
tree | 2061e9e62bc833d5825ee342b6f3929525652c9e /gcc/stor-layout.c | |
parent | 4de997d1376a22a139c43ab64ab0c1482b5b4487 (diff) | |
download | gcc-f303a996311673f8c9178f6593bf4c804077a8ec.zip gcc-f303a996311673f8c9178f6593bf4c804077a8ec.tar.gz gcc-f303a996311673f8c9178f6593bf4c804077a8ec.tar.bz2 |
re PR c++/21166 (g++ gives error on reference to packed structure elements)
.: PR c++/21166
* stor-layout.c (finalize_type_size): Undo DECL_PACKED when possible.
testsuite:
PR c++/21166
* g++.dg/other/crash-4.C: Adjust
* g++/dg/ext/packed9.C: New.
From-SVN: r102858
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 77dfc19..321a4d2 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1477,6 +1477,8 @@ finalize_type_size (tree type) void finish_record_layout (record_layout_info rli, int free_p) { + tree field; + /* Compute the final size. */ finalize_record_size (rli); @@ -1486,6 +1488,15 @@ finish_record_layout (record_layout_info rli, int free_p) /* Perform any last tweaks to the TYPE_SIZE, etc. */ finalize_type_size (rli->t); + /* We might be able to clear DECL_PACKED on any members that happen + to be suitably aligned (not forgetting the alignment of the type + itself). */ + for (field = TYPE_FIELDS (rli->t); field; field = TREE_CHAIN (field)) + if (TREE_CODE (field) == FIELD_DECL && DECL_PACKED (field) + && DECL_OFFSET_ALIGN (field) >= TYPE_ALIGN (TREE_TYPE (field)) + && TYPE_ALIGN (rli->t) >= TYPE_ALIGN (TREE_TYPE (field))) + DECL_PACKED (field) = 0; + /* Lay out any static members. This is done now because their type may use the record's type. */ while (rli->pending_statics) |