aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDave Brolley <brolley@cygnus.com>1998-06-10 10:16:45 +0000
committerDave Brolley <brolley@gcc.gnu.org>1998-06-10 06:16:45 -0400
commit297441fd872faf63cfb9ed802975fc8ebcb69a91 (patch)
tree1479e8d4df9e9fbfc920dc58163b8ba6e5e63673 /gcc
parenta0d85b7572a80c023a0eef537a8c94e6af280c51 (diff)
downloadgcc-297441fd872faf63cfb9ed802975fc8ebcb69a91.zip
gcc-297441fd872faf63cfb9ed802975fc8ebcb69a91.tar.gz
gcc-297441fd872faf63cfb9ed802975fc8ebcb69a91.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl2.c36
-rw-r--r--gcc/cp/lang-specs.h38
-rw-r--r--gcc/cp/lex.c10
5 files changed, 82 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 72f629a..fc4dca7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6324bec..3e118d9 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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));
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b498599..b4b78fc 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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;
}
diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h
index 79b6f16..88ac4d8 100644
--- a/gcc/cp/lang-specs.h
+++ b/gcc/cp/lang-specs.h
@@ -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}\
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 9444d69..41a52fb 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -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 ();