c-cppbuiltin.c (c_cpp_builtins): Move __STDC_HOSTED__ into cpplib as it's a Standard...
authorNeil Booth <neil@gcc.gnu.org>
Sun, 11 May 2003 13:43:36 +0000 (13:43 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 11 May 2003 13:43:36 +0000 (13:43 +0000)
* 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.
* cppfiles.c (find_or_create_entry): Preserve errno.

From-SVN: r66688

gcc/ChangeLog
gcc/c-cppbuiltin.c
gcc/c-opts.c
gcc/cppfiles.c
gcc/cppinit.c
gcc/cpplib.h
gcc/doc/cpp.texi
gcc/doc/cppopts.texi
gcc/fix-header.c

index fcfd2f4d282b2922c271923cc7f3011e76cf8a27..514e2d2e22b2860776b2fcd9b1fb78bc2d5ef892 100644 (file)
@@ -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
index 0a9f7d11751fda89d9f8f6c046d5c8471937f024..9cb1b4efb52bb5ede4e45bb988c5d0fb8583f351 100644 (file)
@@ -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)
index 82cae2e6c9f667f422f54d62ae59553ce9b0db6d..23ed899ae18d0db83bc1d8ffa940d2adbaa4ed5c 100644 (file)
@@ -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++)
index c7a4f9c87dc83ff4ae1ab82a7316ead96f297f16..66865af26516744813163d63cb0339e63a8a366d 100644 (file)
@@ -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);
index 4066ee31dbdd9265c780c85e6c80a17cc107f305..96ac9a46bd2aaa8de7e57d1f7e1f9cc4bc250dc2 100644 (file)
@@ -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");
 }
index 90977d1edb9d2988b3cb4dede4cff948776a7178..a47a7fbf077fd1e0982b220359e28feef3fe6177 100644 (file)
@@ -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,
index 173e341fb830741ffc37781b3cb3c595501d525c..336cc47706bf1aefb1466beb75123a17e95a508a 100644 (file)
@@ -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)}}.
index 4a1f30f96e05a0e047c13eada113d35f7ea0f523..4c98c322f841960c9ac3d7864b339d6280b6de28 100644 (file)
@@ -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
index f76cbd146a036e6c3518d0f88d75bb53d8628cfe..c34d3c3e3be3a2800df57a023a5710a4d90774c4 100644 (file)
@@ -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.  */