Commit 297441fd by Dave Brolley Committed by Dave Brolley

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
parent a0d85b75
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> 1998-06-10 Brendan Kehoe <brendan@cygnus.com>
* typeck.c (build_component_ref): Make sure FIELD has a lang_specific * typeck.c (build_component_ref): Make sure FIELD has a lang_specific
......
...@@ -2417,7 +2417,7 @@ extern void cat_namespace_levels PROTO((void)); ...@@ -2417,7 +2417,7 @@ extern void cat_namespace_levels PROTO((void));
/* in decl2.c */ /* in decl2.c */
extern int flag_assume_nonnull_objects; 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 tree grok_method_quals PROTO((tree, tree, tree));
extern void warn_if_unknown_interface PROTO((tree)); extern void warn_if_unknown_interface PROTO((tree));
extern tree grok_x_components PROTO((tree, tree)); extern tree grok_x_components PROTO((tree, tree));
......
...@@ -43,6 +43,13 @@ Boston, MA 02111-1307, USA. */ ...@@ -43,6 +43,13 @@ Boston, MA 02111-1307, USA. */
#include "dwarf2out.h" #include "dwarf2out.h"
#include "dwarfout.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 tree get_sentry PROTO((tree));
static void mark_vtable_entries PROTO((tree)); static void mark_vtable_entries PROTO((tree));
static void import_export_template 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[] = ...@@ -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. /* Decode the string P as a language-specific option.
Return 1 if it is recognized (and handle it); Return the number of strings consumed for a valid option.
return 0 if not recognized. */ Otherwise return 0. */
int int
lang_decode_option (p) lang_decode_option (argc, argv)
char *p; 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")) if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
flag_writable_strings = 1, flag_writable_strings = 1,
flag_this_is_variable = 1, flag_new_for_scope = 0; flag_this_is_variable = 1, flag_new_for_scope = 0;
...@@ -739,7 +763,7 @@ lang_decode_option (p) ...@@ -739,7 +763,7 @@ lang_decode_option (p)
else if (!strcmp (p, "overloaded-virtual")) else if (!strcmp (p, "overloaded-virtual"))
warn_overloaded_virtual = setting; warn_overloaded_virtual = setting;
else return 0; else return strings_processed;
} }
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,
...@@ -752,7 +776,7 @@ lang_decode_option (p) ...@@ -752,7 +776,7 @@ lang_decode_option (p)
spew_debug = 1; spew_debug = 1;
#endif #endif
else else
return 0; return strings_processed;
return 1; return 1;
} }
......
...@@ -28,6 +28,43 @@ Boston, MA 02111-1307, USA. */ ...@@ -28,6 +28,43 @@ Boston, MA 02111-1307, USA. */
{".c++", {"@c++"}}, {".c++", {"@c++"}},
{".C", {"@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\ {"cpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
%{C:%{!E:%eGNU C++ does not support -C without using -E}}\ %{C:%{!E:%eGNU C++ does not support -C without using -E}}\
%{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
...@@ -48,6 +85,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -48,6 +85,7 @@ Boston, MA 02111-1307, USA. */
%{!S:as %a %Y\ %{!S:as %a %Y\
%{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\ %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
%{!pipe:%g.s} %A\n }}}}"}}, %{!pipe:%g.s} %A\n }}}}"}},
#endif /* ! USE_CPPLIB */
{".ii", {"@c++-cpp-output"}}, {".ii", {"@c++-cpp-output"}},
{"@c++-cpp-output", {"@c++-cpp-output",
{"%{!M:%{!MM:%{!E:cc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\ {"%{!M:%{!MM:%{!E:cc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\
......
...@@ -401,10 +401,12 @@ lang_init_options () ...@@ -401,10 +401,12 @@ lang_init_options ()
void void
lang_init () lang_init ()
{ {
#if ! USE_CPPLIB
/* the beginning of the file is a new line; check for # */ /* the beginning of the file is a new line; check for # */
/* With luck, we discover the real source file's name from that /* With luck, we discover the real source file's name from that
and put it in input_filename. */ and put it in input_filename. */
put_back (check_newline ()); put_back (check_newline ());
#endif
if (flag_gnu_xref) GNU_xref_begin (input_filename); if (flag_gnu_xref) GNU_xref_begin (input_filename);
init_repo (input_filename); init_repo (input_filename);
} }
...@@ -473,13 +475,9 @@ init_parse (filename) ...@@ -473,13 +475,9 @@ init_parse (filename)
int i; int i;
#if USE_CPPLIB #if USE_CPPLIB
yy_cur = ""; yy_cur = "\n";
yy_lim = yy_cur; 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; parse_in.show_column = 1;
if (! cpp_start_read (&parse_in, filename)) if (! cpp_start_read (&parse_in, filename))
abort (); abort ();
......
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