Commit aaf93206 by Neil Booth Committed by Neil Booth

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
parent 9e2da84c
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> 2002-03-24 Richard Henderson <rth@redhat.com>
PR optimization/5742 PR optimization/5742
......
...@@ -450,7 +450,7 @@ COMPILERS = cc1$(exeext) @all_compilers@ ...@@ -450,7 +450,7 @@ COMPILERS = cc1$(exeext) @all_compilers@
# List of things which should already be built whenever we try to use xgcc # List of things which should already be built whenever we try to use xgcc
# to compile anything (without linking). # 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 # List of things which should already be built whenever we try to use xgcc
# to link anything. # to link anything.
...@@ -753,7 +753,7 @@ STAGESTUFF = *$(objext) insn-flags.h insn-config.h insn-codes.h \ ...@@ -753,7 +753,7 @@ STAGESTUFF = *$(objext) insn-flags.h insn-config.h insn-codes.h \
genattr$(build_exeext) genopinit$(build_exeext) gengenrtl$(build_exeext) \ genattr$(build_exeext) genopinit$(build_exeext) gengenrtl$(build_exeext) \
gencheck$(build_exeext) genpreds$(build_exeext) genconstants$(build_exeext) \ gencheck$(build_exeext) genpreds$(build_exeext) genconstants$(build_exeext) \
genrtl.c genrtl.h \ 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) \ $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) cc1obj$(exeext) \
enquire$(exeext) protoize$(exeext) unprotoize$(exeext) \ enquire$(exeext) protoize$(exeext) unprotoize$(exeext) \
specs collect2$(exeext) $(USE_COLLECT2) underscore.c tradcpp0$(exeext) \ specs collect2$(exeext) $(USE_COLLECT2) underscore.c tradcpp0$(exeext) \
...@@ -1963,7 +1963,7 @@ PREPROCESSOR_DEFINES = \ ...@@ -1963,7 +1963,7 @@ PREPROCESSOR_DEFINES = \
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\"
LIBCPP_OBJS = cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o \ 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 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 \ LIBCPP_DEPS = $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \
...@@ -1976,10 +1976,6 @@ libcpp.a: $(LIBCPP_OBJS) ...@@ -1976,10 +1976,6 @@ libcpp.a: $(LIBCPP_OBJS)
$(AR) $(AR_FLAGS) libcpp.a $(LIBCPP_OBJS) $(AR) $(AR_FLAGS) libcpp.a $(LIBCPP_OBJS)
-$(RANLIB) libcpp.a -$(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) cppmain.o: cppmain.c $(CONFIG_H) $(CPPLIB_H) intl.h $(SYSTEM_H)
cpperror.o: cpperror.c $(CONFIG_H) $(LIBCPP_DEPS) cpperror.o: cpperror.c $(CONFIG_H) $(LIBCPP_DEPS)
...@@ -2626,8 +2622,6 @@ install-common: native $(EXTRA_PARTS) lang.install-common ...@@ -2626,8 +2622,6 @@ install-common: native $(EXTRA_PARTS) lang.install-common
$(INSTALL_DATA) SYSCALLS.c.X $(libsubdir)/SYSCALLS.c.X; \ $(INSTALL_DATA) SYSCALLS.c.X $(libsubdir)/SYSCALLS.c.X; \
chmod a-x $(libsubdir)/SYSCALLS.c.X; \ chmod a-x $(libsubdir)/SYSCALLS.c.X; \
fi fi
-rm -f $(libsubdir)/cpp0$(exeext)
$(INSTALL_PROGRAM) cpp0$(exeext) $(libsubdir)/cpp0$(exeext)
-rm -f $(libsubdir)/tradcpp0$(exeext) -rm -f $(libsubdir)/tradcpp0$(exeext)
$(INSTALL_PROGRAM) tradcpp0$(exeext) $(libsubdir)/tradcpp0$(exeext) $(INSTALL_PROGRAM) tradcpp0$(exeext) $(libsubdir)/tradcpp0$(exeext)
# Install gcov if it was compiled. # Install gcov if it was compiled.
......
...@@ -181,6 +181,9 @@ enum c_language_kind c_language; ...@@ -181,6 +181,9 @@ enum c_language_kind c_language;
tree c_global_trees[CTI_MAX]; tree c_global_trees[CTI_MAX];
/* Nonzero if prepreprocessing only. */
int flag_preprocess_only;
/* Nonzero means don't recognize the non-ANSI builtin functions. */ /* Nonzero means don't recognize the non-ANSI builtin functions. */
int flag_no_builtin; int flag_no_builtin;
...@@ -4141,6 +4144,13 @@ const char * ...@@ -4141,6 +4144,13 @@ const char *
c_common_init (filename) c_common_init (filename)
const char *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 /* Do this before initializing pragmas, as then cpplib's hash table
has been set up. */ has been set up. */
filename = init_c_lex (filename); filename = init_c_lex (filename);
......
...@@ -372,6 +372,9 @@ extern void c_mark_lang_decl PARAMS ((struct c_lang_decl *)); ...@@ -372,6 +372,9 @@ extern void c_mark_lang_decl PARAMS ((struct c_lang_decl *));
extern c_language_kind c_language; 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 /* Nonzero means give string constants the type `const char *', rather
than `char *'. */ than `char *'. */
......
...@@ -581,6 +581,8 @@ c_decode_option (argc, argv) ...@@ -581,6 +581,8 @@ c_decode_option (argc, argv)
flag_isoc99 = 1; flag_isoc99 = 1;
flag_isoc94 = 1; flag_isoc94 = 1;
} }
else if (!strcmp (argstart, "c++98"))
; /* Handled by cpplib. */
else else
error ("unknown C standard `%s'", argstart); error ("unknown C standard `%s'", argstart);
} }
...@@ -685,6 +687,8 @@ c_decode_option (argc, argv) ...@@ -685,6 +687,8 @@ c_decode_option (argc, argv)
/* Only warn about unknown pragmas that are not in system headers. */ /* Only warn about unknown pragmas that are not in system headers. */
warn_unknown_pragmas = 1; warn_unknown_pragmas = 1;
} }
else if (!strcmp (p, "-E"))
flag_preprocess_only = 1;
else else
{ {
size_t i; size_t i;
......
...@@ -217,6 +217,8 @@ c_objc_common_init (filename) ...@@ -217,6 +217,8 @@ c_objc_common_init (filename)
c_init_decl_processing (); c_init_decl_processing ();
filename = c_common_init (filename); filename = c_common_init (filename);
if (filename == NULL)
return NULL;
lang_unsafe_for_reeval = c_unsafe_for_reeval; lang_unsafe_for_reeval = c_unsafe_for_reeval;
......
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> 2002-03-23 Jakub Jelinek <jakub@redhat.com>
PR c++/6037 PR c++/6037
......
...@@ -700,6 +700,8 @@ cxx_decode_option (argc, argv) ...@@ -700,6 +700,8 @@ cxx_decode_option (argc, argv)
} }
else return strings_processed; else return strings_processed;
} }
else if (!strcmp (p, "-E"))
flag_preprocess_only = 1;
else if (!strcmp (p, "-ansi")) else if (!strcmp (p, "-ansi"))
flag_no_nonansi_builtin = 1, flag_ansi = 1, flag_no_nonansi_builtin = 1, flag_ansi = 1,
flag_noniso_default_format_attributes = 0, flag_no_gnu_keywords = 1; flag_noniso_default_format_attributes = 0, flag_no_gnu_keywords = 1;
......
...@@ -35,13 +35,13 @@ Boston, MA 02111-1307, USA. */ ...@@ -35,13 +35,13 @@ Boston, MA 02111-1307, USA. */
{"@c++", {"@c++",
/* cc1plus has an integrated ISO C preprocessor. We should invoke /* cc1plus has an integrated ISO C preprocessor. We should invoke
the external preprocessor if -save-temps is given. */ 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}\ %{!Wno-deprecated:-D__DEPRECATED}\
%{!fno-exceptions:-D__EXCEPTIONS}\ %{!fno-exceptions:-D__EXCEPTIONS}\
-D__GXX_ABI_VERSION=100\ -D__GXX_ABI_VERSION=100\
%{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)}\ %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)}\
%{!E:%{!M:%{!MM:\ %{!E:%{!M:%{!MM:\
%{save-temps:cpp0 -lang-c++ \ %{save-temps:cc1plus -E -lang-c++ \
%{!no-gcc:-D__GNUG__=%v1}\ %{!no-gcc:-D__GNUG__=%v1}\
%{!Wno-deprecated:-D__DEPRECATED}\ %{!Wno-deprecated:-D__DEPRECATED}\
%{!fno-exceptions:-D__EXCEPTIONS}\ %{!fno-exceptions:-D__EXCEPTIONS}\
......
...@@ -685,6 +685,8 @@ cxx_init (filename) ...@@ -685,6 +685,8 @@ cxx_init (filename)
interface_unknown = 1; interface_unknown = 1;
filename = c_common_init (filename); filename = c_common_init (filename);
if (filename == NULL)
return NULL;
init_cp_pragma (); init_cp_pragma ();
......
...@@ -603,6 +603,9 @@ extern unsigned char *cpp_quote_string PARAMS ((unsigned char *, ...@@ -603,6 +603,9 @@ extern unsigned char *cpp_quote_string PARAMS ((unsigned char *,
extern int cpp_included PARAMS ((cpp_reader *, const char *)); extern int cpp_included PARAMS ((cpp_reader *, const char *));
extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int)); extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int));
/* In cppmain.c */
extern void cpp_preprocess_file PARAMS ((cpp_reader *));
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
/* CPP main program, using CPP Library. /* Preprocess only, using cpplib.
Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002 Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by Per Bothner, 1994-95. Written by Per Bothner, 1994-95.
...@@ -38,10 +38,7 @@ struct printer ...@@ -38,10 +38,7 @@ struct printer
unsigned char printed; /* Nonzero if something output at line. */ unsigned char printed; /* Nonzero if something output at line. */
}; };
int main PARAMS ((int, char **)); static void setup_callbacks PARAMS ((cpp_reader *));
static void general_init PARAMS ((const char *));
static void do_preprocessing PARAMS ((int, char **));
static void setup_callbacks PARAMS ((void));
/* General output routines. */ /* General output routines. */
static void scan_translation_unit PARAMS ((cpp_reader *)); static void scan_translation_unit PARAMS ((cpp_reader *));
...@@ -64,75 +61,16 @@ static void cb_ident PARAMS ((cpp_reader *, unsigned int, ...@@ -64,75 +61,16 @@ static void cb_ident PARAMS ((cpp_reader *, unsigned int,
static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *)); static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
static void cb_def_pragma PARAMS ((cpp_reader *, unsigned int)); 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 cpp_options *options; /* Options of pfile. */
static struct printer print; static struct printer print;
int /* Preprocess and output. */
main (argc, argv) void
int argc; cpp_preprocess_file (pfile)
char **argv; 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); 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 /* Initialize the printer structure. Setting print.line to -1 here
is a trick to guarantee that the first token of the file will is a trick to guarantee that the first token of the file will
cause a linemarker to be output by maybe_print_line. */ cause a linemarker to be output by maybe_print_line. */
...@@ -156,7 +94,7 @@ do_preprocessing (argc, argv) ...@@ -156,7 +94,7 @@ do_preprocessing (argc, argv)
} }
} }
setup_callbacks (); setup_callbacks (pfile);
if (cpp_read_main_file (pfile, options->in_fname, NULL)) if (cpp_read_main_file (pfile, options->in_fname, NULL))
{ {
...@@ -172,21 +110,24 @@ do_preprocessing (argc, argv) ...@@ -172,21 +110,24 @@ do_preprocessing (argc, argv)
/* -dM command line option. Should this be in cpp_finish? */ /* -dM command line option. Should this be in cpp_finish? */
if (options->dump_macros == dump_only) if (options->dump_macros == dump_only)
cpp_forall_identifiers (pfile, dump_macro, NULL); cpp_forall_identifiers (pfile, dump_macro, NULL);
cpp_finish (pfile);
} }
/* Flush any pending output. */ /* Flush any pending output. */
if (print.printed) if (print.printed)
putc ('\n', print.outf); putc ('\n', print.outf);
/* Don't close stdout (dependencies have yet to be output). */
if (print.outf != stdout)
{
if (ferror (print.outf) || fclose (print.outf)) if (ferror (print.outf) || fclose (print.outf))
cpp_notice_from_errno (pfile, options->out_fname); cpp_notice_from_errno (pfile, options->out_fname);
}
} }
/* Set up the callbacks as appropriate. */ /* Set up the callbacks as appropriate. */
static void static void
setup_callbacks () setup_callbacks (pfile)
cpp_reader *pfile;
{ {
cpp_callbacks *cb = cpp_get_callbacks (pfile); cpp_callbacks *cb = cpp_get_callbacks (pfile);
......
...@@ -658,11 +658,12 @@ static const char *link_libgcc_spec = LINK_LIBGCC_SPEC; ...@@ -658,11 +658,12 @@ static const char *link_libgcc_spec = LINK_LIBGCC_SPEC;
appropriate -B options. */ appropriate -B options. */
static const char *trad_capable_cpp = 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 = static const char *cpp_unique_options =
"%{C:%{!E:%eGNU C does not support -C without using -E}}\ "%{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%*}}\ %{MD:-M -MF %W{!o: %b.d}%W{o*:%.d%*}}\
%{MMD:-MM -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*}\ %{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
......
...@@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA. */
%{!E:%{!M:%{!MM:\ %{!E:%{!M:%{!MM:\
%{traditional|ftraditional|traditional-cpp:\ %{traditional|ftraditional|traditional-cpp:\
%eGNU Objective C no longer supports traditional compilation}\ %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\ %(cpp_options) %b.mi \n\
cc1obj -fpreprocessed %b.mi %(cc1_options) %{gen-decls}}\ cc1obj -fpreprocessed %b.mi %(cc1_options) %{gen-decls}}\
%{!save-temps:\ %{!save-temps:\
......
...@@ -779,6 +779,10 @@ main (argc, argv) ...@@ -779,6 +779,10 @@ main (argc, argv)
no_standard_includes = 1; no_standard_includes = 1;
break; break;
case 'q':
/* Accept -quiet silently. */
break;
case '\0': /* JF handle '-' as file name meaning stdin or stdout */ case '\0': /* JF handle '-' as file name meaning stdin or stdout */
if (in_fname == NULL) { if (in_fname == NULL) {
in_fname = ""; in_fname = "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment