OSDN Git Service

Upgrade to AutoGen 5 Template
[pf3gnuchains/gcc-fork.git] / gcc / extend.texi
index c1cd788..6b08843 100644 (file)
@@ -1,4 +1,4 @@
-@c Copyright (C) 1988,89,92,93,94,96 Free Software Foundation, Inc.
+@c Copyright (C) 1988,1989,1992,1993,1994,1996,1998,1999,2000,2001 Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
 
@@ -7,7 +7,7 @@
 @cindex extensions, C language
 @cindex C language extensions
 
-GNU C provides several language features not found in ANSI standard C.
+GNU C provides several language features not found in ISO standard C.
 (The @samp{-pedantic} option directs GNU CC to print a warning message if
 any of these features is used.)  To test for the availability of these
 features in conditional compilation, check for a predefined macro
@@ -17,6 +17,13 @@ These extensions are available in C and Objective C.  Most of them are
 also available in C++.  @xref{C++ Extensions,,Extensions to the
 C++ Language}, for extensions that apply @emph{only} to C++.
 
+@c FIXME: document clearly which features are in ISO C99, but also
+@c accepted as extensions for -std=gnu89 and possibly for C++.
+@c See PR other/930.
+
+@c FIXME: the documentation for preprocessor extensions here is out of
+@c date.  See PR other/928.
+
 @c The only difference between the two versions of this menu is that the
 @c version for clear INTERNALS has an extra node, "Constraints" (which
 @c appears in a separate chapter in the other version of the manual).
@@ -36,7 +43,9 @@ C++ Language}, for extensions that apply @emph{only} to C++.
 * Hex Floats::          Hexadecimal floating-point constants.
 * Zero Length::         Zero-length arrays.
 * Variable Length::     Arrays whose length is computed at run time.
-* Macro Varargs::      Macros with variable number of arguments.
+* Variadic Macros::    Macros with a variable number of arguments.
+* Escaped Newlines::    Slightly looser rules for escaped newlines.
+* Multi-line Strings::  String literals with embedded newlines.
 * Subscripting::        Any array can be subscripted, even if not an lvalue.
 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
 * Initializers::        Non-constant initializers.
@@ -47,6 +56,7 @@ C++ Language}, for extensions that apply @emph{only} to C++.
 * Case Ranges::                `case 1 ... 9' and such.
 * Function Attributes:: Declaring that functions have no side effects,
                          or that they can never return.
+* Attribute Syntax::    Formal syntax for attributes.
 * Function Prototypes:: Prototype declarations and old-style definitions.
 * C++ Comments::        C++ comments are recognized.
 * Dollar Signs::        Dollar sign is allowed in identifiers.
@@ -64,6 +74,7 @@ C++ Language}, for extensions that apply @emph{only} to C++.
 * Function Names::     Printable strings which are the name of the current
                         function.
 * Return Address::      Getting the return or frame address of a function.
+* Other Builtins::      Other built-in functions.
 @end menu
 @end ifset
 @ifclear INTERNALS
@@ -82,7 +93,9 @@ C++ Language}, for extensions that apply @emph{only} to C++.
 * Hex Floats::          Hexadecimal floating-point constants.
 * Zero Length::         Zero-length arrays.
 * Variable Length::     Arrays whose length is computed at run time.
-* Macro Varargs::      Macros with variable number of arguments.
+* Variadic Macros::    Macros with a variable number of arguments.
+* Escaped Newlines::    Slightly looser rules for escaped newlines.
+* Multi-line Strings::  String literals with embedded newlines.
 * Subscripting::        Any array can be subscripted, even if not an lvalue.
 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
 * Initializers::        Non-constant initializers.
@@ -93,6 +106,7 @@ C++ Language}, for extensions that apply @emph{only} to C++.
 * Case Ranges::                `case 1 ... 9' and such.
 * Function Attributes:: Declaring that functions have no side effects,
                          or that they can never return.
+* Attribute Syntax::    Formal syntax for attributes.
 * Function Prototypes:: Prototype declarations and old-style definitions.
 * C++ Comments::        C++ comments are recognized.
 * Dollar Signs::        Dollar sign is allowed in identifiers.
@@ -111,6 +125,7 @@ C++ Language}, for extensions that apply @emph{only} to C++.
 * Function Names::     Printable strings which are the name of the current
                         function.
 * Return Address::      Getting the return or frame address of a function.
+* Other Builtins::      Other built-in functions.
 @end menu
 @end ifclear
 
@@ -178,6 +193,39 @@ If you don't know the type of the operand, you can still do this, but you
 must use @code{typeof} (@pxref{Typeof}) or type naming (@pxref{Naming
 Types}).
 
+Statement expressions are not supported fully in G++, and their fate
+there is unclear.  (It is possible that they will become fully supported
+at some point, or that they will be deprecated, or that the bugs that
+are present will continue to exist indefinitely.)  Presently, statement
+expressions do not work well as default arguments.
+
+In addition, there are semantic issues with statement-expressions in
+C++.  If you try to use statement-expressions instead of inline
+functions in C++, you may be surprised at the way object destruction is
+handled.  For example:
+
+@example
+#define foo(a)  (@{int b = (a); b + 3; @})
+@end example
+
+@noindent
+does not work the same way as:
+
+@example
+inline int foo(int a) @{ int b = a; return b + 3; @}
+@end example
+
+@noindent
+In particular, if the expression passed into @code{foo} involves the
+creation of temporaries, the destructors for those temporaries will be
+run earlier in the case of the macro than in the case of the function.
+
+These considerations mean that it is probably a bad idea to use
+statement-expressions of this form in header files that are designed to
+work with C++.  (Note that some versions of the GNU C Library contained
+header files using statement-expression that lead to precisely this
+bug.)
+
 @node Local Labels
 @section Locally Declared Labels
 @cindex local labels
@@ -292,11 +340,23 @@ Another use of label values is in an interpreter for threaded code.
 The labels within the interpreter function can be stored in the
 threaded code for super-fast dispatching.
 
-You can use this mechanism to jump to code in a different function.  If
-you do that, totally unpredictable things will happen.  The best way to
+You may not use this mechanism to jump to code in a different function.
+If you do that, totally unpredictable things will happen.  The best way to
 avoid this is to store the label address only in automatic variables and
 never pass it as an argument.
 
+An alternate way to write the above example is
+
+@example
+static const int array[] = @{ &&foo - &&foo, &&bar - &&foo, &&hack - &&foo @};
+goto *(&&foo + array[i]);
+@end example
+
+@noindent
+This is more friendly to code living in shared libraries, as it reduces
+the number of dynamic relocations that are needed, and by consequence,
+allows the data to be read-only.
+
 @node Nested Functions
 @section Nested Functions
 @cindex nested functions
@@ -369,7 +429,7 @@ safe.
 
 GNU CC implements taking the address of a nested function using a
 technique called @dfn{trampolines}.   A paper describing them is
-available as @samp{http://master.debian.org/~karlheg/Usenix88-lexic.pdf}.
+available as @uref{http://people.debian.org/~karlheg/Usenix88-lexic.pdf}.
 
 A nested function can jump to a label inherited from a containing
 function, provided the label was explicitly declared in the containing
@@ -531,8 +591,8 @@ typeof (x[0](1))
 @end example
 
 @noindent
-This assumes that @code{x} is an array of functions; the type described
-is that of the values of the functions.
+This assumes that @code{x} is an array of pointers to functions;
+the type described is that of the values of the functions.
 
 Here is an example with a typename as the argument:
 
@@ -543,7 +603,7 @@ typeof (int *)
 @noindent
 Here the type described is that of pointers to @code{int}.
 
-If you are writing a header file that must work when included in ANSI C
+If you are writing a header file that must work when included in ISO C
 programs, write @code{__typeof__} instead of @code{typeof}.
 @xref{Alternate Keywords}.
 
@@ -794,12 +854,15 @@ A future version of GDB will know how to recognize such pairs and treat
 them as a single variable with a complex type.
 
 @node Hex Floats
+@section Hex Floats
+@cindex hex floats
+
 GNU CC recognizes floating-point numbers written not only in the usual
 decimal notation, such as @code{1.55e1}, but also numbers such as
 @code{0x1.fp3} written in hexadecimal format.  In that format the
 @code{0x} hex introducer and the @code{p} or @code{P} exponent field are
 mandatory.  The exponent is a decimal number that indicates the power of
-2 by which the significand part will be multiplied.  Thus @code{0x1.f} is
+2 by which the significant part will be multiplied.  Thus @code{0x1.f} is
 1 15/16, @code{p3} multiplies it by 8, and the value of @code{0x1.fp3}
 is the same as @code{1.55e1}.
 
@@ -814,9 +877,10 @@ extension for floating-point constants of type @code{float}.
 @cindex arrays of length zero
 @cindex zero-length arrays
 @cindex length-zero arrays
+@cindex flexible array members
 
-Zero-length arrays are allowed in GNU C.  They are very useful as the last
-element of a structure which is really a header for a variable-length
+Zero-length arrays are allowed in GNU C.  They are very useful as the
+last element of a structure which is really a header for a variable-length
 object:
 
 @example
@@ -825,16 +889,81 @@ struct line @{
   char contents[0];
 @};
 
-@{
-  struct line *thisline = (struct line *)
-    malloc (sizeof (struct line) + this_length);
-  thisline->length = this_length;
-@}
+struct line *thisline = (struct line *)
+  malloc (sizeof (struct line) + this_length);
+thisline->length = this_length;
 @end example
 
-In standard C, you would have to give @code{contents} a length of 1, which
+In ISO C89, you would have to give @code{contents} a length of 1, which
 means either you waste space or complicate the argument to @code{malloc}.
 
+In ISO C99, you would use a @dfn{flexible array member}, which is
+slightly different in syntax and semantics:
+
+@itemize @bullet
+@item
+Flexible array members are written as @code{contents[]} without
+the @code{0}.
+
+@item
+Flexible array members have incomplete type, and so the @code{sizeof}
+operator may not be applied.  As a quirk of the original implementation
+of zero-length arrays, @code{sizeof} evaluates to zero.
+
+@item
+Flexible array members may only appear as the last member of a
+@code{struct} that is otherwise non-empty.  GCC currently allows
+zero-length arrays anywhere.  You may encounter problems, however,
+defining structures containing only a zero-length array.  Such usage
+is deprecated, and we recommend using zero-length arrays only in
+places in which flexible array members would be allowed.
+@end itemize
+
+GCC versions before 3.0 allowed zero-length arrays to be statically
+initialized.  In addition to those cases that were useful, it also
+allowed initializations in situations that would corrupt later data.
+Non-empty initialization of zero-length arrays is now deprecated.
+
+Instead GCC allows static initialization of flexible array members.
+This is equivalent to defining a new structure containing the original
+structure followed by an array of sufficient size to contain the data.
+I.e. in the following, @code{f1} is constructed as if it were declared
+like @code{f2}.
+
+@example
+struct f1 @{
+  int x; int y[];
+@} f1 = @{ 1, @{ 2, 3, 4 @} @};
+
+struct f2 @{
+  struct f1 f1; int data[3];
+@} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
+@end example
+
+@noindent
+The convenience of this extension is that @code{f1} has the desired
+type, eliminating the need to consistently refer to @code{f2.f1}.
+
+This has symmetry with normal static arrays, in that an array of
+unknown size is also written with @code{[]}.
+
+Of course, this extension only makes sense if the extra data comes at
+the end of a top-level object, as otherwise we would be overwriting
+data at subsequent offsets.  To avoid undue complication and confusion
+with initialization of deeply nested arrays, we simply disallow any
+non-empty initialization except when the structure is the top-level
+object.  For example:
+
+@example
+struct foo @{ int x; int y[]; @};
+struct bar @{ struct foo z; @};
+
+struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // Legal.
+struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // Illegal.
+struct bar c = @{ @{ 1, @{ @} @} @};            // Legal.
+struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // Illegal.
+@end example
+
 @node Variable Length
 @section Arrays of Variable Length
 @cindex variable-length arrays
@@ -913,66 +1042,98 @@ last one must end with a semicolon, which is followed by the ``real''
 parameter declarations.  Each forward declaration must match a ``real''
 declaration in parameter name and data type.
 
-@node Macro Varargs
-@section Macros with Variable Numbers of Arguments
+@node Variadic Macros
+@section Macros with a Variable Number of Arguments.
 @cindex variable number of arguments
 @cindex macro with variable arguments
 @cindex rest argument (in macro)
+@cindex variadic macros
 
-In GNU C, a macro can accept a variable number of arguments, much as a
-function can.  The syntax for defining the macro looks much like that
-used for a function.  Here is an example:
+In the ISO C standard of 1999, a macro can be declared to accept a
+variable number of arguments much as a function can.  The syntax for
+defining the macro is similar to that of a function.  Here is an
+example:
 
 @example
-#define eprintf(format, args...)  \
- fprintf (stderr, format , ## args)
+#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
 @end example
 
-Here @code{args} is a @dfn{rest argument}: it takes in zero or more
-arguments, as many as the call contains.  All of them plus the commas
-between them form the value of @code{args}, which is substituted into
-the macro body where @code{args} is used.  Thus, we have this expansion:
+Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
+such a macro, it represents the zero or more tokens until the closing
+parenthesis that ends the invocation, including any commas.  This set of
+tokens replaces the identifier @code{__VA_ARGS__} in the macro body
+wherever it appears.  See the CPP manual for more information.
+
+GCC has long supported variadic macros, and used a different syntax that
+allowed you to give a name to the variable arguments just like any other
+argument.  Here is an example:
 
 @example
-eprintf ("%s:%d: ", input_file_name, line_number)
-@expansion{}
-fprintf (stderr, "%s:%d: " , input_file_name, line_number)
+#define debug(format, args...) fprintf (stderr, format, args)
 @end example
 
-@noindent
-Note that the comma after the string constant comes from the definition
-of @code{eprintf}, whereas the last comma comes from the value of
-@code{args}.
+This is in all ways equivalent to the ISO C example above, but arguably
+more readable and descriptive.
+
+GNU CPP has two further variadic macro extensions, and permits them to
+be used with either of the above forms of macro definition.
 
-The reason for using @samp{##} is to handle the case when @code{args}
-matches no arguments at all.  In this case, @code{args} has an empty
-value.  In this case, the second comma in the definition becomes an
-embarrassment: if it got through to the expansion of the macro, we would
-get something like this:
+In standard C, you are not allowed to leave the variable argument out
+entirely; but you are allowed to pass an empty argument.  For example,
+this invocation is invalid in ISO C, because there is no comma after
+the string:
 
 @example
-fprintf (stderr, "success!\n" , )
+debug ("A message")
 @end example
 
-@noindent
-which is invalid C syntax.  @samp{##} gets rid of the comma, so we get
-the following instead:
+GNU CPP permits you to completely omit the variable arguments in this
+way.  In the above examples, the compiler would complain, though since
+the expansion of the macro still has the extra comma after the format
+string.
+
+To help solve this problem, CPP behaves specially for variable arguments
+used with the token paste operator, @samp{##}.  If instead you write
 
 @example
-fprintf (stderr, "success!\n")
+#define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
 @end example
 
-This is a special feature of the GNU C preprocessor: @samp{##} before a
-rest argument that is empty discards the preceding sequence of
-non-whitespace characters from the macro definition.  (If another macro
-argument precedes, none of it is discarded.)
-
-It might be better to discard the last preprocessor token instead of the
-last preceding sequence of non-whitespace characters; in fact, we may
-someday change this feature to do so.  We advise you to write the macro
-definition so that the preceding sequence of non-whitespace characters
-is just a single token, so that the meaning will not change if we change
-the definition of this feature.
+and if the variable arguments are omitted or empty, the @samp{##}
+operator causes the preprocessor to remove the comma before it.  If you
+do provide some variable arguments in your macro invocation, GNU CPP
+does not complain about the paste operation and instead places the
+variable arguments after the comma.  Just like any other pasted macro
+argument, these arguments are not macro expanded.
+
+@node Escaped Newlines
+@section Slightly Looser Rules for Escaped Newlines
+@cindex escaped newlines
+@cindex newlines (escaped)
+
+Recently, the non-traditional preprocessor has relaxed its treatment of
+escaped newlines.  Previously, the newline had to immediately follow a
+backslash.  The current implementation allows whitespace in the form of
+spaces, horizontal and vertical tabs, and form feeds between the
+backslash and the subsequent newline.  The preprocessor issues a
+warning, but treats it as a valid escaped newline and combines the two
+lines to form a single logical line.  This works within comments and
+tokens, including multi-line strings, as well as between tokens.
+Comments are @emph{not} treated as whitespace for the purposes of this
+relaxation, since they have not yet been replaced with spaces.
+
+@node Multi-line Strings
+@section String Literals with Embedded Newlines
+@cindex multi-line string literals
+
+As an extension, GNU CPP permits string literals to cross multiple lines
+without escaping the embedded newlines.  Each embedded newline is
+replaced with a single @samp{\n} character in the resulting string
+literal, regardless of what form the newline took originally.
+
+CPP currently allows such strings in directives as well (other than the
+@samp{#include} family).  This is deprecated and will eventually be
+removed.
 
 @node Subscripting
 @section Non-Lvalue Arrays May Have Subscripts
@@ -1098,19 +1259,20 @@ to a cast.
 @cindex labeled elements in initializers
 @cindex case labels in initializers
 
-Standard C requires the elements of an initializer to appear in a fixed
+Standard C89 requires the elements of an initializer to appear in a fixed
 order, the same as the order of the elements in the array or structure
 being initialized.
 
-In GNU C you can give the elements in any order, specifying the array
-indices or structure field names they apply to.  This extension is not
+In ISO C99 you can give the elements in any order, specifying the array
+indices or structure field names they apply to, and GNU C allows this as
+an extension in C89 mode as well.  This extension is not
 implemented in GNU C++.
 
-To specify an array index, write @samp{[@var{index}]} or
+To specify an array index, write
 @samp{[@var{index}] =} before the element value.  For example,
 
 @example
-int a[6] = @{ [4] 29, [2] = 15 @};
+int a[6] = @{ [4] 29, [2] = 15 @};
 @end example
 
 @noindent
@@ -1124,19 +1286,28 @@ int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
 The index values must be constant expressions, even if the array being
 initialized is automatic.
 
+An alternative syntax for this which has been obsolete since GCC 2.5 but
+GCC still accepts is to write @samp{[@var{index}]} before the element
+value, with no @samp{=}.
+
 To initialize a range of elements to the same value, write
-@samp{[@var{first} ... @var{last}] = @var{value}}.  For example,
+@samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
+extension.  For example,
 
 @example
 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
 @end example
 
 @noindent
+If the value in it has side-effects, the side-effects will happen only once,
+not for each initialized field by the range initializer.
+
+@noindent
 Note that the length of the array is the highest value specified
 plus one.
 
 In a structure initializer, specify the name of a field to initialize
-with @samp{@var{fieldname}:} before the element value.  For example,
+with @samp{.@var{fieldname} =} before the element value.  For example,
 given the following structure,
 
 @example
@@ -1147,7 +1318,7 @@ struct point @{ int x, y; @};
 the following initialization
 
 @example
-struct point p = @{ y: yvalue, x: xvalue @};
+struct point p = @{ .y = yvalue, .x = xvalue @};
 @end example
 
 @noindent
@@ -1157,11 +1328,11 @@ is equivalent to
 struct point p = @{ xvalue, yvalue @};
 @end example
 
-Another syntax which has the same meaning is @samp{.@var{fieldname} =}.,
-as shown here:
+Another syntax which has the same meaning, obsolete since GCC 2.5, is
+@samp{@var{fieldname}:}, as shown here:
 
 @example
-struct point p = @{ .y = yvalue, .x = xvalue @};
+struct point p = @{ y: yvalue, x: xvalue @};
 @end example
 
 You can also use an element label (with either the colon syntax or the
@@ -1171,7 +1342,7 @@ of the union should be used.  For example,
 @example
 union foo @{ int i; double d; @};
 
-union foo f = @{ d: 4 @};
+union foo f = @{ .d = 4 @};
 @end example
 
 @noindent
@@ -1206,6 +1377,22 @@ int whitespace[256]
       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
 @end example
 
+You can also write a series of @samp{.@var{fieldname}} and
+@samp{[@var{index}]} element labels before an @samp{=} to specify a
+nested subobject to initialize; the list is taken relative to the
+subobject corresponding to the closest surrounding brace pair.  For
+example, with the @samp{struct point} declaration above:
+
+@example
+struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
+@end example
+
+@noindent
+If the same field is initialized multiple times, it will have value from
+the last initialization.  If any such overridden initialization has
+side-effect, it is unspecified whether the side-effect happens or not.
+Currently, gcc will discard them and issue a warning.
+
 @node Case Ranges
 @section Case Ranges
 @cindex case ranges
@@ -1291,9 +1478,10 @@ hack ((union foo) x);
 @cindex functions that never return
 @cindex functions that have no side effects
 @cindex functions in arbitrary sections
+@cindex functions that behave like malloc
 @cindex @code{volatile} applied to function
 @cindex @code{const} applied to function
-@cindex functions with @code{printf}, @code{scanf} or @code{strftime} style arguments
+@cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
 @cindex functions that are passed arguments in registers on the 386
 @cindex functions that pop the argument stack on the 386
 @cindex functions that do not pop the argument stack on the 386
@@ -1304,11 +1492,13 @@ carefully.
 
 The keyword @code{__attribute__} allows you to specify special
 attributes when making a declaration.  This keyword is followed by an
-attribute specification inside double parentheses.  Nine attributes,
-@code{noreturn}, @code{const}, @code{format},
-@code{no_instrument_function}, @code{section},
-@code{constructor}, @code{destructor}, @code{unused} and @code{weak} are
-currently defined for functions.  Other attributes, including
+attribute specification inside double parentheses.  Fourteen attributes,
+@code{noreturn}, @code{pure}, @code{const}, @code{format},
+@code{format_arg}, @code{no_instrument_function}, @code{section},
+@code{constructor}, @code{destructor}, @code{unused}, @code{weak},
+@code{malloc}, @code{alias} and @code{no_check_memory_usage} are
+currently defined for functions.  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}).
 
@@ -1317,6 +1507,9 @@ each keyword.  This allows you to use them in header files without
 being concerned about a possible macro of the same name.  For example,
 you may use @code{__noreturn__} instead of @code{noreturn}.
 
+@xref{Attribute Syntax}, for details of the exact syntax for using
+attributes.
+
 @table @code
 @cindex @code{noreturn} function attribute
 @item noreturn
@@ -1359,22 +1552,44 @@ typedef void voidfn ();
 volatile voidfn fatal;
 @end smallexample
 
-@cindex @code{const} function attribute
-@item const
-Many functions do not examine any values except their arguments, and
-have no effects except the return value.  Such a function can be subject
+@cindex @code{pure} function attribute
+@item pure
+Many functions have no effects except the return value and their
+return value depends only on the parameters and/or global variables.
+Such a function can be subject
 to common subexpression elimination and loop optimization just as an
 arithmetic operator would be.  These functions should be declared
-with the attribute @code{const}.  For example,
+with the attribute @code{pure}.  For example,
 
 @smallexample
-int square (int) __attribute__ ((const));
+int square (int) __attribute__ ((pure));
 @end smallexample
 
 @noindent
 says that the hypothetical function @code{square} is safe to call
 fewer times than the program says.
 
+Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
+Interesting non-pure functions are functions with infinite loops or those
+depending on volatile memory or other system resource, that may change between
+two consecutive calls (such as @code{feof} in a multithreading environment).
+
+The attribute @code{pure} is not implemented in GNU C versions earlier
+than 2.96.
+@cindex @code{const} function attribute
+@item const
+Many functions do not examine any values except their arguments, and
+have no effects except the return value.  Basically this is just slightly
+more strict class than the "pure" attribute above, since function is not
+allowed to read global memory.
+
+@cindex pointer arguments
+Note that a function that has pointer arguments and examines the data
+pointed to must @emph{not} be declared @code{const}.  Likewise, a
+function that calls a non-@code{const} function usually must not be
+@code{const}.  It does not make sense for a @code{const} function to
+return @code{void}.
+
 The attribute @code{const} is not implemented in GNU C versions earlier
 than 2.5.  An alternative way to declare that a function has no side
 effects, which works in the current version and in some older versions,
@@ -1389,18 +1604,13 @@ extern const intfn square;
 This approach does not work in GNU C++ from 2.6.0 on, since the language
 specifies that the @samp{const} must be attached to the return value.
 
-@cindex pointer arguments
-Note that a function that has pointer arguments and examines the data
-pointed to must @emph{not} be declared @code{const}.  Likewise, a
-function that calls a non-@code{const} function usually must not be
-@code{const}.  It does not make sense for a @code{const} function to
-return @code{void}.
 
 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
 @cindex @code{format} function attribute
 The @code{format} attribute specifies that a function takes @code{printf},
-@code{scanf}, or @code{strftime} style arguments which should be type-checked
-against a format string.  For example, the declaration:
+@code{scanf}, @code{strftime} or @code{strfmon} style arguments which
+should be type-checked against a format string.  For example, the
+declaration:
 
 @smallexample
 extern int
@@ -1414,14 +1624,16 @@ for consistency with the @code{printf} style format string argument
 @code{my_format}.
 
 The parameter @var{archetype} determines how the format string is
-interpreted, and should be either @code{printf}, @code{scanf}, or
-@code{strftime}.  The
+interpreted, and should be @code{printf}, @code{scanf}, @code{strftime}
+or @code{strfmon}.  (You can also use @code{__printf__},
+@code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  The
 parameter @var{string-index} specifies which argument is the format
 string argument (starting from 1), while @var{first-to-check} is the
 number of the first argument to check against the format string.  For
 functions where the arguments are not available to be checked (such as
 @code{vprintf}), specify the third parameter as zero.  In this case the
-compiler only checks the format string for consistency.
+compiler only checks the format string for consistency.  For
+@code{strftime} formats, the third parameter is required to be zero.
 
 In the example above, the format string (@code{my_format}) is the second
 argument of the function @code{my_print}, and the arguments to check
@@ -1430,19 +1642,28 @@ attribute are 2 and 3.
 
 The @code{format} attribute allows you to identify your own functions
 which take format strings as arguments, so that GNU CC can check the
-calls to these functions for errors.  The compiler always checks formats
-for the ANSI library functions @code{printf}, @code{fprintf},
+calls to these functions for errors.  The compiler always (unless
+@samp{-ffreestanding} is used) checks formats
+for the standard library functions @code{printf}, @code{fprintf},
 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
 warnings are requested (using @samp{-Wformat}), so there is no need to
-modify the header file @file{stdio.h}.
+modify the header file @file{stdio.h}.  In C99 mode, the functions
+@code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
+@code{vsscanf} are also checked.  Except in strictly conforming C
+standard modes, the X/Open function @code{strfmon} is also checked.
+@xref{C Dialect Options,,Options Controlling C Dialect}.
 
 @item format_arg (@var{string-index})
 @cindex @code{format_arg} function attribute
-The @code{format_arg} attribute specifies that a function takes
-@code{printf} or @code{scanf} style arguments, modifies it (for example,
-to translate it into another language), and passes it to a @code{printf}
-or @code{scanf} style function.  For example, the declaration:
+The @code{format_arg} attribute specifies that a function takes a format
+string for a @code{printf}, @code{scanf}, @code{strftime} or
+@code{strfmon} style function and modifies it (for example, to translate
+it into another language), so the result can be passed to a
+@code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
+function (with the remaining arguments to the format function the same
+as they would have been for the unmodified string).  For example, the
+declaration:
 
 @smallexample
 extern char *
@@ -1451,20 +1672,28 @@ my_dgettext (char *my_domain, const char *my_format)
 @end smallexample
 
 @noindent
-causes the compiler to check the arguments in calls to
-@code{my_dgettext} whose result is passed to a @code{printf},
-@code{scanf}, or @code{strftime} type function for consistency with the
-@code{printf} style format string argument @code{my_format}.
+causes the compiler to check the arguments in calls to a @code{printf},
+@code{scanf}, @code{strftime} or @code{strfmon} type function, whose
+format string argument is a call to the @code{my_dgettext} function, for
+consistency with the format string argument @code{my_format}.  If the
+@code{format_arg} attribute had not been specified, all the compiler
+could tell in such calls to format functions would be that the format
+string argument is not constant; this would generate a warning when
+@code{-Wformat-nonliteral} is used, but the calls could not be checked
+without the attribute.
 
 The parameter @var{string-index} specifies which argument is the format
 string argument (starting from 1).
 
 The @code{format-arg} attribute allows you to identify your own
 functions which modify format strings, so that GNU CC can check the
-calls to @code{printf}, @code{scanf}, or @code{strftime} function whose
-operands are a call to one of your own function.  The compiler always
-treats @code{gettext}, @code{dgettext}, and @code{dcgettext} in this
-manner.
+calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
+type function whose operands are a call to one of your own function.
+The compiler always treats @code{gettext}, @code{dgettext}, and
+@code{dcgettext} in this manner except when strict ISO C support is
+requested by @samp{-ansi} or an appropriate @samp{-std} option, or
+@samp{-ffreestanding} is used.  @xref{C Dialect Options,,Options
+Controlling C Dialect}.
 
 @item no_instrument_function
 @cindex @code{no_instrument_function} function attribute
@@ -1521,6 +1750,13 @@ also be used with non-function declarations.  Weak symbols are supported
 for ELF targets, and also for a.out targets when using the GNU assembler
 and linker.
 
+@item malloc
+@cindex @code{malloc} attribute
+The @code{malloc} attribute is used to tell the compiler that a function
+may be treated as if it were the malloc function.  The compiler assumes
+that calls to malloc result in a pointers that cannot alias anything.
+This will often improve optimization.
+
 @item alias ("target")
 @cindex @code{alias} attribute
 The @code{alias} attribute causes the declaration to be emitted as an
@@ -1538,16 +1774,19 @@ Not all target machines support this attribute.
 
 @item no_check_memory_usage
 @cindex @code{no_check_memory_usage} function attribute
-If @samp{-fcheck-memory-usage} is given, calls to support routines will
-be generated before most memory accesses, to permit support code to
-record usage and detect uses of uninitialized or unallocated storage.
-Since the compiler cannot handle them properly, @code{asm} statements
-are not allowed.  Declaring a function with this attribute disables the
+The @code{no_check_memory_usage} attribute causes GNU CC to omit checks
+of memory references when it generates code for that function.  Normally
+if you specify @samp{-fcheck-memory-usage} (see @pxref{Code Gen
+Options}), GNU CC generates calls to support routines before most memory
+accesses to permit support code to record usage and detect uses of
+uninitialized or unallocated storage.  Since GNU CC cannot handle
+@code{asm} statements properly they are not allowed in such functions.
+If you declare a function with this attribute, GNU CC will not generate
 memory checking code for that function, permitting the use of @code{asm}
-statements without requiring separate compilation with different
-options, and allowing you to write support routines of your own if you
-wish, without getting infinite recursion if they get compiled with this
-option.
+statements without having to compile that function with different
+options.  This also allows you to write support routines of your own if
+you wish, without getting infinite recursion if they get compiled with
+@code{-fcheck-memory-usage}.
 
 @item regparm (@var{number})
 @cindex functions that are passed arguments in registers on the 386
@@ -1583,6 +1822,17 @@ compiler to always call the function via a pointer, so that functions
 which reside further than 64 megabytes (67,108,864 bytes) from the
 current location can be called.
 
+@item long_call/short_call
+@cindex indirect calls on ARM
+This attribute allows to specify how to call a particular function on
+ARM.  Both attributes override the @code{-mlong-calls} (@pxref{ARM Options})
+command line switch and @code{#pragma long_calls} settings.  The
+@code{long_call} attribute causes the compiler to always call the
+function by first loading its address into a register and then using the
+contents of that register.   The @code{short_call} attribute always places
+the offset to the function from the call site into the @samp{BL}
+instruction directly.
+
 @item dllimport
 @cindex functions which are imported from a dll on PowerPC Windows NT
 On the PowerPC running Windows NT, the @code{dllimport} attribute causes
@@ -1626,6 +1876,27 @@ 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.
 
+@item interrupt
+@cindex interrupt handler functions
+Use this option on the ARM, AVR and M32R/D ports 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.
+
+Note, interrupt handlers for the H8/300 and H8/300H processors can be
+specified via the @code{interrupt_handler} attribute.
+
+Note, on the AVR interrupts will be enabled inside the function.
+
+Note, for the ARM you can specify the kind of interrupt to be handled by
+adding an optional parameter to the interrupt attribute like this:
+
+@smallexample
+void f () __attribute__ ((interrupt ("IRQ")));
+@end smallexample
+
+Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF.
+
 @item eightbit_data
 @cindex eight bit data on the H8/300 and H8/300H
 Use this option on the H8/300 and H8/300H to indicate that the specified
@@ -1645,12 +1916,18 @@ 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 interrupt
-@cindex interrupt handlers on the M32R/D
-Use this option on the M32R/D 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.
+@item signal
+@cindex signal handler functions on the AVR processors
+Use this option on the AVR to indicate that the specified
+function is an signal handler.  The compiler will generate function
+entry and exit sequences suitable for use in an signal handler when this
+attribute is present. Interrupts will be disabled inside function.
+
+@item naked
+@cindex function without a prologue/epilogue code
+Use this option on the ARM or AVR ports to indicate that the specified
+function do not need prologue/epilogue sequences generated by the
+compiler.  It is up to the programmer to provide these sequences.
 
 @item model (@var{model-name})
 @cindex function addressability on the M32R/D
@@ -1663,11 +1940,11 @@ Small model objects live in the lower 16MB of memory (so that their
 addresses can be loaded with the @code{ld24} instruction), and are
 callable with the @code{bl} instruction.
 
-Medium model objects may live anywhere in the 32 bit address space (the
+Medium model objects may live anywhere in the 32-bit address space (the
 compiler will generate @code{seth/add3} instructions to load their addresses),
 and are callable with the @code{bl} instruction.
 
-Large model objects may live anywhere in the 32 bit address space (the
+Large model objects may live anywhere in the 32-bit address space (the
 compiler will generate @code{seth/add3} instructions to load their addresses),
 and may not be reachable with the @code{bl} instruction (the compiler will
 generate the much slower @code{seth/add3/jl} instruction sequence).
@@ -1680,9 +1957,10 @@ attribute declaration with another attribute declaration.
 
 @cindex @code{#pragma}, reason for not using
 @cindex pragma, reason for not using
-Some people object to the @code{__attribute__} feature, suggesting that ANSI C's
-@code{#pragma} should be used instead.  There are two reasons for not
-doing this.
+Some people object to the @code{__attribute__} feature, suggesting that
+ISO C's @code{#pragma} should be used instead.  At the time
+@code{__attribute__} was designed, there were two reasons for not doing
+this.
 
 @enumerate
 @item
@@ -1693,9 +1971,193 @@ There is no telling what the same @code{#pragma} might mean in another
 compiler.
 @end enumerate
 
-These two reasons apply to almost any application that might be proposed
-for @code{#pragma}.  It is basically a mistake to use @code{#pragma} for
-@emph{anything}.
+These two reasons applied to almost any application that might have been
+proposed for @code{#pragma}.  It was basically a mistake to use
+@code{#pragma} for @emph{anything}.
+
+The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
+to be generated from macros.  In addition, a @code{#pragma GCC}
+namespace is now in use for GCC-specific pragmas.  However, it has been
+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}.
+
+@node Attribute Syntax
+@section Attribute Syntax
+@cindex attribute syntax
+
+This section describes the syntax with which @code{__attribute__} may be
+used, and the constructs to which attribute specifiers bind, for the C
+language.  Some details may vary for C++ and Objective C.  Because of
+infelicities in the grammar for attributes, some forms described here
+may not be successfully parsed in all cases.
+
+@xref{Function Attributes}, for details of the semantics of attributes
+applying to functions.  @xref{Variable Attributes}, for details of the
+semantics of attributes applying to variables.  @xref{Type Attributes},
+for details of the semantics of attributes applying to structure, union
+and enumerated types.
+
+An @dfn{attribute specifier} is of the form
+@code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
+is a possibly empty comma-separated sequence of @dfn{attributes}, where
+each attribute is one of the following:
+
+@itemize @bullet
+@item
+Empty.  Empty attributes are ignored.
+
+@item
+A word (which may be an identifier such as @code{unused}, or a reserved
+word such as @code{const}).
+
+@item
+A word, followed by, in parentheses, parameters for the attribute.
+These parameters take one of the following forms:
+
+@itemize @bullet
+@item
+An identifier.  For example, @code{mode} attributes use this form.
+
+@item
+An identifier followed by a comma and a non-empty comma-separated list
+of expressions.  For example, @code{format} attributes use this form.
+
+@item
+A possibly empty comma-separated list of expressions.  For example,
+@code{format_arg} attributes use this form with the list being a single
+integer constant expression, and @code{alias} attributes use this form
+with the list being a single string constant.
+@end itemize
+@end itemize
+
+An @dfn{attribute specifier list} is a sequence of one or more attribute
+specifiers, not separated by any other tokens.
+
+An attribute specifier list may appear after the colon following a
+label, other than a @code{case} or @code{default} label.  The only
+attribute it makes sense to use after a label is @code{unused}.  This
+feature is intended for code generated by programs which contains labels
+that may be unused but which is compiled with @option{-Wall}.  It would
+not normally be appropriate to use in it human-written code, though it
+could be useful in cases where the code that jumps to the label is
+contained within an @code{#ifdef} conditional.
+
+An attribute specifier list may appear as part of a @code{struct},
+@code{union} or @code{enum} specifier.  It may go either immediately
+after the @code{struct}, @code{union} or @code{enum} keyword, or after
+the closing brace.  It is ignored if the content of the structure, union
+or enumerated type is not defined in the specifier in which the
+attribute specifier list is used---that is, in usages such as
+@code{struct __attribute__((foo)) bar} with no following opening brace.
+Where attribute specifiers follow the closing brace, they are considered
+to relate to the structure, union or enumerated type defined, not to any
+enclosing declaration the type specifier appears in, and the type
+defined is not complete until after the attribute specifiers.
+@c Otherwise, there would be the following problems: a shift/reduce
+@c conflict between attributes binding the the struct/union/enum and
+@c binding to the list of specifiers/qualifiers; and "aligned"
+@c attributes could use sizeof for the structure, but the size could be
+@c changed later by "packed" attributes.
+
+Otherwise, an attribute specifier appears as part of a declaration,
+counting declarations of unnamed parameters and type names, and relates
+to that declaration (which may be nested in another declaration, for
+example in the case of a parameter declaration).  In future, attribute
+specifiers in some places may however apply to a particular declarator
+within a declaration instead; these cases are noted below.
+
+Any list of specifiers and qualifiers at the start of a declaration may
+contain attribute specifiers, whether or not such a list may in that
+context contain storage class specifiers.  (Some attributes, however,
+are essentially in the nature of storage class specifiers, and only make
+sense where storage class specifiers may be used; for example,
+@code{section}.)  There is one necessary limitation to this syntax: the
+first old-style parameter declaration in a function definition cannot
+begin with an attribute specifier, because such an attribute applies to
+the function instead by syntax described below (which, however, is not
+yet implemented in this case).  In some other cases, attribute
+specifiers are permitted by this grammar but not yet supported by the
+compiler.  All attribute specifiers in this place relate to the
+declaration as a whole.  In the obsolencent usage where a type of
+@code{int} is implied by the absence of type specifiers, such a list of
+specifiers and qualifiers may be an attribute specifier list with no
+other specifiers or qualifiers.
+
+An attribute specifier list may appear immediately before a declarator
+(other than the first) in a comma-separated list of declarators in a
+declaration of more than one identifier using a single list of
+specifiers and qualifiers.  At present, such attribute specifiers apply
+not only to the identifier before whose declarator they appear, but to
+all subsequent identifiers declared in that declaration, but in future
+they may apply only to that single identifier.  For example, in
+@code{__attribute__((noreturn)) void d0 (void),
+__attribute__((format(printf, 1, 2))) d1 (const char *, ...), d2
+(void)}, the @code{noreturn} attribute applies to all the functions
+declared; the @code{format} attribute should only apply to @code{d1},
+but at present applies to @code{d2} as well (and so causes an error).
+
+An attribute specifier list may appear immediately before the comma,
+@code{=} or semicolon terminating the declaration of an identifier other
+than a function definition.  At present, such attribute specifiers apply
+to the declared object or function, but in future they may attach to the
+outermost adjacent declarator.  In simple cases there is no difference,
+but, for example, in @code{void (****f)(void)
+__attribute__((noreturn));}, at present the @code{noreturn} attribute
+applies to @code{f}, which causes a warning since @code{f} is not a
+function, but in future it may apply to the function @code{****f}.  The
+precise semantics of what attributes in such cases will apply to are not
+yet specified.  Where an assembler name for an object or function is
+specified (@pxref{Asm Labels}), at present the attribute must follow the
+@code{asm} specification; in future, attributes before the @code{asm}
+specification may apply to the adjacent declarator, and those after it
+to the declared object or function.
+
+An attribute specifier list may, in future, be permitted to appear after
+the declarator in a function definition (before any old-style parameter
+declarations or the function body).
+
+An attribute specifier list may appear at the start of a nested
+declarator.  At present, there are some limitations in this usage: the
+attributes apply to the identifer declared, and to all subsequent
+identifiers declared in that declaration (if it includes a
+comma-separated list of declarators), rather than to a specific
+declarator.  When attribute specifiers follow the @code{*} of a pointer
+declarator, they must presently follow any type qualifiers present, and
+cannot be mixed with them.  The following describes intended future
+semantics which make this syntax more useful only.  It will make the
+most sense if you are familiar with the formal specification of
+declarators in the ISO C standard.
+
+Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
+D1}, where @code{T} contains declaration specifiers that specify a type
+@var{Type} (such as @code{int}) and @code{D1} is a declarator that
+contains an identifier @var{ident}.  The type specified for @var{ident}
+for derived declarators whose type does not include an attribute
+specifier is as in the ISO C standard.
+
+If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
+and the declaration @code{T D} specifies the type
+``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
+@code{T D1} specifies the type ``@var{derived-declarator-type-list}
+@var{attribute-specifier-list} @var{Type}'' for @var{ident}.
+
+If @code{D1} has the form @code{*
+@var{type-qualifier-and-attribute-specifier-list} D}, and the
+declaration @code{T D} specifies the type
+``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
+@code{T D1} specifies the type ``@var{derived-declarator-type-list}
+@var{type-qualifier-and-attribute-specifier-list} @var{Type}'' for
+@var{ident}.
+
+For example, @code{void (__attribute__((noreturn)) ****f)();} specifies
+the type ``pointer to pointer to pointer to pointer to non-returning
+function returning @code{void}''.  As another example, @code{char
+*__attribute__((aligned(8))) *f;} specifies the type ``pointer to
+8-byte-aligned pointer to @code{char}''.  Note again that this describes
+intended future semantics, not current implementation.
 
 @node Function Prototypes
 @section Prototypes and Old-Style Function Definitions
@@ -1703,7 +2165,7 @@ for @code{#pragma}.  It is basically a mistake to use @code{#pragma} for
 @cindex old-style function definitions
 @cindex promotion of formal parameters
 
-GNU C extends ANSI C to allow a function prototype to override a later
+GNU C extends ISO C to allow a function prototype to override a later
 old-style non-prototype definition.  Consider the following example:
 
 @example
@@ -1726,13 +2188,13 @@ isroot (x)   /* ??? lossage here ??? */
 @}
 @end example
 
-Suppose the type @code{uid_t} happens to be @code{short}.  ANSI C does
+Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
 not allow this example, because subword arguments in old-style
 non-prototype definitions are promoted.  Therefore in this example the
 function definition's argument is really an @code{int}, which does not
 match the prototype argument type of @code{short}.
 
-This restriction of ANSI C makes it hard to write code that is portable
+This restriction of ISO C makes it hard to write code that is portable
 to traditional C compilers, because the programmer does not know
 whether the @code{uid_t} type is @code{short}, @code{int}, or
 @code{long}.  Therefore, in cases like these GNU C allows a prototype
@@ -1765,7 +2227,8 @@ In GNU C, you may use C++ style comments, which start with @samp{//} and
 continue until the end of the line.  Many other C implementations allow
 such comments, and they are likely to be in a future C standard.
 However, C++ style comments are not recognized if you specify
-@w{@samp{-ansi}} or @w{@samp{-traditional}}, since they are incompatible
+@w{@samp{-ansi}}, a @option{-std} option specifying a version of ISO C
+before C99, or @w{@samp{-traditional}}, since they are incompatible
 with traditional constructs like @code{dividend//*comment*/divisor}.
 
 @node Dollar Signs
@@ -1819,6 +2282,8 @@ the value of @code{__alignof__ (foo1.y)} is probably 2 or 4, the same as
 @code{__alignof__ (int)}, even though the data type of @code{foo1.y}
 does not itself demand any alignment.@refill
 
+It is an error to ask for the alignment of an incomplete type.
+
 A related feature which lets you specify the alignment of an object is
 @code{__attribute__ ((aligned (@var{alignment})))}; see the following
 section.
@@ -1833,15 +2298,20 @@ attributes of variables or structure fields.  This keyword is followed
 by an attribute specification inside double parentheses.  Eight
 attributes are currently defined for variables: @code{aligned},
 @code{mode}, @code{nocommon}, @code{packed}, @code{section},
-@code{transparent_union}, @code{unused}, and @code{weak}.  Other
+@code{transparent_union}, @code{unused}, and @code{weak}.  Some other
+attributes are defined for variables on particular target systems.  Other
 attributes are available for functions (@pxref{Function Attributes}) and
-for types (@pxref{Type Attributes}).
+for types (@pxref{Type Attributes}).  Other front-ends might define more
+attributes (@pxref{C++ Extensions,,Extensions to the C++ Language}).
 
 You may also specify attributes with @samp{__} preceding and following
 each keyword.  This allows you to use them in header files without
 being concerned about a possible macro of the same name.  For example,
 you may use @code{__aligned__} instead of @code{aligned}.
 
+@xref{Attribute Syntax}, for details of the exact syntax for using
+attributes.
+
 @table @code
 @cindex @code{aligned} attribute
 @item aligned (@var{alignment})
@@ -1993,6 +2463,32 @@ attribute is not available on all platforms.
 If you need to map the entire contents of a module to a particular
 section, consider using the facilities of the linker instead.
 
+@item shared
+@cindex @code{shared} variable attribute
+On Windows NT, in addition to putting variable definitions in a named
+section, the section can also be shared among all running copies of an
+executable or DLL. For example, this small program defines shared data
+by putting it in a named section "shared" and marking the section
+shareable:
+
+@smallexample
+int foo __attribute__((section ("shared"), shared)) = 0;
+
+int
+main()
+@{
+  /* Read and write foo. All running copies see the same value. */
+  return 0;
+@}
+@end smallexample
+
+@noindent
+You may only use the @code{shared} attribute along with @code{section}
+attribute with a fully initialized global definition because of the way
+linkers work.  See @code{section} attribute for more information.
+
+The @code{shared} attribute is only available on Windows NT.
+
 @item transparent_union
 This attribute, attached to a function parameter which is a union, means
 that the corresponding argument may have the type of any union member,
@@ -2018,7 +2514,7 @@ or @code{large}, representing each of the code models.
 Small model objects live in the lower 16MB of memory (so that their
 addresses can be loaded with the @code{ld24} instruction).
 
-Medium and large model objects may live anywhere in the 32 bit address space
+Medium and large model objects may live anywhere in the 32-bit address space
 (the compiler will generate @code{seth/add3} instructions to load their
 addresses).
 
@@ -2036,9 +2532,9 @@ packed))}.
 The keyword @code{__attribute__} allows you to specify special
 attributes of @code{struct} and @code{union} types when you define such
 types.  This keyword is followed by an attribute specification inside
-double parentheses.  Three attributes are currently defined for types:
-@code{aligned}, @code{packed}, and @code{transparent_union}.  Other
-attributes are defined for functions (@pxref{Function Attributes}) and
+double parentheses.  Four attributes are currently defined for types:
+@code{aligned}, @code{packed}, @code{transparent_union}, and @code{unused}.
+Other attributes are defined for functions (@pxref{Function Attributes}) and
 for variables (@pxref{Variable Attributes}).
 
 You may also specify any one of these attributes with @samp{__}
@@ -2056,6 +2552,9 @@ brace of a definition.
 You may also specify attributes between the enum, struct or union
 tag and the name of the type rather than after the closing brace.
 
+@xref{Attribute Syntax}, for details of the exact syntax for using
+attributes.
+
 @table @code
 @cindex @code{aligned} attribute
 @item aligned (@var{alignment})
@@ -2077,7 +2576,7 @@ store) instructions when copying one variable of type @code{struct S} to
 another, thus improving run-time efficiency.
 
 Note that the alignment of any given @code{struct} or @code{union} type
-is required by the ANSI C standard to be at least a perfect multiple of
+is required by the ISO C standard to be at least a perfect multiple of
 the lowest common multiple of the alignments of all of the members of
 the @code{struct} or @code{union} in question.  This means that you @emph{can}
 effectively adjust the alignment of a @code{struct} or @code{union}
@@ -2253,12 +2752,18 @@ inc (int *a)
 @}
 @end example
 
-(If you are writing a header file to be included in ANSI C programs, write
+(If you are writing a header file to be included in ISO C programs, write
 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.)
-
 You can also make all ``simple enough'' functions inline with the option
-@samp{-finline-functions}.  Note that certain usages in a function
-definition can make it unsuitable for inline substitution.
+@samp{-finline-functions}.
+
+Note that certain usages in a function definition can make it unsuitable
+for inline substitution.  Among these usages are: use of varargs, use of
+alloca, use of variable sized data types (@pxref{Variable Length}),
+use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
+and nested functions (@pxref{Nested Functions}).  Using @samp{-Winline}
+will warn when a function marked @code{inline} could not be substituted,
+and will give the reason for the failure.
 
 Note that in C and Objective C, unlike C++, the @code{inline} keyword
 does not affect the linkage of the function.
@@ -2422,13 +2927,15 @@ asm volatile ("movc3 %0,%1,%2"
               : "r0", "r1", "r2", "r3", "r4", "r5");
 @end example
 
-It is an error for a clobber description to overlap an input or output
-operand (for example, an operand describing a register class with one
-member, mentioned in the clobber list).  Most notably, it is invalid to
-describe that an input operand is modified, but unused as output.  It has
-to be specified as an input and output operand anyway.  Note that if there
-are only unused output operands, you will then also need to specify
-@code{volatile} for the @code{asm} construct, as described below.
+You may not write a clobber description in a way that overlaps with an
+input or output operand.  For example, you may not have an operand
+describing a register class with one member if you mention that register
+in the clobber list.  There is no way for you to specify that an input
+operand is modified without also specifying it as an output
+operand.  Note that if all the output operands you specify are for this
+purpose (and hence unused), you will then also need to specify
+@code{volatile} for the @code{asm} construct, as described below, to
+prevent GNU CC from deleting the @code{asm} statement as unused.
 
 If you refer to a particular hardware register from the assembler code,
 you will probably have to list the register after the third colon to
@@ -2446,20 +2953,26 @@ effect.  But it is valid no matter what the machine.
 If your assembler instruction modifies memory in an unpredictable
 fashion, add @samp{memory} to the list of clobbered registers.  This
 will cause GNU CC to not keep memory values cached in registers across
-the assembler instruction.
+the assembler instruction.  You will also want to add the
+@code{volatile} keyword if the memory affected is not listed in the
+inputs or outputs of the @code{asm}, as the @samp{memory} clobber does
+not count as a side-effect of the @code{asm}.
 
 You can put multiple assembler instructions together in a single
-@code{asm} template, separated either with newlines (written as
-@samp{\n}) or with semicolons if the assembler allows such semicolons.
-The GNU assembler allows semicolons and most Unix assemblers seem to do
-so.  The input operands are guaranteed not to use any of the clobbered
+@code{asm} template, separated by the characters normally used in assembly
+code for the system.  A combination that works in most places is a newline
+to break the line, plus a tab character to move to the instruction field
+(written as @samp{\n\t}).  Sometimes semicolons can be used, if the
+assembler allows semicolons as a line-breaking character.  Note that some
+assembler dialects use semicolons to start a comment.
+The input operands are guaranteed not to use any of the clobbered
 registers, and neither will the output operands' addresses, so you can
 read and write the clobbered registers as many times as you like.  Here
 is an example of multiple instructions in a template; it assumes the
 subroutine @code{_foo} accepts arguments in registers 9 and 10:
 
 @example
-asm ("movl %0,r9;movl %1,r10;call _foo"
+asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
      : /* no outputs */
      : "g" (from), "g" (to)
      : "r9", "r10");
@@ -2477,7 +2990,7 @@ instruction, you must include a branch and a label in the @code{asm}
 construct, as follows:
 
 @example
-asm ("clr %0;frob %1;beq 0f;mov #1,%0;0:"
+asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
      : "g" (result)
      : "g" (input));
 @end example
@@ -2534,28 +3047,43 @@ the @code{asm}.  For example:
 (@{ int __old; \
    asm volatile ("get_and_set_priority %0, %1": "=g" (__old) : "g" (new)); \
    __old; @})
-b@end example
+@end example
 
 @noindent
 If you write an @code{asm} instruction with no outputs, GNU CC will know
 the instruction has side-effects and will not delete the instruction or
-move it outside of loops.  If the side-effects of your instruction are
-not purely external, but will affect variables in your program in ways
-other than reading the inputs and clobbering the specified registers or
-memory, you should write the @code{volatile} keyword to prevent future
-versions of GNU CC from moving the instruction around within a core
-region.
-
-An @code{asm} instruction without any operands or clobbers (and ``old
-style'' @code{asm}) will not be deleted or moved significantly,
-regardless, unless it is unreachable, the same wasy as if you had
-written a @code{volatile} keyword.
+move it outside of loops.
+
+The @code{volatile} keyword indicates that the instruction has
+important side-effects.  GCC will not delete a volatile @code{asm} if
+it is reachable.  (The instruction can still be deleted if GCC can
+prove that control-flow will never reach the location of the
+instruction.)  In addition, GCC will not reschedule instructions
+across a volatile @code{asm} instruction.  For example:
+
+@example
+*(volatile int *)addr = foo;
+asm volatile ("eieio" : : );
+@end example
+
+@noindent 
+Assume @code{addr} contains the address of a memory mapped device
+register.  The PowerPC @code{eieio} instruction (Enforce In-order
+Execution of I/O) tells the cpu to make sure that the store to that
+device register happens before it issues any other I/O.
 
 Note that even a volatile @code{asm} instruction can be moved in ways
 that appear insignificant to the compiler, such as across jump
 instructions.  You can't expect a sequence of volatile @code{asm}
 instructions to remain perfectly consecutive.  If you want consecutive
-output, use a single @code{asm}.
+output, use a single @code{asm}.  Also, GCC will perform some
+optimizations across a volatile @code{asm} instruction; GCC does not
+``forget everything'' when it encounters a volatile @code{asm}
+instruction the way some other compilers do.
+
+An @code{asm} instruction without any operands or clobbers (an ``old
+style'' @code{asm}) will be treated identically to a volatile
+@code{asm} instruction.
 
 It is a natural idea to look for a way to give access to the condition
 code left by the assembler instruction.  However, when we attempted to
@@ -2566,10 +3094,104 @@ instructions would alter the condition code before there was time to
 test it.  This problem doesn't arise for ordinary ``test'' and
 ``compare'' instructions because they don't have any output operands.
 
-If you are writing a header file that should be includable in ANSI C
+For reasons similar to those described above, it is not possible to give
+an assembler instruction access to the condition code left by previous
+instructions.
+
+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 i386 floating point asm operands
+
+There are several rules on the usage of stack-like regs in
+asm_operands insns.  These rules apply only to the operands that are
+stack-like regs:
+
+@enumerate
+@item
+Given a set of input regs that die in an asm_operands, it is
+necessary to know which are implicitly popped by the asm, and
+which must be explicitly popped by gcc.
+
+An input reg that is implicitly popped by the asm must be
+explicitly clobbered, unless it is constrained to match an
+output operand.
+
+@item
+For any input reg that is implicitly popped by an asm, it is
+necessary to know how to adjust the stack to compensate for the pop.
+If any non-popped input is closer to the top of the reg-stack than
+the implicitly popped reg, it would not be possible to know what the
+stack looked like --- it's not clear how the rest of the stack ``slides
+up''.
+
+All implicitly popped input regs must be closer to the top of
+the reg-stack than any input that is not implicitly popped.
+
+It is possible that if an input dies in an insn, reload might
+use the input reg for an output reload.  Consider this example:
+
+@example
+asm ("foo" : "=t" (a) : "f" (b));
+@end example
+
+This asm says that input B is not popped by the asm, and that
+the asm pushes a result onto the reg-stack, ie, the stack is one
+deeper after the asm than it was before.  But, it is possible that
+reload will think that it can use the same reg for both the input and
+the output, if input B dies in this insn.
+
+If any input operand uses the @code{f} constraint, all output reg
+constraints must use the @code{&} earlyclobber.
+
+The asm above would be written as
+
+@example
+asm ("foo" : "=&t" (a) : "f" (b));
+@end example
+
+@item
+Some operands need to be in particular places on the stack.  All
+output operands fall in this category --- there is no other way to
+know which regs the outputs appear in unless the user indicates
+this in the constraints.
+
+Output operands must specifically indicate which reg an output
+appears in after an asm.  @code{=f} is not allowed: the operand
+constraints must select a class with a single reg.
+
+@item
+Output operands may not be ``inserted'' between existing stack regs.
+Since no 387 opcode uses a read/write operand, all output operands
+are dead before the asm_operands, and are pushed by the asm_operands.
+It makes no sense to push anywhere but the top of the reg-stack.
+
+Output operands must start at the top of the reg-stack: output
+operands may not ``skip'' a reg.
+
+@item
+Some asm statements may need extra stack space for internal
+calculations.  This can be guaranteed by clobbering stack registers
+unrelated to the inputs and outputs.
+
+@end enumerate
+
+Here are a couple of reasonable asms to want to write.  This asm
+takes one input, which is internally popped, and produces two outputs.
+
+@example
+asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
+@end example
+
+This asm takes two inputs, which are popped by the @code{fyl2xp1} opcode,
+and replaces them with one output.  The user must code the @code{st(1)}
+clobber for reg-stack.c to know that @code{fyl2xp1} pops both inputs.
+
+@example
+asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
+@end example
+
 @ifclear INTERNALS
 @c Show the details on constraints if they do not appear elsewhere in
 @c the manual
@@ -2801,15 +3423,20 @@ be deleted or moved or simplified.
 @cindex alternate keywords
 @cindex keywords, alternate
 
-The option @samp{-traditional} disables certain keywords; @samp{-ansi}
-disables certain others.  This causes trouble when you want to use GNU C
-extensions, or ANSI C features, in a general-purpose header file that
-should be usable by all programs, including ANSI C programs and traditional
-ones.  The keywords @code{asm}, @code{typeof} and @code{inline} cannot be
-used since they won't work in a program compiled with @samp{-ansi}, while
-the keywords @code{const}, @code{volatile}, @code{signed}, @code{typeof}
-and @code{inline} won't work in a program compiled with
-@samp{-traditional}.@refill
+The option @option{-traditional} disables certain keywords;
+@option{-ansi} and the various @option{-std} options disable certain
+others.  This causes trouble when you want to use GNU C extensions, or
+ISO C features, in a general-purpose header file that should be usable
+by all programs, including ISO C programs and traditional ones.  The
+keywords @code{asm}, @code{typeof} and @code{inline} cannot be used
+since they won't work in a program compiled with @option{-ansi}
+(although @code{inline} can be used in a program compiled with
+@option{-std=c99}), while the keywords @code{const}, @code{volatile},
+@code{signed}, @code{typeof} and @code{inline} won't work in a program
+compiled with @option{-traditional}.  The ISO C99 keyword
+@code{restrict} is only available when @option{-std=gnu99} (which will
+eventually be the default) or @option{-std=c99} (or the equivalent
+@option{-std=iso9899:1999}) is used.@refill
 
 The way to solve these problems is to put @samp{__} at the beginning and
 end of each problematical keyword.  For example, use @code{__asm__}
@@ -2826,7 +3453,9 @@ macros to replace them with the customary keywords.  It looks like this:
 #endif
 @end example
 
-@samp{-pedantic} causes warnings for many GNU C extensions.  You can
+@findex __extension__
+@samp{-pedantic} and other options cause warnings for many GNU C extensions.
+You can
 prevent such warnings within one expression by writing
 @code{__extension__} before the expression.  @code{__extension__} has no
 effect aside from this.
@@ -2851,10 +3480,11 @@ This extension is not supported by GNU C++.
 @node Function Names
 @section Function Names as Strings
 
-GNU CC predefines two string variables to be the name of the current function.
-The variable @code{__FUNCTION__} is the name of the function as it appears
-in the source.  The variable @code{__PRETTY_FUNCTION__} is the name of
-the function pretty printed in a language specific fashion.
+GNU CC predefines two magic identifiers to hold the name of the current
+function. The identifier @code{__FUNCTION__} holds the name of the function
+as it appears in the source. The identifier @code{__PRETTY_FUNCTION__}
+holds the name of the function pretty printed in a language specific
+fashion.
 
 These names are always the same in a C function, but in a C++ function
 they may be different.  For example, this program:
@@ -2890,11 +3520,43 @@ __FUNCTION__ = sub
 __PRETTY_FUNCTION__ = int  a::sub (int)
 @end smallexample
 
-These names are not macros: they are predefined string variables.
-For example, @samp{#ifdef __FUNCTION__} does not have any special
+The compiler automagically replaces the identifiers with a string
+literal containing the appropriate name. Thus, they are neither
+preprocessor macros, like @code{__FILE__} and @code{__LINE__}, nor
+variables. This means that they catenate with other string literals, and
+that they can be used to initialize char arrays. For example
+
+@smallexample
+char here[] = "Function " __FUNCTION__ " in " __FILE__;
+@end smallexample
+
+On the other hand, @samp{#ifdef __FUNCTION__} does not have any special
 meaning inside a function, since the preprocessor does not do anything
 special with the identifier @code{__FUNCTION__}.
 
+GNU CC also supports the magic word @code{__func__}, defined by the
+ISO standard C-99:
+
+@display
+The identifier @code{__func__} is implicitly declared by the translator
+as if, immediately following the opening brace of each function
+definition, the declaration
+
+@smallexample
+static const char __func__[] = "function-name";
+@end smallexample
+
+appeared, where function-name is the name of the lexically-enclosing
+function. This name is the unadorned name of the function.
+@end display
+
+By this definition, @code{__func__} is a variable, not a string literal.
+In particular, @code{__func__} does not catenate with other string
+literals.
+
+In @code{C++}, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__} are
+variables, declared in the same way as @code{__func__}.
+
 @node Return Address
 @section Getting the Return or Frame Address of a Function
 
@@ -2902,6 +3564,7 @@ These functions may be used to get information about the callers of a
 function.
 
 @table @code
+@findex __builtin_return_address
 @item __builtin_return_address (@var{level})
 This function returns the return address of the current function, or of
 one of its callers.  The @var{level} argument is number of frames to
@@ -2918,6 +3581,7 @@ of the stack has been reached, this function will return @code{0}.
 This function should only be used with a non-zero argument for debugging
 purposes.
 
+@findex __builtin_frame_address
 @item __builtin_frame_address (@var{level})
 This function is similar to @code{__builtin_return_address}, but it
 returns the address of the function frame rather than the return address
@@ -2938,6 +3602,191 @@ The caveats that apply to @code{__builtin_return_address} apply to this
 function as well.
 @end table
 
+@node Other Builtins
+@section Other built-in functions provided by GNU CC
+@cindex builtin functions
+@findex __builtin_isgreater
+@findex __builtin_isgreaterequal
+@findex __builtin_isless
+@findex __builtin_islessequal
+@findex __builtin_islessgreater
+@findex __builtin_isunordered
+@findex abort
+@findex abs
+@findex alloca
+@findex bcmp
+@findex bzero
+@findex cimag
+@findex cimagf
+@findex cimagl
+@findex conj
+@findex conjf
+@findex conjl
+@findex cos
+@findex cosf
+@findex cosl
+@findex creal
+@findex crealf
+@findex creall
+@findex exit
+@findex _exit
+@findex _Exit
+@findex fabs
+@findex fabsf
+@findex fabsl
+@findex ffs
+@findex fprintf
+@findex fputs
+@findex imaxabs
+@findex index
+@findex labs
+@findex llabs
+@findex memcmp
+@findex memcpy
+@findex memset
+@findex printf
+@findex rindex
+@findex sin
+@findex sinf
+@findex sinl
+@findex sqrt
+@findex sqrtf
+@findex sqrtl
+@findex strcat
+@findex strchr
+@findex strcmp
+@findex strcpy
+@findex strcspn
+@findex strlen
+@findex strncat
+@findex strncmp
+@findex strncpy
+@findex strpbrk
+@findex strrchr
+@findex strspn
+@findex strstr
+
+GNU CC provides a large number of built-in functions other than the ones
+mentioned above.  Some of these are for internal use in the processing
+of exceptions or variable-length argument lists and will not be
+documented here because they may change from time to time; we do not
+recommend general use of these functions.
+
+The remaining functions are provided for optimization purposes.
+
+GNU CC includes builtin versions of many of the functions in the
+standard C library.  The versions prefixed with @code{__builtin_} will
+always be treated as having the same meaning as the C library function
+even if you specify the @samp{-fno-builtin} (@pxref{C Dialect Options})
+option.  Many of these functions are only optimized in certain cases; if
+not optimized in a particular case, a call to the library function will
+be emitted.
+
+The functions @code{abort}, @code{exit}, @code{_Exit} and @code{_exit}
+are recognized and presumed not to return, but otherwise are not built
+in.  @code{_exit} is not recognized in strict ISO C mode (@samp{-ansi},
+@samp{-std=c89} or @samp{-std=c99}).  @code{_Exit} is not recognized in
+strict C89 mode (@samp{-ansi} or @samp{-std=c89}).
+
+Outside strict ISO C mode, the functions @code{alloca}, @code{bcmp},
+@code{bzero}, @code{index}, @code{rindex} and @code{ffs} may be handled
+as builtins.  Corresponding versions @code{__builtin_alloca},
+@code{__builtin_bcmp}, @code{__builtin_bzero}, @code{__builtin_index},
+@code{__builtin_rindex} and @code{__builtin_ffs} are also recognized in
+strict ISO C mode.
+
+The ISO C99 functions @code{conj}, @code{conjf}, @code{conjl},
+@code{creal}, @code{crealf}, @code{creall}, @code{cimag}, @code{cimagf},
+@code{cimagl}, @code{llabs} and @code{imaxabs} are handled as builtins
+except in strict ISO C89 mode.  There are also builtin versions of the ISO C99
+functions @code{cosf}, @code{cosl}, @code{fabsf}, @code{fabsl},
+@code{sinf}, @code{sinl}, @code{sqrtf}, and @code{sqrtl}, that are
+recognized in any mode since ISO C89 reserves these names for the
+purpose to which ISO C99 puts them.  All these functions have
+corresponding versions prefixed with @code{__builtin_}.
+
+The following ISO C89 functions are recognized as builtins unless
+@samp{-fno-builtin} is specified: @code{abs}, @code{cos}, @code{fabs},
+@code{fprintf}, @code{fputs}, @code{labs}, @code{memcmp}, @code{memcpy},
+@code{memset}, @code{printf}, @code{sin}, @code{sqrt}, @code{strcat},
+@code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
+@code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
+@code{strpbrk}, @code{strrchr}, @code{strspn}, and @code{strstr}.  All
+of these functions have corresponding versions prefixed with
+@code{__builtin_}, except that the version for @code{sqrt} is called
+@code{__builtin_fsqrt}.
+
+GNU CC provides builtin versions of the ISO C99 floating point
+comparison macros (that avoid raising exceptions for unordered
+operands): @code{__builtin_isgreater}, @code{__builtin_isgreaterequal},
+@code{__builtin_isless}, @code{__builtin_islessequal},
+@code{__builtin_islessgreater}, and @code{__builtin_isunordered}.
+
+
+@table @code
+@findex __builtin_constant_p
+@item __builtin_constant_p (@var{exp})
+You can use the builtin function @code{__builtin_constant_p} to
+determine if a value is known to be constant at compile-time and hence
+that GNU CC can perform constant-folding on expressions involving that
+value.  The argument of the function is the value to test.  The function
+returns the integer 1 if the argument is known to be a compile-time
+constant and 0 if it is not known to be a compile-time constant.  A
+return of 0 does not indicate that the value is @emph{not} a constant,
+but merely that GNU CC cannot prove it is a constant with the specified
+value of the @samp{-O} option.
+
+You would typically use this function in an embedded application where
+memory was a critical resource.  If you have some complex calculation,
+you may want it to be folded if it involves constants, but need to call
+a function if it does not.  For example:
+
+@smallexample
+#define Scale_Value(X)  \
+  (__builtin_constant_p (X) ? ((X) * SCALE + OFFSET) : Scale (X))
+@end smallexample
+
+You may use this builtin function in either a macro or an inline
+function.  However, if you use it in an inlined function and pass an
+argument of the function as the argument to the builtin, GNU CC will
+never return 1 when you call the inline function with a string constant
+or constructor expression (@pxref{Constructors}) and will not return 1
+when you pass a constant numeric value to the inline function unless you
+specify the @samp{-O} option.
+
+@findex __builtin_expect
+@item __builtin_expect(@var{exp}, @var{c})
+You may use @code{__builtin_expect} to provide the compiler with
+branch prediction information.  In general, you should prefer to
+use actual profile feedback for this (@samp{-fprofile-arcs}), as
+programmers are notoriously bad at predicting how their programs
+actually perform.  However, there are applications in which this
+data is hard to collect.
+
+The return value is the value of @var{exp}, which should be an
+integral expression.  The value of @var{c} must be a compile-time
+constant.  The semantics of the builtin are that it is expected
+that @var{exp} == @var{c}.  For example:
+
+@smallexample
+if (__builtin_expect (x, 0))
+  foo ();
+@end smallexample
+
+@noindent
+would indicate that we do not expect to call @code{foo}, since
+we expect @code{x} to be zero.  Since you are limited to integral
+expressions for @var{exp}, you should use constructions such as
+
+@smallexample
+if (__builtin_expect (ptr != NULL, 1))
+  error ();
+@end smallexample
+
+@noindent
+when testing pointer or floating-point values.
+@end table
+
 @node C++ Extensions
 @chapter Extensions to the C++ Language
 @cindex extensions, C++ language
@@ -2952,131 +3801,21 @@ test specifically for GNU C++ (@pxref{Standard Predefined,,Standard
 Predefined Macros,cpp.info,The C Preprocessor}).
 
 @menu
-* Naming Results::      Giving a name to C++ function return values.
 * Min and Max::                C++ Minimum and maximum operators.
-* Destructors and Goto:: Goto is safe to use in C++ even when destructors
-                           are needed.
+* Volatiles::          What constitutes an access to a volatile object.
+* Restricted Pointers:: C99 restricted pointers and references.
 * C++ Interface::       You can use a single C++ header file for both
-                         declarations and definitions.
+                        declarations and definitions.
 * Template Instantiation:: Methods for ensuring that exactly one copy of
-                         each needed template instantiation is emitted.
-* C++ Signatures::     You can specify abstract types to get subtype
-                        polymorphism independent from inheritance.
+                        each needed template instantiation is emitted.
+* 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.
+* Java Exceptions::     Tweaking exception handling to work with Java.
+* Deprecated Features:: Things might disappear from g++.
+* Backwards Compatibility:: Compatibilities with earlier definitions of C++.
 @end menu
 
-@node Naming Results
-@section Named Return Values in C++
-
-@cindex @code{return}, in C++ function header
-@cindex return value, named, in C++
-@cindex named return value in C++
-@cindex C++ named return value
-GNU C++ extends the function-definition syntax to allow you to specify a
-name for the result of a function outside the body of the definition, in
-C++ programs:
-
-@example
-@group
-@var{type}
-@var{functionname} (@var{args}) return @var{resultname};
-@{
-  @dots{}
-  @var{body}
-  @dots{}
-@}
-@end group
-@end example
-
-You can use this feature to avoid an extra constructor call when
-a function result has a class type.  For example, consider a function
-@code{m}, declared as @w{@samp{X v = m ();}}, whose result is of class
-@code{X}:
-
-@example
-X
-m ()
-@{
-  X b;
-  b.a = 23;
-  return b;
-@}
-@end example
-
-@cindex implicit argument: return value
-Although @code{m} appears to have no arguments, in fact it has one implicit
-argument: the address of the return value.  At invocation, the address
-of enough space to hold @code{v} is sent in as the implicit argument.
-Then @code{b} is constructed and its @code{a} field is set to the value
-23.  Finally, a copy constructor (a constructor of the form @samp{X(X&)})
-is applied to @code{b}, with the (implicit) return value location as the
-target, so that @code{v} is now bound to the return value.
-
-But this is wasteful.  The local @code{b} is declared just to hold
-something that will be copied right out.  While a compiler that
-combined an ``elision'' algorithm with interprocedural data flow
-analysis could conceivably eliminate all of this, it is much more
-practical to allow you to assist the compiler in generating
-efficient code by manipulating the return value explicitly,
-thus avoiding the local variable and copy constructor altogether.
-
-Using the extended GNU C++ function-definition syntax, you can avoid the
-temporary allocation and copying by naming @code{r} as your return value
-at the outset, and assigning to its @code{a} field directly:
-
-@example
-X
-m () return r;
-@{
-  r.a = 23;
-@}
-@end example
-
-@noindent
-The declaration of @code{r} is a standard, proper declaration, whose effects
-are executed @strong{before} any of the body of @code{m}.
-
-Functions of this type impose no additional restrictions; in particular,
-you can execute @code{return} statements, or return implicitly by
-reaching the end of the function body (``falling off the edge'').
-Cases like
-
-@example
-X
-m () return r (23);
-@{
-  return;
-@}
-@end example
-
-@noindent
-(or even @w{@samp{X m () return r (23); @{ @}}}) are unambiguous, since
-the return value @code{r} has been initialized in either case.  The
-following code may be hard to read, but also works predictably:
-
-@example
-X
-m () return r;
-@{
-  X b;
-  return b;
-@}
-@end example
-
-The return value slot denoted by @code{r} is initialized at the outset,
-but the statement @samp{return b;} overrides this value.  The compiler
-deals with this by destroying @code{r} (calling the destructor if there
-is one, or doing nothing if there is not), and then reinitializing
-@code{r} with @code{b}.
-
-This extension is provided primarily to help people who use overloaded
-operators, where there is a great need to control not just the
-arguments, but the return values of functions.  For classes where the
-copy constructor incurs a heavy performance penalty (especially in the
-common case where there is a quick default constructor), this is a major
-savings.  The disadvantage of this extension is that you do not control
-when the default constructor for the return value is called: it is
-always called at the beginning.
-
 @node Min and Max
 @section Minimum and Maximum Operators in C++
 
@@ -3122,18 +3861,135 @@ Since @code{<?} and @code{>?} are built into the compiler, they properly
 handle expressions with side-effects;  @w{@samp{int min = i++ <? j++;}}
 works correctly.
 
-@node Destructors and Goto
-@section @code{goto} and Destructors in GNU C++
+@node Volatiles
+@section When is a Volatile Object Accessed?
+@cindex accessing volatiles
+@cindex volatile read
+@cindex volatile write
+@cindex volatile access
+
+Both the C and C++ standard have the concept of volatile objects. These
+are normally accessed by pointers and used for accessing hardware. The
+standards encourage compilers to refrain from optimizations
+concerning accesses to volatile objects that it might perform on
+non-volatile objects. The C standard leaves it implementation defined
+as to what constitutes a volatile access. The C++ standard omits to
+specify this, except to say that C++ should behave in a similar manner
+to C with respect to volatiles, where possible. The minimum either
+standard specifies is that at a sequence point all previous accesses to
+volatile objects have stabilized and no subsequent accesses have
+occurred. Thus an implementation is free to reorder and combine
+volatile accesses which occur between sequence points, but cannot do so
+for accesses across a sequence point. The use of volatiles does not
+allow you to violate the restriction on updating objects multiple times
+within a sequence point.
+
+In most expressions, it is intuitively obvious what is a read and what is
+a write. For instance
+
+@example
+volatile int *dst = <somevalue>;
+volatile int *src = <someothervalue>;
+*dst = *src;
+@end example
+
+@noindent
+will cause a read of the volatile object pointed to by @var{src} and stores the
+value into the volatile object pointed to by @var{dst}. There is no
+guarantee that these reads and writes are atomic, especially for objects
+larger than @code{int}.
+
+Less obvious expressions are where something which looks like an access
+is used in a void context. An example would be,
+
+@example
+volatile int *src = <somevalue>;
+*src;
+@end example
+
+With C, such expressions are rvalues, and as rvalues cause a read of
+the object, gcc interprets this as a read of the volatile being pointed
+to. The C++ standard specifies that such expressions do not undergo
+lvalue to rvalue conversion, and that the type of the dereferenced
+object may be incomplete. The C++ standard does not specify explicitly
+that it is this lvalue to rvalue conversion which is responsible for
+causing an access. However, there is reason to believe that it is,
+because otherwise certain simple expressions become undefined. However,
+because it would surprise most programmers, g++ treats dereferencing a
+pointer to volatile object of complete type in a void context as a read
+of the object. When the object has incomplete type, g++ issues a
+warning.
+
+@example
+struct S;
+struct T @{int m;@};
+volatile S *ptr1 = <somevalue>;
+volatile T *ptr2 = <somevalue>;
+*ptr1;
+*ptr2;
+@end example
+
+In this example, a warning is issued for @code{*ptr1}, and @code{*ptr2}
+causes a read of the object pointed to. If you wish to force an error on
+the first case, you must force a conversion to rvalue with, for instance
+a static cast, @code{static_cast<S>(*ptr1)}.
+
+When using a reference to volatile, g++ does not treat equivalent
+expressions as accesses to volatiles, but instead issues a warning that
+no volatile is accessed. The rationale for this is that otherwise it
+becomes difficult to determine where volatile access occur, and not
+possible to ignore the return value from functions returning volatile
+references. Again, if you wish to force a read, cast the reference to
+an rvalue.
+
+@node Restricted Pointers
+@section Restricting Pointer Aliasing
+@cindex restricted pointers
+@cindex restricted references
+@cindex restricted this pointer
+
+As with gcc, g++ understands the C99 feature of restricted pointers,
+specified with the @code{__restrict__}, or @code{__restrict} type
+qualifier. Because you cannot compile C++ by specifying the -std=c99
+language flag, @code{restrict} is not a keyword in C++.
+
+In addition to allowing restricted pointers, you can specify restricted
+references, which indicate that the reference is not aliased in the local
+context.
 
-@cindex @code{goto} in C++
-@cindex destructors vs @code{goto}
-In C++ programs, you can safely use the @code{goto} statement.  When you
-use it to exit a block which contains aggregates requiring destructors,
-the destructors will run before the @code{goto} transfers control.
+@example
+void fn (int *__restrict__ rptr, int &__restrict__ rref)
+@{
+  @dots{}
+@}
+@end example
 
-@cindex constructors vs @code{goto}
-The compiler still forbids using @code{goto} to @emph{enter} a scope
-that requires constructors.
+@noindent
+In the body of @code{fn}, @var{rptr} points to an unaliased integer and
+@var{rref} refers to a (different) unaliased integer.
+
+You may also specify whether a member function's @var{this} pointer is
+unaliased by using @code{__restrict__} as a member function qualifier.
+
+@example
+void T::fn () __restrict__
+@{
+  @dots{}
+@}
+@end example
+
+@noindent
+Within the body of @code{T::fn}, @var{this} will have the effective
+definition @code{T *__restrict__ const this}. Notice that the
+interpretation of a @code{__restrict__} member function qualifier is
+different to that of @code{const} or @code{volatile} qualifier, in that it
+is applied to the pointer rather than the object. This is consistent with
+other compilers which implement restricted pointers.
+
+As with all outermost parameter qualifiers, @code{__restrict__} is
+ignored in function definition matching. This means you only need to
+specify @code{__restrict__} in a function definition, rather than
+in a function prototype as well.
 
 @node C++ Interface
 @section Declarations and Definitions in One Header
@@ -3370,12 +4226,16 @@ other files) without having to specify them as well.
 
 g++ has extended the template instantiation syntax outlined in the
 Working Paper to allow forward declaration of explicit instantiations
-and instantiation of the compiler support data for a template class
-(i.e. the vtable) without instantiating any of its members:
+(with @code{extern}), instantiation of the compiler support data for a
+template class (i.e. the vtable) without instantiating any of its
+members (with @code{inline}), and instantiation of only the static data
+members of a template class, without the support data or member
+functions (with (@code{static}):
 
 @example
 extern template int max (int, int);
 inline template class Foo<int>;
+static template class Foo<int>;
 @end example
 
 @item
@@ -3421,141 +4281,202 @@ be the same in all translation units, or things are likely to break.
 more discussion of these pragmas.
 @end enumerate
 
-@node C++ Signatures
-@section Type Abstraction using Signatures
-
-@findex signature
-@cindex type abstraction, C++
-@cindex C++ type abstraction
-@cindex subtype polymorphism, C++
-@cindex C++ subtype polymorphism
-@cindex signatures, C++
-@cindex C++ signatures
-
-In GNU C++, you can use the keyword @code{signature} to define a
-completely abstract class interface as a datatype.  You can connect this
-abstraction with actual classes using signature pointers.  If you want
-to use signatures, run the GNU compiler with the
-@samp{-fhandle-signatures} command-line option.  (With this option, the
-compiler reserves a second keyword @code{sigof} as well, for a future
-extension.)
-
-Roughly, signatures are type abstractions or interfaces of classes.
-Some other languages have similar facilities.  C++ signatures are
-related to ML's signatures, Haskell's type classes, definition modules
-in Modula-2, interface modules in Modula-3, abstract types in Emerald,
-type modules in Trellis/Owl, categories in Scratchpad II, and types in
-POOL-I.  For a more detailed discussion of signatures, see
-@cite{Signatures: A Language Extension for Improving Type Abstraction and
-Subtype Polymorphism in C++}
-by @w{Gerald} Baumgartner and Vincent F. Russo (Tech report
-CSD--TR--95--051, Dept. of Computer Sciences, Purdue University,
-August 1995, a slightly improved version appeared in
-@emph{Software---Practice & Experience}, @b{25}(8), pp. 863--889,
-August 1995).  You can get the tech report by anonymous FTP from
-@code{ftp.cs.purdue.edu} in @file{pub/gb/Signature-design.ps.gz}.
-
-Syntactically, a signature declaration is a collection of
-member function declarations and nested type declarations.
-For example, this signature declaration defines a new abstract type
-@code{S} with member functions @samp{int foo ()} and @samp{int bar (int)}:
-
-@example
-signature S
-@{
-  int foo ();
-  int bar (int);
-@};
+@node Bound member functions
+@section Extracting the function pointer from a bound pointer to member function
+
+@cindex pmf
+@cindex pointer to member function
+@cindex bound pointer to member function
+
+In C++, pointer to member functions (PMFs) are implemented using a wide
+pointer of sorts to handle all the possible call mechanisms; the PMF
+needs to store information about how to adjust the @samp{this} pointer,
+and if the function pointed to is virtual, where to find the vtable, and
+where in the vtable to look for the member function.  If you are using
+PMFs in an inner loop, you should really reconsider that decision.  If
+that is not an option, you can extract the pointer to the function that
+would be called for a given object/PMF pair and call it directly inside
+the inner loop, to save a bit of time.
+
+Note that you will still be paying the penalty for the call through a
+function pointer; on most modern architectures, such a call defeats the
+branch prediction features of the CPU.  This is also true of normal
+virtual function calls.
+
+The syntax for this extension is
+
+@example
+extern A a;
+extern int (A::*fp)();
+typedef int (*fptr)(A *);
+
+fptr p = (fptr)(a.*fp);
 @end example
 
-Since signature types do not include implementation definitions, you
-cannot write an instance of a signature directly.  Instead, you can
-define a pointer to any class that contains the required interfaces as a
-@dfn{signature pointer}.  Such a class @dfn{implements} the signature
-type.
-@c Eventually signature references should work too.
+For PMF constants (i.e. expressions of the form @samp{&Klasse::Member}),
+no object is needed to obtain the address of the function. They can be
+converted to function pointers directly:
+
+@example
+fptr p1 = (fptr)(&A::foo);
+@end example
+
+You must specify @samp{-Wno-pmf-conversions} to use this extension.
+
+@node C++ Attributes
+@section C++-Specific Variable, Function, and Type Attributes
+
+Some attributes only make sense for C++ programs.
+
+@table @code
+@item init_priority (@var{priority})
+@cindex init_priority attribute
 
-To use a class as an implementation of @code{S}, you must ensure that
-the class has public member functions @samp{int foo ()} and @samp{int
-bar (int)}.  The class can have other member functions as well, public
-or not; as long as it offers what's declared in the signature, it is
-suitable as an implementation of that signature type.
 
-For example, suppose that @code{C} is a class that meets the
-requirements of signature @code{S} (@code{C} @dfn{conforms to}
-@code{S}).  Then
+In Standard C++, objects defined at namespace scope are guaranteed to be
+initialized in an order in strict accordance with that of their definitions
+@emph{in a given translation unit}.  No guarantee is made for initializations
+across translation units.  However, GNU C++ allows users to control the
+order of initialization of objects defined at namespace scope with the
+@code{init_priority} attribute by specifying a relative @var{priority},
+a constant integral expression currently bounded between 101 and 65535
+inclusive.  Lower numbers indicate a higher priority.
+
+In the following example, @code{A} would normally be created before
+@code{B}, but the @code{init_priority} attribute has reversed that order:
 
 @example
-C obj;
-S * p = &obj;
+Some_Class  A  __attribute__ ((init_priority (2000)));
+Some_Class  B  __attribute__ ((init_priority (543)));
 @end example
 
 @noindent
-defines a signature pointer @code{p} and initializes it to point to an
-object of type @code{C}.
-The member function call @w{@samp{int i = p->foo ();}}
-executes @samp{obj.foo ()}.
+Note that the particular values of @var{priority} do not matter; only their
+relative ordering.
 
-@cindex @code{signature} in C++, advantages
-Abstract virtual classes provide somewhat similar facilities in standard
-C++.  There are two main advantages to using signatures instead:
 
-@enumerate
-@item
-Subtyping becomes independent from inheritance.  A class or signature
-type @code{T} is a subtype of a signature type @code{S} independent of
-any inheritance hierarchy as long as all the member functions declared
-in @code{S} are also found in @code{T}.  So you can define a subtype
-hierarchy that is completely independent from any inheritance
-(implementation) hierarchy, instead of being forced to use types that
-mirror the class inheritance hierarchy.
+@item com_interface
+@cindex com_interface attribute
 
-@item
-Signatures allow you to work with existing class hierarchies as
-implementations of a signature type.  If those class hierarchies are
-only available in compiled form, you're out of luck with abstract virtual
-classes, since an abstract virtual class cannot be retrofitted on top of
-existing class hierarchies.  So you would be required to write interface
-classes as subtypes of the abstract virtual class.
-@end enumerate
+@c This is based on:  1) grepping the code,
+@c 2) http://gcc.gnu.org/ml/gcc-bugs/1999-08n/msg01212.html
+@c 3) http://gcc.gnu.org/ml/gcc-bugs/1999-08n/msg01215.html
+@c and 4) a lot of guesswork.  You can tell I don't use COM.  -pme 21Dec00
+
+This type attribute takes no parameters, and marks a class or struct as an
+interface for communication via COM; the class will support the COM ABI
+rather than the full C++ ABI.  Currently this means that RTTI is not possible
+with the resulting class heirarchy.  The virtual pointer table will be
+changed to be COM-compliant.  Also, all classes and structs derived from one
+marked with this attribute are implicitly marked with the same attribute;
+thus, only the base class in a COM hierarchy needs @code{com_interface}.
+
+@item java_interface
+@cindex java_interface attribute
+
+This type attribute informs C++ that the class is a Java interface.  It may
+only be applied to classes declared within an @code{extern "Java"} block.
+Calls to methods declared in this interface will be dispatched using GCJ's
+interface table mechanism, instead of regular virtual table dispatch.
+
+@end table
 
-@cindex default implementation, signature member function
-@cindex signature member function default implementation
-There is one more detail about signatures.  A signature declaration can
-contain member function @emph{definitions} as well as member function
-declarations.  A signature member function with a full definition is
-called a @emph{default implementation}; classes need not contain that
-particular interface in order to conform.  For example, a
-class @code{C} can conform to the signature
+@node Java Exceptions
+@section Java Exceptions
+
+The Java language uses a slightly different exception handling model
+from C++.  Normally, GNU C++ will automatically detect when you are
+writing C++ code that uses Java exceptions, and handle them
+appropriately.  However, if C++ code only needs to execute destructors
+when Java exceptions are thrown through it, GCC will guess incorrectly.
+Sample problematic code:
 
 @example
-signature T
-@{
-  int f (int);
-  int f0 () @{ return f (0); @};
-@};
+  struct S @{ ~S(); @};
+  extern void bar();    // is implemented in Java and may throw exceptions
+  void foo()
+  @{
+    S s;
+    bar();
+  @}
 @end example
 
 @noindent
-whether or not @code{C} implements the member function @samp{int f0 ()}.
-If you define @code{C::f0}, that definition takes precedence;
-otherwise, the default implementation @code{S::f0} applies.
-
-@ignore
-There will be more support for signatures in the future.
-Add to this doc as the implementation grows.
-In particular, the following features are planned but not yet
-implemented:
-@itemize @bullet
-@item signature references,
-@item signature inheritance,
-@item the @code{sigof} construct for extracting the signature information
-      of a class,
-@item views for renaming member functions when matching a class type
-      with a signature type,
-@item specifying exceptions with signature member functions, and
-@item signature templates.
-@end itemize
-This list is roughly in the order in which we intend to implement
-them.  Watch this space for updates.
-@end ignore
+The usual effect of an incorrect guess is a link failure, complaining of
+a missing routine called @samp{__gxx_personality_v0}.
+
+You can inform the compiler that Java exceptions are to be used in a
+translation unit, irrespective of what it might think, by writing
+@samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
+@samp{#pragma} must appear before any functions that throw or catch
+exceptions, or run destructors when exceptions are thrown through them.
+
+You cannot mix Java and C++ exceptions in the same translation unit.  It
+is believed to be safe to throw a C++ exception from one file through
+another file compiled for the for the Java exception model, or vice
+versa, but there may be bugs in this area.
+
+@node Deprecated Features
+@section Deprecated Features
+
+In the past, the GNU C++ compiler was extended to experiment with new
+features, at a time when the C++ language was still evolving. Now that
+the C++ standard is complete, some of those features are superseded by
+superior alternatives. Using the old features might cause a warning in
+some cases that the feature will be dropped in the future. In other
+cases, the feature might be gone already.
+
+While the list below is not exhaustive, it documents some of the options
+that are now deprecated:
+
+@table @code
+@item -fexternal-templates
+@itemx -falt-external-templates
+These are two of the many ways for g++ to implement template
+instantiation. @xref{Template Instantiation}. The C++ standard clearly
+defines how template definitions have to be organized across
+implementation units. g++ has an implicit instantiation mechanism that
+should work just fine for standard-conforming code.
+
+@item -fstrict-prototype
+@itemx -fno-strict-prototype
+Previously it was possible to use an empty prototype parameter list to
+indicate an unspecified number of parameters (like C), rather than no
+parameters, as C++ demands. This feature has been removed, except where
+it is required for backwards compatibility @xref{Backwards Compatibility}.
+@end table
+
+The named return value extension has been deprecated, and will be
+removed from g++ at some point.
+
+The use of initializer lists with new expressions has been deprecated,
+and will be removed from g++ at some point.
+
+@node Backwards Compatibility
+@section Backwards Compatibility
+@cindex Backwards Compatibility
+@cindex ARM [Annotated C++ Reference Manual]
+
+Now that there is a definitive ISO standard C++, g++ has a specification
+to adhere to. The C++ language evolved over time, and features that
+used to be acceptable in previous drafts of the standard, such as the ARM
+[Annotated C++ Reference Manual], are no longer accepted. In order to allow
+compilation of C++ written to such drafts, g++ contains some backwards
+compatibilities. @emph{All such backwards compatibility features are
+liable to disappear in future versions of g++.} They should be considered
+deprecated @xref{Deprecated Features}.
+
+@table @code
+@item For scope
+If a variable is declared at for scope, it used to remain in scope until
+the end of the scope which contained the for statement (rather than just
+within the for scope). g++ retains this, but issues a warning, if such a
+variable is accessed outside the for scope.
+
+@item implicit C language
+Old C system header files did not contain an @code{extern "C" @{...@}}
+scope to set the language. On such systems, all header files are
+implicitly scoped inside a C language scope. Also, an empty prototype
+@code{()} will be treated as an unspecified number of arguments, rather
+than no arguments, as C++ demands.
+@end table