]> gcc.gnu.org Git - gcc.git/commitdiff
Integrate cpplib into the C++ front end.
authorDave Brolley <brolley@cygnus.com>
Wed, 10 Jun 1998 10:16:45 +0000 (10:16 +0000)
committerDave Brolley <brolley@gcc.gnu.org>
Wed, 10 Jun 1998 10:16:45 +0000 (06:16 -0400)
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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl2.c
gcc/cp/lang-specs.h
gcc/cp/lex.c

index 72f629adfc6c2b244860296ae2b9259b7686e6d1..fc4dca71fbd318b6720e070b331508b4deb4cad8 100644 (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
index 6324becec6b650f3fdb8e35f098da24e210a63b4..3e118d91a5a5e33a4cb99a9e341e824860162259 100644 (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));
index b498599f6f1aad9fc4441f050129029eb6c25d69..b4b78fc69ade03eadc9501061d36f7bc41d43f1e 100644 (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;
 }
index 79b6f1669fc1e22d79fefd23ed55dbee9c25181a..88ac4d8873ec4e307d1d71a100b8ad8f921944d4 100644 (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}\
index 9444d695e19baf2e38971e2ea72a54585f2bd622..41a52fb77d029737612640ec620b3aa08c5374b9 100644 (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 ();
This page took 0.09538 seconds and 5 git commands to generate.