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
This commit is contained in:
Neil Booth 2002-03-24 12:27:45 +00:00 committed by Neil Booth
parent 9e2da84c6a
commit aaf9320682
15 changed files with 84 additions and 88 deletions

View 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

View 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.

View 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);

View 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 *'. */

View 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;

View 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;

View 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

View 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;

View 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}\

View file

@ -685,6 +685,8 @@ cxx_init (filename)
interface_unknown = 1;
filename = c_common_init (filename);
if (filename == NULL)
return NULL;
init_cp_pragma ();

View 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

View 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);

View file

@ -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*}\

View 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:\

View 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 = "";