Integrate cpplib into the C++ front end.

1998-06-10  Dave Brolley  <brolley@cygnus.com>
	* decl2.c (lang_decode_option): New argc/argv interface.
	* cp-tree.h (lang_decode_option): New argc/argv interface.
	* lang-specs.h (default_compilers): Only call cpp if -E, -M or -MM is
	specified for cpplib-enabled compilers.
	* lex.c (lang_init): Don't check_newline for cpplib.
	(init_parse): Don't initialize cpplib here.

From-SVN: r20408
This commit is contained in:
Dave Brolley 1998-06-10 10:16:45 +00:00 committed by Dave Brolley
parent a0d85b7572
commit 297441fd87
5 changed files with 82 additions and 13 deletions

View File

@ -1,3 +1,12 @@
1998-06-10 Dave Brolley <brolley@cygnus.com>
* decl2.c (lang_decode_option): New argc/argv interface.
* cp-tree.h (lang_decode_option): New argc/argv interface.
* lang-specs.h (default_compilers): Only call cpp if -E, -M or -MM is
specified for cpplib-enabled compilers.
* lex.c (lang_init): Don't check_newline for cpplib.
(init_parse): Don't initialize cpplib here.
1998-06-10 Brendan Kehoe <brendan@cygnus.com>
* typeck.c (build_component_ref): Make sure FIELD has a lang_specific

View File

@ -2417,7 +2417,7 @@ extern void cat_namespace_levels PROTO((void));
/* in decl2.c */
extern int flag_assume_nonnull_objects;
extern int lang_decode_option PROTO((char *));
extern int lang_decode_option PROTO((int, char **));
extern tree grok_method_quals PROTO((tree, tree, tree));
extern void warn_if_unknown_interface PROTO((tree));
extern tree grok_x_components PROTO((tree, tree));

View File

@ -43,6 +43,13 @@ Boston, MA 02111-1307, USA. */
#include "dwarf2out.h"
#include "dwarfout.h"
#if USE_CPPLIB
#include "cpplib.h"
extern cpp_reader parse_in;
extern cpp_options parse_options;
static int cpp_initialized;
#endif
static tree get_sentry PROTO((tree));
static void mark_vtable_entries PROTO((tree));
static void import_export_template PROTO((tree));
@ -492,13 +499,30 @@ static struct { char *string; int *variable; int on_value;} lang_f_options[] =
};
/* Decode the string P as a language-specific option.
Return 1 if it is recognized (and handle it);
return 0 if not recognized. */
Return the number of strings consumed for a valid option.
Otherwise return 0. */
int
lang_decode_option (p)
char *p;
lang_decode_option (argc, argv)
int argc;
char **argv;
{
int strings_processed;
char *p = argv[0];
#if USE_CPPLIB
if (! cpp_initialized)
{
cpp_reader_init (&parse_in);
parse_in.data = &parse_options;
cpp_options_init (&parse_options);
cpp_initialized = 1;
}
strings_processed = cpp_handle_option (&parse_in, argc, argv);
#else
strings_processed = 0;
#endif /* ! USE_CPPLIB */
if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
flag_writable_strings = 1,
flag_this_is_variable = 1, flag_new_for_scope = 0;
@ -739,7 +763,7 @@ lang_decode_option (p)
else if (!strcmp (p, "overloaded-virtual"))
warn_overloaded_virtual = setting;
else return 0;
else return strings_processed;
}
else if (!strcmp (p, "-ansi"))
flag_no_nonansi_builtin = 1, flag_ansi = 1,
@ -752,7 +776,7 @@ lang_decode_option (p)
spew_debug = 1;
#endif
else
return 0;
return strings_processed;
return 1;
}

View File

@ -28,6 +28,43 @@ Boston, MA 02111-1307, USA. */
{".c++", {"@c++"}},
{".C", {"@c++"}},
{"@c++",
#if USE_CPPLIB
{
#define CPP_FOR_CXX "cpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
%{C:%{!E:%eGNU C++ does not support -C without using -E}}\
%{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
-undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus -D__GNUC_MINOR__=%v2\
%{ansi:-trigraphs -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\
%{!fno-exceptions:-D__EXCEPTIONS}\
%{fhonor-std:-D__HONOR_STD} %{fnew-abi:-D__HONOR_STD}\
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\
%{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
%i %{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n"
"%{E:"CPP_FOR_CXX"}"
"%{!E:%{M:"CPP_FOR_CXX"}"
"%{!M:%{MM:"CPP_FOR_CXX"}"
"%{!MM:cc1plus %i %1 %2\
-lang-c++ %{nostdinc*} %{C} %{A*} %{I*} %{P} %I\
-undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus\
-D__GNUC_MINOR__=%v2\
%{ansi:-trigraphs -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\
%{!fno-exceptions:-D__EXCEPTIONS}\
%{fhonor-std:-D__HONOR_STD} %{fnew-abi:-D__HONOR_STD}\
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
%{trigraphs}\
%{!Q:-quiet} -dumpbase %b.cc %{d*} %{m*} %{a}\
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
%{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
%{v:-version} %{pg:-p} %{p}\
%{f*} %{+e*} %{aux-info*}\
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
%{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}}|\n\
%{!S:as %a %Y\
%{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
%{!pipe:%g.s} %A\n }}}}"}},
#undef CPP_FOR_CXX
#else /* ! USE_CPPLIB */
{"cpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
%{C:%{!E:%eGNU C++ does not support -C without using -E}}\
%{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
@ -48,6 +85,7 @@ Boston, MA 02111-1307, USA. */
%{!S:as %a %Y\
%{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
%{!pipe:%g.s} %A\n }}}}"}},
#endif /* ! USE_CPPLIB */
{".ii", {"@c++-cpp-output"}},
{"@c++-cpp-output",
{"%{!M:%{!MM:%{!E:cc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\

View File

@ -401,10 +401,12 @@ lang_init_options ()
void
lang_init ()
{
#if ! USE_CPPLIB
/* the beginning of the file is a new line; check for # */
/* With luck, we discover the real source file's name from that
and put it in input_filename. */
put_back (check_newline ());
#endif
if (flag_gnu_xref) GNU_xref_begin (input_filename);
init_repo (input_filename);
}
@ -473,13 +475,9 @@ init_parse (filename)
int i;
#if USE_CPPLIB
yy_cur = "";
yy_lim = yy_cur;
yy_cur = "\n";
yy_lim = yy_cur + 1;
cpp_reader_init (&parse_in);
parse_in.data = &parse_options;
cpp_options_init (&parse_options);
cpp_handle_options (&parse_in, 0, NULL); /* FIXME */
parse_in.show_column = 1;
if (! cpp_start_read (&parse_in, filename))
abort ();