From 467cecf3b892c8b74cf0aafe0d6974c9ee66700a Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 3 Sep 2004 17:22:40 +0000 Subject: re PR c/7054 (#pragma pack handled incorrectly) PR c/7054 * defaults.h (TARGET_DEFAULT_PACK_STRUCT): Provide default. * tree.h (initial_max_fld_align): Declare * stor-layout.c (initial_max_fld_align): Define and initialize. (maximum_field_alignment): Initialize to the same value. * common.opt: Add -fpack-struct= variant of switch. * opts.c: Handle -fpack-struct= variant of switch. * c-pragma.c: Change #pragma pack() handling so that it becomes compatible to other compilers: accept individual 'push' argument, make final pop restore (command line) default, correct interaction of push/pop and sole specification of a new alignment (so that the sequence #pragma pack(push) - #pragma pack() becomes identical to #pragma pack(push, ). * doc/extend.texi: New node "Structure-Packing Pragmas" under "Pragmas", describing #pragma pack. * doc/invoke.texi: Document -fpack-struct= variant of switch. * doc/tm.texi: Adjust description for HANDLE_PRAGMA_PACK_PUSH_POP. Document new TARGET_DEFAULT_PACK_STRUCT. testsuite: * gcc.dg/pack-test-2.c: Adjust to permit and check #pragma pack(push). * gcc.dg/c99-flex-array-4.c: Add -fpack-struct=8 to provide a deterministic starting point for the alignment of structure fields. * gcc.dg/Wpadded.c: Dito. * g++.dg/abi/vbase10.C: Dito. From-SVN: r87037 --- gcc/stor-layout.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/stor-layout.c') diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 395a5f9..75ff523 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -43,7 +43,9 @@ tree sizetype_tab[(int) TYPE_KIND_LAST]; /* If nonzero, this is an upper limit on alignment of structure fields. The value is measured in bits. */ -unsigned int maximum_field_alignment; +unsigned int maximum_field_alignment = TARGET_DEFAULT_PACK_STRUCT * BITS_PER_UNIT; +/* ... and its original value in bytes, specified via -fpack-struct=. */ +unsigned int initial_max_fld_align = TARGET_DEFAULT_PACK_STRUCT; /* If nonzero, the alignment of a bitstring or (power-)set value, in bits. May be overridden by front-ends. */ -- cgit v1.1