OSDN Git Service

* de.po: Update.
[pf3gnuchains/gcc-fork.git] / gcc / doc / extend.texi
index 0edf2cf..7825a12 100644 (file)
@@ -1069,11 +1069,12 @@ This will work with all versions of GCC@.
 
 Compound expressions, conditional expressions and casts are allowed as
 lvalues provided their operands are lvalues.  This means that you can take
-their addresses or store values into them.
+their addresses or store values into them.  All these extensions are
+deprecated.
 
-Standard C++ allows compound expressions and conditional expressions as
-lvalues, and permits casts to reference type, so use of this extension
-is deprecated for C++ code.
+Standard C++ allows compound expressions and conditional expressions
+as lvalues, and permits casts to reference type, so use of this
+extension is not supported for C++ code.
 
 For example, a compound expression can be assigned, provided the last
 expression in the sequence is an lvalue.  These two expressions are
@@ -1101,7 +1102,8 @@ expressions are equivalent:
 (a ? b = 5 : (c = 5))
 @end example
 
-A cast is a valid lvalue if its operand is an lvalue.  A simple
+A cast is a valid lvalue if its operand is an lvalue.  This extension
+is deprecated.  A simple
 assignment whose left-hand side is a cast works by converting the
 right-hand side first to the specified type, then to the type of the
 inner left-hand side expression.  After this is stored, the value is
@@ -1980,9 +1982,9 @@ attributes are currently defined for functions on all targets:
 @code{format}, @code{format_arg}, @code{no_instrument_function},
 @code{section}, @code{constructor}, @code{destructor}, @code{used},
 @code{unused}, @code{deprecated}, @code{weak}, @code{malloc},
-@code{alias}, and @code{nonnull}.  Several other attributes are defined
-for functions on particular target systems.  Other attributes, including
-@code{section} are supported for variables declarations
+@code{alias}, @code{warn_unused_result} and @code{nonnull}.  Several other
+attributes are defined for functions on particular target systems.  Other
+attributes, including @code{section} are supported for variables declarations
 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
 
 You may also specify attributes with @samp{__} preceding and following
@@ -2020,6 +2022,10 @@ would happen if @code{fatal} ever did return.  This makes slightly
 better code.  More importantly, it helps avoid spurious warnings of
 uninitialized variables.
 
+The @code{noreturn} keyword does not affect the exceptional path when that
+applies: a @code{noreturn}-marked function may still return to the caller
+by throwing an exception.
+
 Do not assume that registers saved by the calling function are
 restored before calling the @code{noreturn} function.
 
@@ -2312,6 +2318,26 @@ results in a warning on line 3 but not line 2.
 The @code{deprecated} attribute can also be used for variables and
 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
 
+@item warn_unused_result
+@cindex @code{warn_unused_result} attribute
+The @code{warn_unused_result} attribute causes a warning to be emitted
+if a caller of the function with this attribute does not use its
+return value.  This is useful for functions where not checking
+the result is either a security problem or always a bug, such as
+@code{realloc}.
+
+@smallexample
+int fn () __attribute__ ((warn_unused_result));
+int foo ()
+@{
+  if (fn () < 0) return -1;
+  fn ();
+  return 0;
+@}
+@end smallexample
+
+results in warning on line 5.
+
 @item weak
 @cindex @code{weak} attribute
 The @code{weak} attribute causes the declaration to be emitted as a weak
@@ -2452,11 +2478,11 @@ instruction directly.
 
 @item function_vector
 @cindex calling functions through the function vector on the H8/300 processors
-Use this attribute on the H8/300 and H8/300H to indicate that the specified
+Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
 function should be called through the function vector.  Calling a
 function through the function vector will reduce code size, however;
 the function vector has a limited size (maximum 128 entries on the H8/300
-and 64 entries on the H8/300H) and shares space with the interrupt vector.
+and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
 
 You must use GAS and GLD from GNU binutils version 2.7 or later for
 this attribute to work correctly.
@@ -2468,8 +2494,8 @@ that the specified function is an interrupt handler.  The compiler will
 generate function entry and exit sequences suitable for use in an
 interrupt handler when this attribute is present.
 
-Note, interrupt handlers for the H8/300, H8/300H and SH processors can
-be specified via the @code{interrupt_handler} attribute.
+Note, interrupt handlers for the m68k, H8/300, H8/300H, H8S, and SH processors
+can be specified via the @code{interrupt_handler} attribute.
 
 Note, on the AVR, interrupts will be enabled inside the function.
 
@@ -2483,9 +2509,9 @@ void f () __attribute__ ((interrupt ("IRQ")));
 Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF@.
 
 @item interrupt_handler
-@cindex interrupt handler functions on the H8/300 and SH processors
-Use this attribute on the H8/300, H8/300H and SH to indicate that the
-specified function is an interrupt handler.  The compiler will generate
+@cindex interrupt handler functions on the m68k, H8/300 and SH processors
+Use this attribute on the m68k, H8/300, H8/300H, H8S, and SH to indicate that
+the specified function is an interrupt handler.  The compiler will generate
 function entry and exit sequences suitable for use in an interrupt
 handler when this attribute is present.
 
@@ -2502,13 +2528,13 @@ void f () __attribute__ ((interrupt_handler,
 @end smallexample
 
 @item trap_exit
-Use this attribute on the SH for an @code{interrupt_handle} to return using
+Use this attribute on the SH for an @code{interrupt_handler} to return using
 @code{trapa} instead of @code{rte}.  This attribute expects an integer
 argument specifying the trap number to be used.
 
 @item eightbit_data
-@cindex eight bit data on the H8/300 and H8/300H
-Use this attribute on the H8/300 and H8/300H to indicate that the specified
+@cindex eight bit data on the H8/300, H8/300H, and H8S
+Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
 variable should be placed into the eight bit data section.
 The compiler will generate more efficient code for certain operations
 on data in the eight bit data area.  Note the eight bit data area is limited to
@@ -2518,13 +2544,19 @@ You must use GAS and GLD from GNU binutils version 2.7 or later for
 this attribute to work correctly.
 
 @item tiny_data
-@cindex tiny data section on the H8/300H
-Use this attribute on the H8/300H to indicate that the specified
+@cindex tiny data section on the H8/300H and H8S
+Use this attribute on the H8/300H and H8S to indicate that the specified
 variable should be placed into the tiny data section.
 The compiler will generate more efficient code for loads and stores
 on data in the tiny data section.  Note the tiny data area is limited to
 slightly under 32kbytes of data.
 
+@item saveall
+@cindex save all registers on the H8/300, H8/300H, and H8S
+Use this attribute on the H8/300, H8/300H, and H8S to indicate that
+all registers except the stack pointer should be saved in the prologue
+regardless of whether they are used or not.
+
 @item signal
 @cindex signal handler functions on the AVR processors
 Use this attribute on the AVR to indicate that the specified
@@ -2604,7 +2636,7 @@ Currently, the attribute is ignored for inlined functions. If the
 attribute is applied to a symbol @emph{definition}, an error is reported.
 If a symbol previously declared @code{dllimport} is later defined, the
 attribute is ignored in subsequent references, and a warning is emitted.
-The attribute is also overriden by a subsequent declaration as
+The attribute is also overridden by a subsequent declaration as
 @code{dllexport}. 
 
 When applied to C++ classes, the attribute marks non-inlined
@@ -2686,7 +2718,7 @@ found convenient to use @code{__attribute__} to achieve a natural
 attachment of attributes to their corresponding declarations, whereas
 @code{#pragma GCC} is of use for constructs that do not naturally form
 part of the grammar.  @xref{Other Directives,,Miscellaneous
-Preprocessing Directives, cpp, The C Preprocessor}.
+Preprocessing Directives, cpp, The GNU C Preprocessor}.
 
 @node Attribute Syntax
 @section Attribute Syntax
@@ -3785,7 +3817,7 @@ the single copy in the library.
 
 Since GCC eventually will implement ISO C99 semantics for
 inline functions, it is best to use @code{static inline} only
-to guarentee compatibility.  (The
+to guarantee compatibility.  (The
 existing semantics will remain available when @option{-std=gnu89} is
 specified, but eventually the default will be @option{-std=gnu99} and
 that will implement the C99 semantics, though it does not do so yet.)
@@ -4116,6 +4148,26 @@ If you are writing a header file that should be includable in ISO C
 programs, write @code{__asm__} instead of @code{asm}.  @xref{Alternate
 Keywords}.
 
+@subsection Size of an @code{asm}
+
+Some targets require that GCC track the size of each instruction used in
+order to generate correct code.  Because the final length of an
+@code{asm} is only known by the assembler, GCC must make an estimate as
+to how big it will be.  The estimate is formed by counting the number of
+statements in the pattern of the @code{asm} and multiplying that by the
+length of the longest instruction on that processor.  Statements in the
+@code{asm} are identified by newline characters and whatever statement
+separator characters are supported by the assembler; on most processors
+this is the `@code{;}' character.
+
+Normally, GCC's estimate is perfectly adequate to ensure that correct
+code is generated, but it is possible to confuse the compiler if you use
+pseudo instructions or assembler macros that expand into multiple real
+instructions or if you use assembler directives that expand to more
+space in the object file than would be needed for a single instruction.
+If this happens then the assembler will produce a diagnostic saying that
+a label is unreachable.
+
 @subsection i386 floating point asm operands
 
 There are several rules on the usage of stack-like regs in
@@ -4756,13 +4808,43 @@ v4si f (v4si a, v4si b, v4si c)
 @findex cabs
 @findex cabsf
 @findex cabsl
+@findex cacos
+@findex cacosf
+@findex cacosh
+@findex cacoshf
+@findex cacoshl
+@findex cacosl
 @findex calloc
+@findex carg
+@findex cargf
+@findex cargl
+@findex casin
+@findex casinf
+@findex casinh
+@findex casinhf
+@findex casinhl
+@findex casinl
+@findex catan
+@findex catanf
+@findex catanh
+@findex catanhf
+@findex catanhl
+@findex catanl
 @findex cbrt
 @findex cbrtf
 @findex cbrtl
+@findex ccos
+@findex ccosf
+@findex ccosh
+@findex ccoshf
+@findex ccoshl
+@findex ccosl
 @findex ceil
 @findex ceilf
 @findex ceill
+@findex cexp
+@findex cexpf
+@findex cexpl
 @findex cimag
 @findex cimagf
 @findex cimagl
@@ -4778,9 +4860,30 @@ v4si f (v4si a, v4si b, v4si c)
 @findex coshf
 @findex coshl
 @findex cosl
+@findex cpow
+@findex cpowf
+@findex cpowl
+@findex cproj
+@findex cprojf
+@findex cprojl
 @findex creal
 @findex crealf
 @findex creall
+@findex csin
+@findex csinf
+@findex csinh
+@findex csinhf
+@findex csinhl
+@findex csinl
+@findex csqrt
+@findex csqrtf
+@findex csqrtl
+@findex ctan
+@findex ctanf
+@findex ctanh
+@findex ctanhf
+@findex ctanhl
+@findex ctanl
 @findex dcgettext
 @findex dgettext
 @findex drem
@@ -5046,32 +5149,44 @@ mode.
 The ISO C99 functions
 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
-@code{cabsf}, @code{cabsl}, @code{cabs}, @code{cbrtf}, @code{cbrtl},
-@code{cbrt}, @code{cimagf}, @code{cimagl}, @code{cimag}, @code{conjf},
-@code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
-@code{copysign}, @code{crealf}, @code{creall}, @code{creal},
-@code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
-@code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
-@code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
-@code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
-@code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
-@code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
-@code{imaxabs}, @code{lgammaf}, @code{lgammal}, @code{lgamma},
-@code{llabs}, @code{llrintf}, @code{llrintl}, @code{llrint},
-@code{llroundf}, @code{llroundl}, @code{llround}, @code{log1pf},
-@code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l}, @code{log2},
-@code{logbf}, @code{logbl}, @code{logb}, @code{lrintf}, @code{lrintl},
-@code{lrint}, @code{lroundf}, @code{lroundl}, @code{lround},
-@code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
-@code{nextafterf}, @code{nextafterl}, @code{nextafter},
-@code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
-@code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
-@code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
-@code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
-@code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
-@code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
-@code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
-@code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf},
+@code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
+@code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
+@code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
+@code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
+@code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
+@code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
+@code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
+@code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
+@code{cimagl}, @code{cimag},
+@code{conjf}, @code{conjl}, @code{conj}, @code{copysignf},
+@code{copysignl}, @code{copysign}, @code{cpowf}, @code{cpowl},
+@code{cpow}, @code{cprojf}, @code{cprojl}, @code{cproj}, @code{crealf},
+@code{creall}, @code{creal}, @code{csinf}, @code{csinhf}, @code{csinhl},
+@code{csinh}, @code{csinl}, @code{csin}, @code{csqrtf}, @code{csqrtl},
+@code{csqrt}, @code{ctanf}, @code{ctanhf}, @code{ctanhl}, @code{ctanh},
+@code{ctanl}, @code{ctan}, @code{erfcf}, @code{erfcl}, @code{erfc},
+@code{erff}, @code{erfl}, @code{erf}, @code{exp2f}, @code{exp2l},
+@code{exp2}, @code{expm1f}, @code{expm1l}, @code{expm1}, @code{fdimf},
+@code{fdiml}, @code{fdim}, @code{fmaf}, @code{fmal}, @code{fmaxf},
+@code{fmaxl}, @code{fmax}, @code{fma}, @code{fminf}, @code{fminl},
+@code{fmin}, @code{hypotf}, @code{hypotl}, @code{hypot}, @code{ilogbf},
+@code{ilogbl}, @code{ilogb}, @code{imaxabs}, @code{lgammaf},
+@code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf},
+@code{llrintl}, @code{llrint}, @code{llroundf}, @code{llroundl},
+@code{llround}, @code{log1pf}, @code{log1pl}, @code{log1p},
+@code{log2f}, @code{log2l}, @code{log2}, @code{logbf}, @code{logbl},
+@code{logb}, @code{lrintf}, @code{lrintl}, @code{lrint}, @code{lroundf},
+@code{lroundl}, @code{lround}, @code{nearbyintf}, @code{nearbyintl},
+@code{nearbyint}, @code{nextafterf}, @code{nextafterl},
+@code{nextafter}, @code{nexttowardf}, @code{nexttowardl},
+@code{nexttoward}, @code{remainderf}, @code{remainderl},
+@code{remainder}, @code{remquof}, @code{remquol}, @code{remquo},
+@code{rintf}, @code{rintl}, @code{rint}, @code{roundf}, @code{roundl},
+@code{round}, @code{scalblnf}, @code{scalblnl}, @code{scalbln},
+@code{scalbnf}, @code{scalbnl}, @code{scalbn}, @code{snprintf},
+@code{tgammaf}, @code{tgammal}, @code{tgamma}, @code{truncf},
+@code{truncl}, @code{trunc}, @code{vfscanf}, @code{vscanf},
+@code{vsnprintf} and @code{vsscanf}
 are handled as built-in functions
 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c89}).
 
@@ -7519,8 +7634,8 @@ can also use most of the C language extensions in your C++ programs).  If you
 want to write code that checks whether these features are available, you can
 test for the GNU compiler the same way as for C programs: check for a
 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
-test specifically for GNU C++ (@pxref{Standard Predefined,,Standard
-Predefined Macros,cpp.info,The C Preprocessor}).
+test specifically for GNU C++ (@pxref{Common Predefined Macros,,
+Predefined Macros,cpp,The GNU C Preprocessor}).
 
 @menu
 * Min and Max::                C++ Minimum and maximum operators.
@@ -7534,6 +7649,7 @@ Predefined Macros,cpp.info,The C Preprocessor}).
 * Bound member functions:: You can extract a function pointer to the
                         method denoted by a @samp{->*} or @samp{.*} expression.
 * C++ Attributes::      Variable, function, and type attributes for C++ only.
+* Strong Using::      Strong using-directives for namespace composition.
 * Java Exceptions::     Tweaking exception handling to work with Java.
 * Deprecated Features:: Things will disappear from g++.
 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
@@ -8134,6 +8250,45 @@ interface table mechanism, instead of regular virtual table dispatch.
 
 @end table
 
+See also @xref{Strong Using}.
+
+@node Strong Using
+@section Strong Using
+
+A using-directive with @code{__attribute ((strong))} is stronger
+than a normal using-directive in two ways:
+
+@itemize @bullet
+@item
+Templates from the used namespace can be specialized as though they were members of the using namespace.
+
+@item
+The using namespace is considered an associated namespace of all
+templates in the used namespace for purposes of argument-dependent
+name lookup.
+@end itemize
+
+This is useful for composing a namespace transparently from
+implementation namespaces.  For example:
+
+@smallexample
+namespace std @{
+  namespace debug @{
+    template <class T> struct A @{ @};
+  @}
+  using namespace debug __attribute ((__strong__));
+  template <> struct A<int> @{ @};   // ok to specialize
+
+  template <class T> void f (A<T>);
+@}
+
+int main()
+@{
+  f (std::A<float>());             // lookup finds std::f
+  f (std::A<int>());
+@}
+@end smallexample
+
 @node Java Exceptions
 @section Java Exceptions