This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] pr69477 - attribute aligned documentation misleading
- From: Martin Sebor <msebor at gmail dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 25 Jan 2016 15:13:14 -0700
- Subject: [PATCH] pr69477 - attribute aligned documentation misleading
- Authentication-results: sourceware.org; auth=none
The attached patch adjusts the documentation of attribute aligned
and attribute pack so as to prevent misreading the text of the
former attribute as if it had read:
Specifying attribute aligned for struct and union types is
equivalent to specifying the packed attribute on each of
the structure or union members. ...
Martin
PR other/69477 - attribute aligned documentation misleading
gcc/ChangeLog:
2016-01-25 Martin Sebor <msebor@redhat.com>
PR other/69477
* doc/extend.texi (Common Type Attributes): Move text that talks about
attribute packed from attribute aligned to the section discussing
the former attribute for clarity.
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi (revision 232765)
+++ gcc/doc/extend.texi (working copy)
@@ -6307,9 +6307,6 @@ relevant type, and the code that the com
pointer arithmetic operations is often more efficient for
efficiently-aligned types than for other types.
-The @code{aligned} attribute can only increase the alignment; but you
-can decrease it by specifying @code{packed} as well. See below.
-
Note that the effectiveness of @code{aligned} attributes may be limited
by inherent limitations in your linker. On many systems, the linker is
only able to arrange for variables to be aligned up to a certain maximum
@@ -6319,36 +6316,8 @@ up to a maximum of 8-byte alignment, the
in an @code{__attribute__} still only provides you with 8-byte
alignment. See your linker documentation for further information.
-@opindex fshort-enums
-Specifying this attribute for @code{struct} and @code{union} types is
-equivalent to specifying the @code{packed} attribute on each of the
-structure or union members. Specifying the @option{-fshort-enums}
-flag on the line is equivalent to specifying the @code{packed}
-attribute on all @code{enum} definitions.
-
-In the following example @code{struct my_packed_struct}'s members are
-packed closely together, but the internal layout of its @code{s} member
-is not packed---to do that, @code{struct my_unpacked_struct} needs to
-be packed too.
-
-@smallexample
-struct my_unpacked_struct
- @{
- char c;
- int i;
- @};
-
-struct __attribute__ ((__packed__)) my_packed_struct
- @{
- char c;
- int i;
- struct my_unpacked_struct s;
- @};
-@end smallexample
-
-You may only specify this attribute on the definition of an @code{enum},
-@code{struct} or @code{union}, not on a @code{typedef} that does not
-also define the enumerated type, structure or union.
+The @code{aligned} attribute can only increase alignment. Alignment
+can be decreased by specifying the @code{packed} attribute. See below.
@item bnd_variable_size
@cindex @code{bnd_variable_size} type attribute
@@ -6476,6 +6445,37 @@ of the structure or union is placed to m
attached to an @code{enum} definition, it indicates that the smallest
integral type should be used.
+@opindex fshort-enums
+Specifying the @code{packed} attribute for @code{struct} and @code{union}
+types is equivalent to specifying the @code{packed} attribute on each
+of the structure or union members. Specifying the @option{-fshort-enums}
+flag on the command line is equivalent to specifying the @code{packed}
+attribute on all @code{enum} definitions.
+
+In the following example @code{struct my_packed_struct}'s members are
+packed closely together, but the internal layout of its @code{s} member
+is not packed---to do that, @code{struct my_unpacked_struct} needs to
+be packed too.
+
+@smallexample
+struct my_unpacked_struct
+ @{
+ char c;
+ int i;
+ @};
+
+struct __attribute__ ((__packed__)) my_packed_struct
+ @{
+ char c;
+ int i;
+ struct my_unpacked_struct s;
+ @};
+@end smallexample
+
+You may only specify the @code{packed} attribute attribute on the definition
+of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
+that does not also define the enumerated type, structure or union.
+
@item scalar_storage_order ("@var{endianness}")
@cindex @code{scalar_storage_order} type attribute
When attached to a @code{union} or a @code{struct}, this attribute sets