diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2015-11-08 18:33:42 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2015-11-08 18:33:42 +0000 |
commit | ee45a32dae253f7daa966573eb8cb64b2cf7bf52 (patch) | |
tree | cf927ff52a6d5ba28290472db09363fe67a835d6 /gcc/doc | |
parent | eb11eb157cf07500e2915da8a72f2f3a501cc5ae (diff) | |
download | gcc-ee45a32dae253f7daa966573eb8cb64b2cf7bf52.zip gcc-ee45a32dae253f7daa966573eb8cb64b2cf7bf52.tar.gz gcc-ee45a32dae253f7daa966573eb8cb64b2cf7bf52.tar.bz2 |
Merge of the scalar-storage-order branch.
From-SVN: r229965
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/extend.texi | 69 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 22 |
2 files changed, 79 insertions, 12 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 26afc00..08d4420 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -6395,6 +6395,42 @@ of the structure or union is placed to minimize the memory required. When attached to an @code{enum} definition, it indicates that the smallest integral type should be used. +@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 +the storage order, aka endianness, of the scalar fields of the type, as +well as the array fields whose component is scalar. The supported +endianness are @code{big-endian} and @code{little-endian}. The attribute +has no effects on fields which are themselves a @code{union}, a @code{struct} +or an array whose component is a @code{union} or a @code{struct}, and it is +possible to have fields with a different scalar storage order than the +enclosing type. + +This attribute is supported only for targets that use a uniform default +scalar storage order (fortunately, most of them), i.e. targets that store +the scalars either all in big-endian or all in little-endian. + +Additional restrictions are enforced for types with the reverse scalar +storage order with regard to the scalar storage order of the target: + +@itemize +@item Taking the address of a scalar field of a @code{union} or a +@code{struct} with reverse scalar storage order is not permitted and will +yield an error. +@item Taking the address of an array field, whose component is scalar, of +a @code{union} or a @code{struct} with reverse scalar storage order is +permitted but will yield a warning, unless @option{-Wno-scalar-storage-order} +is specified. +@item Taking the address of a @code{union} or a @code{struct} with reverse +scalar storage order is permitted. +@end itemize + +These restrictions exist because the storage order attribute is lost when +the address of a scalar or the address of an array with scalar component +is taken, so storing indirectly through this address will generally not work. +The second case is nevertheless allowed to be able to perform a block copy +from or to the array. + @item transparent_union @cindex @code{transparent_union} type attribute @@ -18432,7 +18468,7 @@ for further explanation. * Darwin Pragmas:: * Solaris Pragmas:: * Symbol-Renaming Pragmas:: -* Structure-Packing Pragmas:: +* Structure-Layout Pragmas:: * Weak Pragmas:: * Diagnostic Pragmas:: * Visibility Pragmas:: @@ -18708,8 +18744,8 @@ the name does not change. always the C-language name. @end enumerate -@node Structure-Packing Pragmas -@subsection Structure-Packing Pragmas +@node Structure-Layout Pragmas +@subsection Structure-Layout Pragmas For compatibility with Microsoft Windows compilers, GCC supports a set of @code{#pragma} directives that change the maximum alignment of @@ -18732,17 +18768,30 @@ multiple @code{#pragma pack(@var{n})} instances and finalized by a single @code{#pragma pack(pop)}. @end enumerate -Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct} -@code{#pragma} which lays out a structure as the documented -@code{__attribute__ ((ms_struct))}. +Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct} +directive which lays out structures and unions subsequently defined as the +documented @code{__attribute__ ((ms_struct))}. + @enumerate -@item @code{#pragma ms_struct on} turns on the layout for structures -declared. -@item @code{#pragma ms_struct off} turns off the layout for structures -declared. +@item @code{#pragma ms_struct on} turns on the Microsoft layout. +@item @code{#pragma ms_struct off} turns off the Microsoft layout. @item @code{#pragma ms_struct reset} goes back to the default layout. @end enumerate +Most targets also support the @code{#pragma scalar_storage_order} directive +which lays out structures and unions subsequently defined as the documented +@code{__attribute__ ((scalar_storage_order))}. + +@enumerate +@item @code{#pragma scalar_storage_order big-endian} sets the storage order +of the scalar fields to big-endian. +@item @code{#pragma scalar_storage_order little-endian} sets the storage order +of the scalar fields to little-endian. +@item @code{#pragma scalar_storage_order default} goes back to the endianness +that was in effect when compilation started (see also command-line option +@option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}). +@end enumerate + @node Weak Pragmas @subsection Weak Pragmas diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 2e5953b..dc9a4e7 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -169,10 +169,11 @@ in the following sections. -aux-info @var{filename} -fallow-parameterless-variadic-functions @gol -fno-asm -fno-builtin -fno-builtin-@var{function} @gol -fhosted -ffreestanding -fopenacc -fopenmp -fopenmp-simd @gol --fms-extensions -fplan9-extensions -trigraphs -traditional -traditional-cpp @gol +-fms-extensions -fplan9-extensions -fsso-struct=@var{endianness} -fallow-single-precision -fcond-mismatch -flax-vector-conversions @gol -fsigned-bitfields -fsigned-char @gol --funsigned-bitfields -funsigned-char} +-funsigned-bitfields -funsigned-char @gol +-trigraphs -traditional -traditional-cpp} @item C++ Language Options @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. @@ -278,6 +279,7 @@ Objective-C and Objective-C++ Dialects}. -Wshift-overflow -Wshift-overflow=@var{n} @gol -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value @gol -Wsign-compare -Wsign-conversion -Wfloat-conversion @gol +-Wno-scalar-storage-order @gol -Wsizeof-pointer-memaccess -Wsizeof-array-argument @gol -Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol -Wstrict-aliasing=n @gol -Wstrict-overflow -Wstrict-overflow=@var{n} @gol @@ -2076,6 +2078,17 @@ These options control whether a bit-field is signed or unsigned, when the declaration does not use either @code{signed} or @code{unsigned}. By default, such a bit-field is signed, because this is consistent: the basic integer types such as @code{int} are signed types. + +@item -fsso-struct=@var{endianness} +@opindex fsso-struct +Set the default scalar storage order of structures and unions to the +specified endianness. The accepted values are @samp{big-endian} and +@samp{little-endian}. If the option is not passed, the compiler uses +the native endianness of the target. This option is not supported for C++. + +@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate +code that is not binary compatible with code generated without it if the +specified endianness is not the native endianness of the target. @end table @node C++ Dialect Options @@ -5113,6 +5126,11 @@ This includes conversions from real to integer, and from higher precision real to lower precision real values. This option is also enabled by @option{-Wconversion}. +@item -Wno-scalar-storage-order +@opindex -Wno-scalar-storage-order +@opindex -Wscalar-storage-order +Do not warn on suspicious constructs involving reverse scalar storage order. + @item -Wsized-deallocation @r{(C++ and Objective-C++ only)} @opindex Wsized-deallocation @opindex Wno-sized-deallocation |