diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2002-03-24 12:27:45 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2002-03-24 12:27:45 +0000 |
commit | aaf932068245d39888fc1efd7f887a6d60de76e5 (patch) | |
tree | 273845d7b4dc2112d82db2e2e8f9f5239af6a84c /gcc/cppmain.c | |
parent | 9e2da84c6a68dc73dfdd7ec04652ab5db8df3994 (diff) | |
download | gcc-aaf932068245d39888fc1efd7f887a6d60de76e5.zip gcc-aaf932068245d39888fc1efd7f887a6d60de76e5.tar.gz gcc-aaf932068245d39888fc1efd7f887a6d60de76e5.tar.bz2 |
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.
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
Diffstat (limited to 'gcc/cppmain.c')
-rw-r--r-- | gcc/cppmain.c | 89 |
1 files changed, 15 insertions, 74 deletions
diff --git a/gcc/cppmain.c b/gcc/cppmain.c index 99ca2de..0d42729 100644 --- a/gcc/cppmain.c +++ b/gcc/cppmain.c @@ -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); |