diff options
-rw-r--r-- | gcc/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/c-cppbuiltin.c | 5 | ||||
-rw-r--r-- | gcc/c-opts.c | 2 | ||||
-rw-r--r-- | gcc/cppfiles.c | 4 | ||||
-rw-r--r-- | gcc/cppinit.c | 11 | ||||
-rw-r--r-- | gcc/cpplib.h | 2 | ||||
-rw-r--r-- | gcc/doc/cpp.texi | 22 | ||||
-rw-r--r-- | gcc/doc/cppopts.texi | 7 | ||||
-rw-r--r-- | gcc/fix-header.c | 2 |
9 files changed, 47 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fcfd2f4..514e2d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2003-05-11 Bruno Haible <bruno@clisp.org> + + * cppfiles.c (find_or_create_entry): Preserve errno. + +2003-05-11 Neil Booth <neil@cat.daikokuya.co.uk> + + * c-cppbuiltin.c (c_cpp_builtins): Move __STDC_HOSTED__ into + cpplib as it's a Standard Predefined Macro. + * c-opts.c (finish_options): Pass flag_hosted to cpp_init_builtins. + * cppinit.c (_cpp_init_builtins): Take HOSTED. Define + __STDC_HOSTED__ appropriately. + * cpplib.h (_cpp_init_builtins): Update. + * fix-header.c (read_scan_file): Update. + * doc/cpp.texi, doc/cppopts.texi: Update documentation. + 2003-05-11 Gabriel Dos Reis <gdr@integrable-solutions.net> PR C++/689 diff --git a/gcc/c-cppbuiltin.c b/gcc/c-cppbuiltin.c index 0a9f7d1..9cb1b4e 100644 --- a/gcc/c-cppbuiltin.c +++ b/gcc/c-cppbuiltin.c @@ -355,11 +355,6 @@ c_cpp_builtins (pfile) if (optimize) cpp_define (pfile, "__OPTIMIZE__"); - if (flag_hosted) - cpp_define (pfile, "__STDC_HOSTED__=1"); - else - cpp_define (pfile, "__STDC_HOSTED__=0"); - if (fast_math_flags_set_p ()) cpp_define (pfile, "__FAST_MATH__"); if (flag_really_no_inline) diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 82cae2e..23ed899 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -1789,7 +1789,7 @@ finish_options () size_t i; cpp_change_file (parse_in, LC_RENAME, _("<built-in>")); - cpp_init_builtins (parse_in); + cpp_init_builtins (parse_in, flag_hosted); c_cpp_builtins (parse_in); cpp_change_file (parse_in, LC_RENAME, _("<command line>")); for (i = 0; i < deferred_count; i++) diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index c7a4f9c..66865af2 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -174,8 +174,10 @@ find_or_create_entry (pfile, fname) splay_tree_node node; struct include_file *file; char *name = xstrdup (fname); + int saved_errno; cpp_simplify_path (name); + saved_errno = errno; node = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) name); if (node) free (name); @@ -184,7 +186,7 @@ find_or_create_entry (pfile, fname) file = xcnew (struct include_file); file->name = name; file->header_name = name; - file->err_no = errno; + file->err_no = saved_errno; node = splay_tree_insert (pfile->all_include_files, (splay_tree_key) file->name, (splay_tree_value) file); diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 4066ee3..96ac9a4 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -327,10 +327,12 @@ mark_named_operators (pfile) } /* Read the builtins table above and enter them, and language-specific - macros, into the hash table. */ + macros, into the hash table. HOSTED is true if this is a hosted + environment. */ void -cpp_init_builtins (pfile) +cpp_init_builtins (pfile, hosted) cpp_reader *pfile; + int hosted; { const struct builtin *b; size_t n = ARRAY_SIZE (builtin_array); @@ -355,6 +357,11 @@ cpp_init_builtins (pfile) else if (CPP_OPTION (pfile, c99)) _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L"); + if (hosted) + cpp_define (pfile, "__STDC_HOSTED__=1"); + else + cpp_define (pfile, "__STDC_HOSTED__=0"); + if (CPP_OPTION (pfile, objc)) _cpp_define_builtin (pfile, "__OBJC__ 1"); } diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 90977d1..a47a7fb 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -526,7 +526,7 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *)); extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *)); /* Set up built-ins like __FILE__. */ -extern void cpp_init_builtins PARAMS ((cpp_reader *)); +extern void cpp_init_builtins PARAMS ((cpp_reader *, int)); /* Call this to finish preprocessing. If you requested dependency generation, pass an open stream to write the information to, diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 173e341..336cc47 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -264,15 +264,14 @@ complete support for international character sets in a future release. Different systems use different conventions to indicate the end of a line. GCC accepts the ASCII control sequences @kbd{LF}, @kbd{@w{CR -LF}}, @kbd{CR}, and @kbd{@w{LF CR}} as end-of-line markers. The first -three are the canonical sequences used by Unix, DOS and VMS, and the +LF}}, @kbd{CR} as end-of-line markers. These +are the canonical sequences used by Unix, DOS and VMS, and the classic Mac OS (before OSX) respectively. You may therefore safely copy source code written on any of those systems to a different one and use it without conversion. (GCC may lose track of the current line number if a file doesn't consistently use one convention, as sometimes happens when it is edited on computers with different conventions that share a -network file system.) @kbd{@w{LF CR}} is included because it has been -reported as an end-of-line marker under exotic conditions. +network file system.) If the last line of any input file lacks an end-of-line marker, the end of the file is considered to implicitly supply one. The C standard says @@ -1733,7 +1732,7 @@ predefined macros, but you cannot undefine them. @subsection Standard Predefined Macros @cindex standard predefined macros. -The standard predefined macros are specified by the C and/or C++ +The standard predefined macros are specified by the relevant language standards, so they are available with all compilers that implement those standards. Older compilers may not provide all of them. Their names all start with double underscores. @@ -1852,6 +1851,14 @@ of the 1998 C++ standard will define this macro to @code{199711L}. The GNU C++ compiler is not yet fully conforming, so it uses @code{1} instead. We hope to complete our implementation in the near future. +@item __OBJC__ +This macro is defined, with value 1, when the Objective-C compiler is in +use. You can use @code{__OBJC__} to test whether a header is compiled +by a C compiler or a Objective-C compiler. + +@item __ASSEMBLER__ +This macro is defined with value 1 when preprocessing assembler. + @end table @node Common Predefined Macros @@ -1913,11 +1920,6 @@ calculate a single number, then compare that against a threshold: @noindent Many people find this form easier to understand. -@item __OBJC__ -This macro is defined, with value 1, when the Objective-C compiler is in -use. You can use @code{__OBJC__} to test whether a header is compiled -by a C compiler or a Objective-C compiler. - @item __GNUG__ The GNU C++ compiler defines this. Testing it is equivalent to testing @code{@w{(__GNUC__ && __cplusplus)}}. diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi index 4a1f30f..4c98c32 100644 --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi @@ -40,8 +40,11 @@ provided with a @option{-D} option. @item -undef @opindex undef -Do not predefine any system-specific macros. The common predefined -macros remain defined. +Do not predefine any system-specific or GCC-specific macros. The +standard predefined macros remain defined. +@ifset cppmanual +@xref{Standard Predefined Macros} +@end ifset @item -I @var{dir} @opindex I diff --git a/gcc/fix-header.c b/gcc/fix-header.c index f76cbd1..c34d3c3 100644 --- a/gcc/fix-header.c +++ b/gcc/fix-header.c @@ -636,7 +636,7 @@ read_scan_file (in_fname, argc, argv) exit (FATAL_EXIT_CODE); cpp_change_file (scan_in, LC_RENAME, "<built-in>"); - cpp_init_builtins (scan_in); + cpp_init_builtins (scan_in, true); cpp_change_file (scan_in, LC_RENAME, in_fname); /* Process switches after builtins so -D can override them. */ |