+2018-11-25 Sandra Loosemore <sandra@codesourcery.com>
+
+ PR other/54265
+ * doc/extend.texi (Common Variable Attributes): Use preferred
+ placement of type attributes in examples, plus whitespace fixes.
+ (Type Attributes): Clarify why placement of attributes
+ immediately after struct/union/enum keyword is preferred.
+ (Common Type Attributes): Use preferred placement of type
+ attributes in examples, plus more whitespace fixes.
+
2018-11-25 Paul Koning <ni1d@arrl.net>
* config/pdp11/pdp11.h (TARGET_HAS_NO_HW_DIVIDE): Define.
@{
int i1;
int i2;
- unsigned long long x __attribute__((warn_if_not_aligned(16)));
+ unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
@};
@end smallexample
the misaligned offset:
@smallexample
-struct foo
+struct __attribute__ ((aligned (16))) foo
@{
int i1;
int i2;
- unsigned long long x __attribute__((warn_if_not_aligned(16)));
-@} __attribute__((aligned(16)));
+ unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
+@};
@end smallexample
This warning can be disabled by @option{-Wno-if-not-aligned}.
You may specify type attributes in an enum, struct or union type
declaration or definition by placing them immediately after the
-@code{struct}, @code{union} or @code{enum} keyword. A less preferred
-syntax is to place them just past the closing curly brace of the
-definition.
+@code{struct}, @code{union} or @code{enum} keyword. You can also place
+them just past the closing curly brace of the definition, but this is less
+preferred because logically the type should be fully defined at
+the closing brace.
You can also include type attributes in a @code{typedef} declaration.
@xref{Attribute Syntax}, for details of the exact syntax for using
bytes. For example, the declarations:
@smallexample
-struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
+struct __attribute__ ((aligned (8))) S @{ short f[3]; @};
typedef int more_aligned_int __attribute__ ((aligned (8)));
@end smallexample
example, you could write:
@smallexample
-struct S @{ short f[3]; @} __attribute__ ((aligned));
+struct __attribute__ ((aligned)) S @{ short f[3]; @};
@end smallexample
Whenever you leave out the alignment factor in an @code{aligned}
only able to arrange for variables to be aligned up to a certain maximum
alignment. (For some linkers, the maximum supported alignment may
be very very small.) If your linker is only able to align variables
-up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
+up to a maximum of 8-byte alignment, then specifying @code{aligned (16)}
in an @code{__attribute__} still only provides you with 8-byte
alignment. See your linker documentation for further information.
@smallexample
typedef unsigned long long __u64
- __attribute__((aligned(4),warn_if_not_aligned(8)));
+ __attribute__((aligned (4), warn_if_not_aligned (8)));
struct foo
@{
8 bytes. Align @code{struct foo} to 8 bytes:
@smallexample
-struct foo
+struct __attribute__ ((aligned (8))) foo
@{
int i1;
int i2;
__u64 x;
-@} __attribute__((aligned(8)));
+@};
@end smallexample
@noindent
when the structure field has the misaligned offset:
@smallexample
-struct foo
+struct __attribute__ ((aligned (8))) foo
@{
int i1;
int i2;
int i3;
__u64 x;
-@} __attribute__((aligned(8)));
+@};
@end smallexample
This warning can be disabled by @option{-Wno-if-not-aligned}.
Example of use:
@smallexample
-typedef short __attribute__((__may_alias__)) short_a;
+typedef short __attribute__ ((__may_alias__)) short_a;
int
main (void)