diff options
author | Greg McGary <gkm@gnu.org> | 1999-12-03 19:02:20 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 1999-12-03 19:02:20 +0000 |
commit | 3c12fcc27809a223032e1b0ad2beba1f6844a5c6 (patch) | |
tree | 7d5534785288859eef23b404bed24959cca1f313 /gcc/invoke.texi | |
parent | 7337695dc2c8f106fbad8b59ad2b4a2c9d413710 (diff) | |
download | gcc-3c12fcc27809a223032e1b0ad2beba1f6844a5c6.zip gcc-3c12fcc27809a223032e1b0ad2beba1f6844a5c6.tar.gz gcc-3c12fcc27809a223032e1b0ad2beba1f6844a5c6.tar.bz2 |
flags.h (warn_padded, [...]): Add global var decls.
* flags.h (warn_padded, warn_packed): Add global var decls.
* toplev.c (warn_padded, warn_packed): Add global var defns.
(W_options): Add warnings `-Wpacked' and `-Wpadded'.
* stor-layout.c (layout_record): Add local variable `type'
to hold often-used TREE_TYPE (field). Add local variable
`unpacked_align' to hold alignment that would be in force
if no `packed' attribute were present. Warn if `packed' attribute
is unnecessary, or even harmful. Warn when gcc inserts padding
to satisfy alignment requirements of members. Use NULL_TREE
when checking whether var_size is set.
* invoke.texi: Document new flags.
Co-Authored-By: Geoff Keating <geoffk@cygnus.com>
From-SVN: r30770
Diffstat (limited to 'gcc/invoke.texi')
-rw-r--r-- | gcc/invoke.texi | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/gcc/invoke.texi b/gcc/invoke.texi index 7e76139..ea90467 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -128,7 +128,7 @@ in the following sections. -Werror-implicit-function-declaration -Wfloat-equal -Winline -Wlarger-than-@var{len} -Wlong-long -Wmain -Wmissing-declarations -Wmissing-noreturn --Wmultichar -Wno-import +-Wmultichar -Wno-import -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wuninitialized -Wunknown-pragmas -Wunreachable-code @@ -1430,7 +1430,7 @@ arguments, two, or three arguments of appropriate types. Warn if a multicharacter constant (@samp{'FOOF'}) is used. Usually they indicate a typo in the user's code, as they have implementation-defined values, and should not be used in portable code. - + @item -Wparentheses Warn if parentheses are omitted in certain contexts, such as when there is an assignment in a context where a truth value @@ -1798,6 +1798,33 @@ be taken to manually verify functions actually do not ever return before adding the @code{noreturn} attribute, otherwise subtle code generation bugs could be introduced. +@item -Wpacked +Warn if a structure is given the packed attribute, but the packed +attribute has no effect on the layout or size of the structure. +Such structures may be mis-aligned for little benefit. For +instance, in this code, the variable @code{f.x} in @code{struct bar} +will be misaligned even though @code{struct bar} does not itself +have the packed attribute: + +@smallexample +@group +struct foo @{ + int x; + char a, b, c, d; +@} __attribute__((packed)); +struct bar @{ + char z; + struct foo f; +@}; +@end group +@end smallexample + +@item -Wpadded +Warn if padding is included in a structure, either to align an element +of the structure or to align the whole structure. Sometimes when this +happens it is possible to rearrange the fields of the structure to +reduce the padding and so make the structure smaller. + @item -Wredundant-decls Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing. |