aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorAdam Nemet <anemet@caviumnetworks.com>2009-01-23 06:29:54 +0000
committerAdam Nemet <nemet@gcc.gnu.org>2009-01-23 06:29:54 +0000
commit2cd36c22d3d16e24f342829a989ac35f2f442656 (patch)
treef2ccff5eab03e65287a19a85ac3f6e9c2d8e320d /gcc/doc
parent5cf9cc965f9307beeed14acf4814677041e5bad7 (diff)
downloadgcc-2cd36c22d3d16e24f342829a989ac35f2f442656.zip
gcc-2cd36c22d3d16e24f342829a989ac35f2f442656.tar.gz
gcc-2cd36c22d3d16e24f342829a989ac35f2f442656.tar.bz2
c-decl.c (finish_struct): Move code to set DECL_PACKED after DECL_BIT_FIELD is alreay known.
* c-decl.c (finish_struct): Move code to set DECL_PACKED after DECL_BIT_FIELD is alreay known. Also inherit packed for bitfields regardless of their type. * c-common.c (handle_packed_attribute): Don't ignore packed on bitfields. * c.opt (Wpacked-bitfield-compat): New warning option. * stor-layout.c (place_field): Warn if offset of a field changed. * doc/extend.texi (packed): Mention the ABI change. * doc/invoke.texi (-Wpacked-bitfield-compat): Document. (Warning Options): Add it to the list. cp/ * class.c (check_field_decls): Also inherit packed for bitfields regardless of their type. testsuite/ * gcc.dg/bitfld-15.c, gcc.dg/bitfld-16.c, gcc.dg/bitfld-17.c,gcc.dg/bitfld-18.c: New tests. * g++.dg/ext/bitfield2.C, g++.dg/ext/bitfield3.C, g++.dg/ext/bitfield4.C, g++.dg/ext/bitfield5.C: New tests. From-SVN: r143584
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi6
-rw-r--r--gcc/doc/invoke.texi23
2 files changed, 28 insertions, 1 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 264e88a..79a8c2e 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -3824,6 +3824,12 @@ struct foo
@};
@end smallexample
+@emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
+@code{packed} attribute on bit-fields of type @code{char}. This has
+been fixed in GCC 4.4 but the change can lead to differences in the
+structure layout. See the documention of
+@option{-Wpacked-bitfield-compat} for more information.
+
@item section ("@var{section-name}")
@cindex @code{section} variable attribute
Normally, the compiler places the objects it generates in sections like
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b0e274c..247782a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -249,7 +249,7 @@ Objective-C and Objective-C++ Dialects}.
-Wmissing-format-attribute -Wmissing-include-dirs @gol
-Wmissing-noreturn -Wno-mudflap @gol
-Wno-multichar -Wnonnull -Wno-overflow @gol
--Woverlength-strings -Wpacked -Wpadded @gol
+-Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded @gol
-Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
-Wpointer-arith -Wno-pointer-to-int-cast @gol
-Wredundant-decls @gol
@@ -3974,6 +3974,27 @@ struct bar @{
@end group
@end smallexample
+@item -Wpacked-bitfield-compat
+@opindex Wpacked-bitfield-compat
+@opindex Wno-packed-bitfield-compat
+The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
+on bit-fields of type @code{char}. This has been fixed in GCC 4.4 but
+the change can lead to differences in the structure layout. GCC
+informs you when the offset of such a field has changed in GCC 4.4.
+For example there is no longer a 4-bit padding between field @code{a}
+and @code{b} in this structure:
+
+@smallexample
+struct foo
+@{
+ char a:4;
+ char b:8;
+@} __attribute__ ((packed));
+@end smallexample
+
+This warning is enabled by default. Use
+@option{-Wno-packed-bitfield-compat} to disable this warning.
+
@item -Wpadded
@opindex Wpadded
@opindex Wno-padded