From 92318bc515d223b2eeebb665f76e131dd2318b2b Mon Sep 17 00:00:00 2001 From: kan Date: Thu, 10 Oct 2002 04:40:18 +0000 Subject: Gcc 3.2.1-prerelease from the FSF anoncvs repo gcc-3_2-branch on October 9th 2002 20:15 EST. --- contrib/gcc/doc/cpp.texi | 37 ++++++++++++----------- contrib/gcc/doc/extend.texi | 74 +++++++++++++++++++++++++-------------------- contrib/gcc/doc/invoke.texi | 22 ++++++-------- 3 files changed, 72 insertions(+), 61 deletions(-) (limited to 'contrib/gcc/doc') diff --git a/contrib/gcc/doc/cpp.texi b/contrib/gcc/doc/cpp.texi index 8e829d8..39e6a28 100644 --- a/contrib/gcc/doc/cpp.texi +++ b/contrib/gcc/doc/cpp.texi @@ -830,11 +830,22 @@ version of GCC in use. You can add to this list with the @option{-I@var{dir}} command line option. All the directories named by @option{-I} are searched, in -left-to-right order, @emph{before} the default directories. You can -also prevent GCC from searching any of the default directories with the -@option{-nostdinc} option. This is useful when you are compiling an +left-to-right order, @emph{before} the default directories. The only +exception is when @file{dir} is already searched by default. In +this case, the option is ignored and the search order for system +directories remains unchanged. + +Duplicate directories are removed from the quote and bracket search +chains before the two chains are merged to make the final search chain. +Thus, it is possible for a directory to occur twice in the final search +chain if it was specified in both the quote and bracket chains. + +You can prevent GCC from searching any of the default directories with +the @option{-nostdinc} option. This is useful when you are compiling an operating system kernel or some other program that does not use the standard C library facilities, or the standard C library itself. +@option{-I} options are not ignored as described above when +@option{-nostdinc} is in effect. GCC looks for headers requested with @code{@w{#include "@var{file}"}} first in the directory containing the current file, then in the same @@ -843,12 +854,6 @@ For example, if @file{/usr/include/sys/stat.h} contains @code{@w{#include "types.h"}}, GCC looks for @file{types.h} first in @file{/usr/include/sys}, then in its usual search path. -If you name a search directory with @option{-I@var{dir}} that is also a -system include directory, the @option{-I} wins; the directory will be -searched according to the @option{-I} ordering, and it will not be -treated as a system include directory. GCC will warn you when a system -include directory is hidden in this way. - @samp{#line} (@pxref{Line Control}) does not change GCC's idea of the directory containing the current file. @@ -1081,8 +1086,8 @@ found in that directory will be considered system headers. All directories named by @option{-isystem} are searched @emph{after} all directories named by @option{-I}, no matter what their order was on the command line. If the same directory is named by both @option{-I} and -@option{-isystem}, @option{-I} wins; it is as if the @option{-isystem} option -had never been specified at all. GCC warns you when this happens. +@option{-isystem}, the @option{-I} option is ignored. GCC provides an +informative message when this occurs if @option{-v} is used. @findex #pragma GCC system_header There is also a directive, @code{@w{#pragma GCC system_header}}, which @@ -1815,9 +1820,7 @@ conformance to the C Standard. GNU CPP follows the host convention when processing system header files, but when processing user files @code{__STDC__} is always 1. This has been reported to cause problems; for instance, some versions of Solaris provide X Windows headers that -expect @code{__STDC__} to be either undefined or 1. You may be able to -work around this sort of problem by using an @option{-I} option to -cancel treatment of those headers as system headers. @xref{Invocation}. +expect @code{__STDC__} to be either undefined or 1. @xref{Invocation}. @item __STDC_VERSION__ This macro expands to the C Standard's version number, a long integer @@ -3733,9 +3736,9 @@ Here are a few more obsolete features. @item Attempting to paste two tokens which together do not form a valid preprocessing token. -The preprocessor currently warns about this and outputs the two tokens -adjacently, which is probably the behavior the programmer intends. It -may not work in future, though. +The preprocessor currently warns about this, and the resulting +preprocessed output is undefined. The tokens remain distinct if the +preprocessor is being used directly by the compiler front end. Most of the time, when you get this warning, you will find that @samp{##} is being used superstitiously, to guard against whitespace appearing diff --git a/contrib/gcc/doc/extend.texi b/contrib/gcc/doc/extend.texi index 79eea70..281e4ac 100644 --- a/contrib/gcc/doc/extend.texi +++ b/contrib/gcc/doc/extend.texi @@ -385,7 +385,6 @@ extensions, accepted by GCC in C89 mode and in C++. * Labels as Values:: Getting pointers to labels, and computed gotos. * Nested Functions:: As in Algol and Pascal, lexical scoping of functions. * Constructing Calls:: Dispatching a call to another function. -* Naming Types:: Giving a name to the type of some expression. * Typeof:: @code{typeof}: referring to the type of an expression. * Lvalues:: Using @samp{?:}, @samp{,} and casts in lvalues. * Conditionals:: Omitting the middle operand of a @samp{?:} expression. @@ -495,8 +494,7 @@ the value of an enumeration constant, the width of a bit-field, or the initial value of a static variable. 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}). +must use @code{typeof} (@pxref{Typeof}). Statement expressions are not supported fully in G++, and their fate there is unclear. (It is possible that they will become fully supported @@ -845,29 +843,6 @@ the containing function. You should specify, for @var{result}, a value returned by @code{__builtin_apply}. @end deftypefn -@node Naming Types -@section Naming an Expression's Type -@cindex naming types - -You can give a name to the type of an expression using a @code{typedef} -declaration with an initializer. Here is how to define @var{name} as a -type name for the type of @var{exp}: - -@example -typedef @var{name} = @var{exp}; -@end example - -This is useful in conjunction with the statements-within-expressions -feature. Here is how the two together can be used to define a safe -``maximum'' macro that operates on any arithmetic type: - -@example -#define max(a,b) \ - (@{typedef _ta = (a), _tb = (b); \ - _ta _a = (a); _tb _b = (b); \ - _a > _b ? _a : _b; @}) -@end example - @cindex underscores in variables in macros @cindex @samp{_} in variables in macros @cindex local variables in macros @@ -919,6 +894,21 @@ A @code{typeof}-construct can be used anywhere a typedef name could be used. For example, you can use it in a declaration, in a cast, or inside of @code{sizeof} or @code{typeof}. +@code{typeof} is often useful in conjunction with the +statements-within-expressions feature. Here is how the two together can +be used to define a safe ``maximum'' macro that operates on any +arithmetic type and evaluates each of its arguments exactly once: + +@example +#define max(a,b) \ + (@{ typeof (a) _a = (a); \ + typeof (b) _b = (b); \ + _a > _b ? _a : _b; @}) +@end example + +@noindent +Some more examples of the use of @code{typeof}: + @itemize @bullet @item This declares @code{y} with the type of what @code{x} points to. @@ -968,6 +958,26 @@ Thus, @code{array (pointer (char), 4)} is the type of arrays of 4 pointers to @code{char}. @end itemize +@emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported +a more limited extension which permitted one to write + +@example +typedef @var{T} = @var{expr}; +@end example + +@noindent +with the effect of declaring @var{T} to have the type of the expression +@var{expr}. This extension does not work with GCC 3 (versions between +3.0 and 3.2 will crash; 3.2.1 and later give an error). Code which +relies on it should be rewritten to use @code{typeof}: + +@example +typedef typeof(@var{expr}) @var{T}; +@end example + +@noindent +This will work with all versions of GCC@. + @node Lvalues @section Generalized Lvalues @cindex compound expressions as lvalues @@ -6170,12 +6180,12 @@ the minimum value of variables @var{i} and @var{j}. However, side effects in @code{X} or @code{Y} may cause unintended behavior. For example, @code{MIN (i++, j++)} will fail, incrementing -the smaller counter twice. A GNU C extension allows you to write safe -macros that avoid this kind of problem (@pxref{Naming Types,,Naming an -Expression's Type}). However, writing @code{MIN} and @code{MAX} as -macros also forces you to use function-call notation for a -fundamental arithmetic operation. Using GNU C++ extensions, you can -write @w{@samp{int min = i ?} are built into the compiler, they properly handle expressions with side-effects; @w{@samp{int min = i++