]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Removal of separate preprocessor cpp0.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Sun, 24 Mar 2002 12:27:45 +0000 (12:27 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 24 Mar 2002 12:27:45 +0000 (12:27 +0000)
* Makefile.in (GCC_PASSES, STAGESTUFF, LIBCPP_OBJS,
cpp0, install-common): Update.
* c-common.c (flag_preprocess_only): New.
(c_common_init): Preprocess for -E.
* c-common.h (flag_preprocess_only): New.
* c-decl.c (c_decode_option): Handle -E, and -std=c++98.
* c-objc-common.c (c_init_decl_processing): Exit quickly
for NULL return from c_common_init.
* cpplib.h (cpp_preprocess_file): New.
* cppmain.c (main, general_init, pfile, progname): Remove.
(do_preprocessing): Rename cpp_preprocess_file, don't call
cpp_finish.  Don't close stdout here.
(setup_callbacks): Update prototype.
* gcc.c (trad_capable_cpp, cpp_unique_options, default_compilers):
Update.
* tradcpp.c (main): Ignore -quiet.
cp:
* decl2.c (cxx_decode_option): Handle -E.
* lang-specs.h (default_compilers): Preprocess with cc1plus.
* lex.c (cxx_init): Exit quickly if c_common_init returns NULL.
objc:
* lang-specs.h (default_compilers): Preprocess with cc1obj.

Co-Authored-By: Aldy Hernandez <aldyh@redhat.com>
From-SVN: r51256

15 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/c-common.c
gcc/c-common.h
gcc/c-decl.c
gcc/c-objc-common.c
gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/lang-specs.h
gcc/cp/lex.c
gcc/cpplib.h
gcc/cppmain.c
gcc/gcc.c
gcc/objc/lang-specs.h
gcc/tradcpp.c

index f75a46379ed4e429e7a622015d0adb7322564ab6..3f568562ca2e081968dee818b92ef85b68d721dd 100644 (file)
@@ -1,3 +1,27 @@
+2002-03-24  Neil Booth  <neil@daikokuya.demon.co.uk>
+           Aldy Hernandez  <aldyh@redhat.com>
+
+       Removal of separate preprocessor cpp0.
+
+       * Makefile.in (GCC_PASSES, STAGESTUFF, LIBCPP_OBJS,
+       cpp0, install-common): Update.
+       * c-common.c (flag_preprocess_only): New.
+       (c_common_init): Preprocess for -E.
+       * c-common.h (flag_preprocess_only): New.
+       * c-decl.c (c_decode_option): Handle -E and -std=c++98.
+       * c-objc-common.c (c_init_decl_processing): Exit quickly
+       for NULL return from c_common_init.
+       * cpplib.h (cpp_preprocess_file): New.
+       * cppmain.c (main, general_init, pfile, progname): Remove.
+       (do_preprocessing): Rename cpp_preprocess_file, don't call
+       cpp_finish.  Don't close stdout here.
+       (setup_callbacks): Update prototype.
+       * gcc.c (trad_capable_cpp, cpp_unique_options, default_compilers):
+       Update.
+       * tradcpp.c (main): Ignore -quiet.
+objc:
+       * lang-specs.h (default_compilers): Preprocess with cc1obj.
+
 2002-03-24  Richard Henderson  <rth@redhat.com>
 
        PR optimization/5742
index 462e20e4c682af2ab919c8dff53032227c6e6280..e9642fc4422f2e8c3261e90a16d15223a9c64b31 100644 (file)
@@ -450,7 +450,7 @@ COMPILERS = cc1$(exeext) @all_compilers@
 
 # List of things which should already be built whenever we try to use xgcc
 # to compile anything (without linking).
-GCC_PASSES=xgcc$(exeext) cc1$(exeext) cpp0$(exeext) specs $(EXTRA_PASSES)
+GCC_PASSES=xgcc$(exeext) cc1$(exeext) specs $(EXTRA_PASSES)
 
 # List of things which should already be built whenever we try to use xgcc
 # to link anything.
@@ -753,7 +753,7 @@ STAGESTUFF = *$(objext) insn-flags.h insn-config.h insn-codes.h \
  genattr$(build_exeext) genopinit$(build_exeext) gengenrtl$(build_exeext) \
  gencheck$(build_exeext) genpreds$(build_exeext) genconstants$(build_exeext) \
  genrtl.c genrtl.h \
- xgcc$(exeext) cpp$(exeext) cc1$(exeext) cpp0$(exeext) $(EXTRA_PASSES) \
+ xgcc$(exeext) cpp$(exeext) cc1$(exeext) $(EXTRA_PASSES) \
  $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) cc1obj$(exeext) \
  enquire$(exeext) protoize$(exeext) unprotoize$(exeext) \
  specs collect2$(exeext) $(USE_COLLECT2) underscore.c tradcpp0$(exeext) \
@@ -1963,7 +1963,7 @@ PREPROCESSOR_DEFINES = \
   -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\"
 
 LIBCPP_OBJS =  cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o \
-               cpphash.o cpperror.o cppinit.o cppdefault.o \
+               cpphash.o cpperror.o cppinit.o cppdefault.o cppmain.o \
                hashtable.o line-map.o mkdeps.o prefix.o version.o mbchar.o
 
 LIBCPP_DEPS =  $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \
@@ -1976,10 +1976,6 @@ libcpp.a: $(LIBCPP_OBJS)
        $(AR) $(AR_FLAGS) libcpp.a $(LIBCPP_OBJS)
        -$(RANLIB) libcpp.a
 
-cpp0$(exeext): cppmain.o intl.o libcpp.a $(LIBDEPS)
-       $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cpp0$(exeext) cppmain.o \
-       intl.o libcpp.a $(LIBS)
-
 cppmain.o:  cppmain.c  $(CONFIG_H) $(CPPLIB_H) intl.h $(SYSTEM_H)
 
 cpperror.o: cpperror.c $(CONFIG_H) $(LIBCPP_DEPS)
@@ -2626,8 +2622,6 @@ install-common: native $(EXTRA_PARTS) lang.install-common
            $(INSTALL_DATA) SYSCALLS.c.X $(libsubdir)/SYSCALLS.c.X; \
            chmod a-x $(libsubdir)/SYSCALLS.c.X; \
        fi
-       -rm -f $(libsubdir)/cpp0$(exeext)
-       $(INSTALL_PROGRAM) cpp0$(exeext) $(libsubdir)/cpp0$(exeext)
        -rm -f $(libsubdir)/tradcpp0$(exeext)
        $(INSTALL_PROGRAM) tradcpp0$(exeext) $(libsubdir)/tradcpp0$(exeext)
 # Install gcov if it was compiled.
index 228f41b10fe9ed0b561ba7e712e36fdfe383b43a..0d5e1e810c59d8ecb631dd6b288436ecbcf5c1f9 100644 (file)
@@ -181,6 +181,9 @@ enum c_language_kind c_language;
 
 tree c_global_trees[CTI_MAX];
 
+/* Nonzero if prepreprocessing only.  */
+int flag_preprocess_only;
+
 /* Nonzero means don't recognize the non-ANSI builtin functions.  */
 
 int flag_no_builtin;
@@ -4141,6 +4144,13 @@ const char *
 c_common_init (filename)
      const char *filename;
 {
+  /* NULL is passed up to toplev.c and we exit quickly.  */
+  if (flag_preprocess_only)
+    {
+      cpp_preprocess_file (parse_in);
+      return NULL;
+    }
+
   /* Do this before initializing pragmas, as then cpplib's hash table
      has been set up.  */
   filename = init_c_lex (filename);
index 0e8fa954acef52039133d4815facc9ac33ee664e..3bd5ba0154766af2df90f7232e7069d2f3ea2d97 100644 (file)
@@ -372,6 +372,9 @@ extern void c_mark_lang_decl                    PARAMS ((struct c_lang_decl *));
 
 extern c_language_kind c_language;
 
+/* Nonzero if prepreprocessing only.  */
+extern int flag_preprocess_only;
+
 /* Nonzero means give string constants the type `const char *', rather
    than `char *'.  */
 
index 4e0dccd4b0ab07397eae0bd12166400533a6af12..a727b2707dd0cf990eb095fcb9298d06b2360fc9 100644 (file)
@@ -581,6 +581,8 @@ c_decode_option (argc, argv)
          flag_isoc99 = 1;
          flag_isoc94 = 1;
        }
+      else if (!strcmp (argstart, "c++98"))
+       ; /* Handled by cpplib.  */
       else
        error ("unknown C standard `%s'", argstart);
     }
@@ -685,6 +687,8 @@ c_decode_option (argc, argv)
       /* Only warn about unknown pragmas that are not in system headers.  */
       warn_unknown_pragmas = 1;
     }
+  else if (!strcmp (p, "-E"))
+    flag_preprocess_only = 1;
   else
     {
       size_t i;
index 6c0aef673f70fd5d7bd5617727853f166fcf0b0a..62fd84955b388d2cb38424dd5734920b5dc2430a 100644 (file)
@@ -217,6 +217,8 @@ c_objc_common_init (filename)
   c_init_decl_processing ();
 
   filename = c_common_init (filename);
+  if (filename == NULL)
+    return NULL;
 
   lang_unsafe_for_reeval = c_unsafe_for_reeval;
 
index c61b19185fec948c8957bc9dc9fda3693db0eb0b..df1bd5718ef670bf43b8f5989ccd4ec5a8d2bc72 100644 (file)
@@ -1,3 +1,9 @@
+2002-03-24  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * decl2.c (cxx_decode_option): Handle -E.
+       * lang-specs.h (default_compilers): Preprocess with cc1plus.
+       * lex.c (cxx_init): Exit quickly if c_common_init returns NULL.
+
 2002-03-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/6037
index 2dbb6636a98d552b578da7cb2b69a3a7418e8c9d..6763b4591ac99a15aecb426b8b9d57f413d3d012 100644 (file)
@@ -700,6 +700,8 @@ cxx_decode_option (argc, argv)
        }
       else return strings_processed;
     }
+  else if (!strcmp (p, "-E"))
+    flag_preprocess_only = 1;
   else if (!strcmp (p, "-ansi"))
     flag_no_nonansi_builtin = 1, flag_ansi = 1,
     flag_noniso_default_format_attributes = 0, flag_no_gnu_keywords = 1;
index e48bf7436f10bbaeebea2658f6bc56cf58b1fc61..771ab59963f763917d8f934b45ab4d8ccb4d0afd 100644 (file)
@@ -35,13 +35,13 @@ Boston, MA 02111-1307, USA.  */
   {"@c++",
    /* cc1plus has an integrated ISO C preprocessor.  We should invoke
       the external preprocessor if -save-temps is given.  */
-    "%{E|M|MM:cpp0 -lang-c++ %{!no-gcc:-D__GNUG__=%v1}\
+    "%{E|M|MM:cc1plus -E -lang-c++ %{!no-gcc:-D__GNUG__=%v1}\
        %{!Wno-deprecated:-D__DEPRECATED}\
        %{!fno-exceptions:-D__EXCEPTIONS}\
        -D__GXX_ABI_VERSION=100\
        %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)}\
      %{!E:%{!M:%{!MM:\
-       %{save-temps:cpp0 -lang-c++ \
+       %{save-temps:cc1plus -E -lang-c++ \
                    %{!no-gcc:-D__GNUG__=%v1}\
                            %{!Wno-deprecated:-D__DEPRECATED}\
                    %{!fno-exceptions:-D__EXCEPTIONS}\
index 593f3121474df51c3bcc5b37ffba56b82696cef5..f0c6389935d869f1c8c8c4b25250700193bfc4ac 100644 (file)
@@ -685,6 +685,8 @@ cxx_init (filename)
   interface_unknown = 1;
 
   filename = c_common_init (filename);
+  if (filename == NULL)
+    return NULL;
 
   init_cp_pragma ();
 
index 783b25835b06764850a6483691d0eab1b3ad83e8..e8298be1fae75d2bb23377155a2672d6b5ce26d4 100644 (file)
@@ -603,6 +603,9 @@ extern unsigned char *cpp_quote_string      PARAMS ((unsigned char *,
 extern int cpp_included        PARAMS ((cpp_reader *, const char *));
 extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int));
 
+/* In cppmain.c */
+extern void cpp_preprocess_file PARAMS ((cpp_reader *));
+
 #ifdef __cplusplus
 }
 #endif
index 99ca2deb90bc931a9f7ea1f343291b4a2bfbd262..0d427292662b409a9c398ef12aae10142a3bfdb1 100644 (file)
@@ -1,4 +1,4 @@
-/* CPP main program, using CPP Library.
+/* Preprocess only, using cpplib.
    Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Per Bothner, 1994-95.
@@ -38,10 +38,7 @@ struct printer
   unsigned char printed;       /* Nonzero if something output at line.  */
 };
 
-int main               PARAMS ((int, char **));
-static void general_init PARAMS ((const char *));
-static void do_preprocessing PARAMS ((int, char **));
-static void setup_callbacks PARAMS ((void));
+static void setup_callbacks PARAMS ((cpp_reader *));
 
 /* General output routines.  */
 static void scan_translation_unit PARAMS ((cpp_reader *));
@@ -64,74 +61,15 @@ static void cb_ident          PARAMS ((cpp_reader *, unsigned int,
 static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
 static void cb_def_pragma PARAMS ((cpp_reader *, unsigned int));
 
-const char *progname;          /* Needs to be global.  */
-static cpp_reader *pfile;      /* An opaque handle.  */
 static cpp_options *options;   /* Options of pfile.  */
 static struct printer print;
 
-int
-main (argc, argv)
-     int argc;
-     char **argv;
+/* Preprocess and output.  */
+void
+cpp_preprocess_file (pfile)
+     cpp_reader *pfile;
 {
-  general_init (argv[0]);
-
-  /* Construct a reader with default language GNU C89.  */
-  pfile = cpp_create_reader (CLK_GNUC89);
   options = cpp_get_options (pfile);
-  
-  do_preprocessing (argc, argv);
-
-  if (cpp_destroy (pfile))
-    return FATAL_EXIT_CODE;
-
-  return SUCCESS_EXIT_CODE;
-}
-
-/* Store the program name, and set the locale.  */
-static void
-general_init (argv0)
-     const char *argv0;
-{
-  progname = argv0 + strlen (argv0);
-
-  while (progname != argv0 && ! IS_DIR_SEPARATOR (progname[-1]))
-    --progname;
-
-  xmalloc_set_program_name (progname);
-
-  hex_init ();
-  gcc_init_libintl ();
-}
-
-/* Handle switches, preprocess and output.  */
-static void
-do_preprocessing (argc, argv)
-     int argc;
-     char **argv;
-{
-  int argi = 1;  /* Next argument to handle.  */
-
-  argi += cpp_handle_options (pfile, argc - argi , argv + argi);
-  if (CPP_FATAL_ERRORS (pfile))
-    return;
-
-  if (argi < argc)
-    {
-      cpp_fatal (pfile, "invalid option %s", argv[argi]);
-      return;
-    }
-
-  cpp_post_options (pfile);
-  if (CPP_FATAL_ERRORS (pfile))
-    return;
-
-  /* If cpp_handle_options saw --help or --version on the command
-     line, it will have set pfile->help_only to indicate this.  Exit
-     successfully.  [The library does not exit itself, because
-     e.g. cc1 needs to print its own --help message at this point.]  */
-  if (options->help_only)
-    return;
 
   /* Initialize the printer structure.  Setting print.line to -1 here
      is a trick to guarantee that the first token of the file will
@@ -156,7 +94,7 @@ do_preprocessing (argc, argv)
        }
     }
 
-  setup_callbacks ();
+  setup_callbacks (pfile);
 
   if (cpp_read_main_file (pfile, options->in_fname, NULL))
     {
@@ -172,21 +110,24 @@ do_preprocessing (argc, argv)
       /* -dM command line option.  Should this be in cpp_finish?  */
       if (options->dump_macros == dump_only)
        cpp_forall_identifiers (pfile, dump_macro, NULL);
-
-      cpp_finish (pfile);
     }
 
   /* Flush any pending output.  */
   if (print.printed)
     putc ('\n', print.outf);
 
-  if (ferror (print.outf) || fclose (print.outf))
-    cpp_notice_from_errno (pfile, options->out_fname);
+  /* Don't close stdout (dependencies have yet to be output).  */
+  if (print.outf != stdout)
+    {
+      if (ferror (print.outf) || fclose (print.outf))
+       cpp_notice_from_errno (pfile, options->out_fname);
+    }
 }
 
 /* Set up the callbacks as appropriate.  */
 static void
-setup_callbacks ()
+setup_callbacks (pfile)
+     cpp_reader *pfile;
 {
   cpp_callbacks *cb = cpp_get_callbacks (pfile);
 
index 5f8ada04c0a99f51fb172a4456120644188104a5..436b97baf27d80628c9abb66c6e99eccf30e02d0 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -658,11 +658,12 @@ static const char *link_libgcc_spec = LINK_LIBGCC_SPEC;
    appropriate -B options.  */
 
 static const char *trad_capable_cpp =
-"%{traditional|ftraditional|traditional-cpp:trad}cpp0";
+"%{traditional|ftraditional|traditional-cpp:tradcpp0}\
+ %{!traditional:%{!ftraditional:%{!traditional-cpp:cc1 -E}}}";
 
 static const char *cpp_unique_options =
 "%{C:%{!E:%eGNU C does not support -C without using -E}}\
- %{nostdinc*} %{C} %{v} %{I*} %{P} %{$} %I\
+ %{!Q:-quiet} %{nostdinc*} %{C} %{v} %{I*} %{P} %{$} %I\
  %{MD:-M -MF %W{!o: %b.d}%W{o*:%.d%*}}\
  %{MMD:-MM -MF %W{!o: %b.d}%W{o*:%.d%*}}\
  %{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
index c6e2eb8808cf9d433727d810ed998c11eef215c8..c6d1f9aa0e1250e65ada44c1e80c517bd97c179d 100644 (file)
@@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA.  */
       %{!E:%{!M:%{!MM:\
        %{traditional|ftraditional|traditional-cpp:\
 %eGNU Objective C no longer supports traditional compilation}\
-       %{save-temps:cpp0 -lang-objc %{ansi:-std=c89}\
+       %{save-temps:cc1obj -E -lang-objc %{ansi:-std=c89}\
          %(cpp_options) %b.mi \n\
            cc1obj -fpreprocessed %b.mi %(cc1_options) %{gen-decls}}\
        %{!save-temps:\
index 3cff998e40639f3b4b88c1360af14e1d6fda7c34..4ed6332ac7ffd16146ee198e04476c0ca56ca100 100644 (file)
@@ -779,6 +779,10 @@ main (argc, argv)
        no_standard_includes = 1;
        break;
 
+      case 'q':
+       /* Accept -quiet silently.  */
+       break;
+
       case '\0': /* JF handle '-' as file name meaning stdin or stdout */
        if (in_fname == NULL) {
          in_fname = "";