]> gcc.gnu.org Git - gcc.git/commitdiff
c-lang.c (c_post_options): Call cpp_post_options.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Sun, 7 Jan 2001 15:17:07 +0000 (15:17 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 7 Jan 2001 15:17:07 +0000 (15:17 +0000)
        * c-lang.c (c_post_options): Call cpp_post_options.
        * cppmain.c (main): Similarly.
        * fix-header.c (read_scan_file): Similarly.
        * cp/decl2.c (cxx_post_options): Similarly.
        * objc/objc-act.c (objc_post_options): Similarly.
        * cppinit.c (cpp_start_read): Move option consistency checks
        to cpp_post_options.  Don't call init_dependency_output.
        If needed, add default target and main file dependency.
        (OPT_MD, OPT_MMD): Remove.
        (OPT_MF): New.
        (cpp_handle_option): Update for OPT_* changes.
        (cpp_post_options): New.
        (init_dependency_output): Command line -MF overrides environment
        variables.  Don't set default target etc.  Suppress output
        if dependencies are going to stdout.
        (print_help): Update.
        * cpplib.h (cpp_post_options): New.
        * gcc.c (cpp_options): Update for -MD, -MMD, -MF.

From-SVN: r38777

gcc/ChangeLog
gcc/c-lang.c
gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cppinit.c
gcc/cpplib.h
gcc/cppmain.c
gcc/fix-header.c
gcc/gcc.c
gcc/objc/objc-act.c

index 2749261bebe4b8091bf32a2cfbcf133408b222d4..589a2b7719e47cbfc760fec296f85a8af40b409b 100644 (file)
@@ -1,3 +1,23 @@
+2001-01-07  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+        * c-lang.c (c_post_options): Call cpp_post_options.
+       * objc/objc-act.c (objc_post_options): Similarly.
+       * cppmain.c (main): Similarly.
+        * fix-header.c (read_scan_file): Similarly.
+        * cppinit.c (cpp_start_read): Move option consistency checks
+        to cpp_post_options.  Don't call init_dependency_output.
+        If needed, add default target and main file dependency.
+        (OPT_MD, OPT_MMD): Remove.
+        (OPT_MF): New.
+        (cpp_handle_option): Update for OPT_* changes.
+        (cpp_post_options): New.
+        (init_dependency_output): Command line -MF overrides environment
+        variables.  Don't set default target etc.  Suppress output
+        if dependencies are going to stdout.
+        (print_help): Update.
+        * cpplib.h (cpp_post_options): New.
+        * gcc.c (cpp_options): Update for -MD, -MMD, -MF.
+       
 Sun Jan  7 14:44:19 MET 2001  Jan Hubicka  <jh@suse.cz>
 
        * jump.c (comparison_dominates_p): Support unordered compares.
index 52f6015a49f91766c51fee686b27d36811efe6fa..5b08679c5e1087380f036db1bfea440cb3398b61 100644 (file)
@@ -47,6 +47,7 @@ struct lang_hooks lang_hooks = {c_post_options};
 static void
 c_post_options ()
 {
+  cpp_post_options (parse_in);
 }
 
 /* Each of the functions defined here
index d7a7a3b1480446e8c17a12bff3d9d09832b0a520..c0ca59daf3ae64d2140c0274fe5fe85688589cf3 100644 (file)
@@ -1,3 +1,7 @@
+2001-01-07  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+        * cp/decl2.c (cxx_post_options): Call cpp_post_options.
+
 2001-01-05  Nathan Sidwell  <nathan@codesourcery.com>
 
        * parse.y (template_datadef): Check for error_mark_node.
index 4daf5909d8b00ff67e7172867fd5795b2d4f8785..bac8a6d4f241e86c9025b1dbc1149fb9613e0088 100644 (file)
@@ -551,6 +551,7 @@ struct lang_hooks lang_hooks = {cxx_post_options};
 static void
 cxx_post_options ()
 {
+  cpp_post_options (parse_in);
 }
 
 /* Compare two option strings, pointed two by P1 and P2, for use with
index 38572258cb8f9692c74862b86965541a11e2b66d..85a351ca3e47a6307c5589ae5080b8d056b5b58c 100644 (file)
@@ -867,25 +867,6 @@ cpp_start_read (pfile, fname)
 {
   struct pending_option *p, *q;
 
-  /* -MG doesn't select the form of output and must be specified with one of
-     -M or -MM.  -MG doesn't make sense with -MD or -MMD since they don't
-     inhibit compilation.  */
-  if (CPP_OPTION (pfile, print_deps_missing_files)
-      && (CPP_OPTION (pfile, print_deps) == 0
-         || !CPP_OPTION (pfile, no_output)))
-    {
-      cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
-      return 0;
-    }
-
-  /* -Wtraditional is not useful in C++ mode.  */
-  if (CPP_OPTION (pfile, cplusplus))
-    CPP_OPTION (pfile, warn_traditional) = 0;
-
-  /* Set this if it hasn't been set already. */
-  if (CPP_OPTION (pfile, user_label_prefix) == NULL)
-    CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
-
   /* Set up the include search path now.  */
   if (! CPP_OPTION (pfile, no_standard_includes))
     init_standard_includes (pfile);
@@ -906,8 +887,6 @@ cpp_start_read (pfile, fname)
       fprintf (stderr, _("End of search list.\n"));
     }
 
-  /* Open the main input file.  This must be done early, so we have a
-     buffer to stand on.  */
   if (CPP_OPTION (pfile, in_fname) == NULL
       || *CPP_OPTION (pfile, in_fname) == 0)
     {
@@ -918,11 +897,20 @@ cpp_start_read (pfile, fname)
   if (CPP_OPTION (pfile, out_fname) == NULL)
     CPP_OPTION (pfile, out_fname) = "";
 
+  if (CPP_OPTION (pfile, print_deps))
+    {
+      /* Set the default target (if there is none already).  */
+      deps_add_default_target (pfile->deps, CPP_OPTION (pfile, in_fname));
+
+      if (CPP_OPTION (pfile, in_fname))
+       deps_add_dep (pfile->deps, CPP_OPTION (pfile, in_fname));
+    }
+
+  /* Open the main input file.  This must be done early, so we have a
+     buffer to stand on.  */
   if (!_cpp_read_file (pfile, fname))
     return 0;
 
-  init_dependency_output (pfile);
-
   /* Install __LINE__, etc.  */
   init_builtins (pfile);
 
@@ -1050,10 +1038,9 @@ new_pending_directive (pend, text, handler)
   DEF_OPT("H",                        0,      OPT_H)                          \
   DEF_OPT("I",                        no_dir, OPT_I)                          \
   DEF_OPT("M",                        0,      OPT_M)                          \
-  DEF_OPT("MD",                       no_fil, OPT_MD)                         \
+  DEF_OPT("MF",                       no_fil, OPT_MF)                         \
   DEF_OPT("MG",                       0,      OPT_MG)                         \
   DEF_OPT("MM",                       0,      OPT_MM)                         \
-  DEF_OPT("MMD",                      no_fil, OPT_MMD)                        \
   DEF_OPT("MP",                       0,      OPT_MP)                         \
   DEF_OPT("MQ",                       no_tgt, OPT_MQ)                         \
   DEF_OPT("MT",                       no_tgt, OPT_MT)                         \
@@ -1448,43 +1435,22 @@ cpp_handle_option (pfile, argc, argv)
                }
          }
          break;
-         /* The style of the choices here is a bit mixed.
-            The chosen scheme is a hybrid of keeping all options in one string
-            and specifying each option in a separate argument:
-            -M|-MM|-MD file|-MMD file [-MG].  An alternative is:
-            -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
-            -M[M][G][D file].  This is awkward to handle in specs, and is not
-            as extensible.  */
-         /* ??? -MG must be specified in addition to one of -M or -MM.
-            This can be relaxed in the future without breaking anything.
-            The converse isn't true.  */
-
-         /* -MG isn't valid with -MD or -MMD.  This is checked for later.  */
+
        case OPT_MG:
          CPP_OPTION (pfile, print_deps_missing_files) = 1;
          break;
        case OPT_M:
-       case OPT_MD:
+         CPP_OPTION (pfile, print_deps) = 2;
+         break;
        case OPT_MM:
-       case OPT_MMD:
-         if (opt_code == OPT_M || opt_code == OPT_MD)
-           CPP_OPTION (pfile, print_deps) = 2;
-         else
-           CPP_OPTION (pfile, print_deps) = 1;
-
-         /* For -MD and -MMD, write deps on file named by next arg.  */
-         /* For -M and -MM, write deps on standard output and
-            suppress the usual output.  */
-         if (opt_code == OPT_MD || opt_code == OPT_MMD)
-             CPP_OPTION (pfile, deps_file) = arg;
-         else
-             CPP_OPTION (pfile, no_output) = 1;
+         CPP_OPTION (pfile, print_deps) = 1;
          break;
-
-       case OPT_MP:
+       case OPT_MF:
+         CPP_OPTION (pfile, deps_file) = arg;
+         break;
+       case OPT_MP:
          CPP_OPTION (pfile, deps_phony_targets) = 1;
          break;
-
        case OPT_MQ:
        case OPT_MT:
          /* Add a target.  -MQ quotes for Make.  */
@@ -1680,9 +1646,37 @@ cpp_handle_options (pfile, argc, argv)
       if (strings_processed == 0)
        break;
     }
+
   return i;
 }
 
+/* Extra processing when all options are parsed, after all calls to
+   cpp_handle_option[s].  Consistency checks etc.  */
+void
+cpp_post_options (pfile)
+     cpp_reader *pfile;
+{
+  /* -Wtraditional is not useful in C++ mode.  */
+  if (CPP_OPTION (pfile, cplusplus))
+    CPP_OPTION (pfile, warn_traditional) = 0;
+
+  /* Set this if it hasn't been set already. */
+  if (CPP_OPTION (pfile, user_label_prefix) == NULL)
+    CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
+
+  /* We need to do this after option processing and before
+     cpp_start_read, as cppmain.c relies on the options->no_output to
+     set its callbacks correctly before calling cpp_start_read.  */
+  init_dependency_output (pfile);
+
+  /* -MG doesn't select the form of output and must be specified with
+     one of -M or -MM.  -MG doesn't make sense unless preprocessed
+     output (and compilation) is inhibited.  */
+  if (CPP_OPTION (pfile, print_deps_missing_files)
+      && CPP_OPTION (pfile, print_deps) == 0)
+    cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
+}
+
 /* Set up dependency-file output.  */
 static void
 init_dependency_output (pfile)
@@ -1722,15 +1716,17 @@ init_dependency_output (pfile)
       else
        output_file = spec;
 
-      CPP_OPTION (pfile, deps_file) = output_file;
+      /* Command line overrides environment variables.  */
+      if (CPP_OPTION (pfile, deps_file) == 0)
+       CPP_OPTION (pfile, deps_file) = output_file;
       CPP_OPTION (pfile, print_deps_append) = 1;
     }
 
-  /* Set the default target (if there is none already).  */
-  deps_add_default_target (pfile->deps, CPP_OPTION (pfile, in_fname));
-
-  if (CPP_OPTION (pfile, in_fname))
-    deps_add_dep (pfile->deps, CPP_OPTION (pfile, in_fname));
+  /* If dependencies go to standard output, we need to suppress
+     output.  The user may be requesting other stuff to stdout, with
+     -dM, -v etc.  We let them shoot themselves in the foot.  */
+  if (CPP_OPTION (pfile, deps_file) == 0)
+    CPP_OPTION (pfile, no_output) = 1;
 }
 
 static void
@@ -1799,9 +1795,13 @@ Switches:\n\
   fputs (_("\
   -M                        Generate make dependencies\n\
   -MM                       As -M, but ignore system header files\n\
-  -MD                       As -M, but put output in a .d file\n\
-  -MMD                      As -MD, but ignore system header files\n\
+  -MF <file>                Write dependency output to the given file\n\
   -MG                       Treat missing header file as generated files\n\
+"), stdout);
+  fputs (_("\
+  -MP                      Generate phony targets for all headers\n\
+  -MQ <target>              Add a MAKE-quoted target\n\
+  -MT <target>              Add an unquoted target\n\
   -g3                       Include #define and #undef directives in the output\n\
 "), stdout);
   fputs (_("\
index 7b53d0959c7aa97ff472c1e825bca332cac322e6..d5063b96c26122985a13dc7e69a2241f12e95427 100644 (file)
@@ -704,14 +704,25 @@ struct cpp_hashnode
   union tree_node *fe_value;           /* Front end value.  */
 };
 
+/* Call this first to get a handle to pass to other functions.  */
 extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
+
+/* Now call cpp_handle_option[s] to handle 1[or more] switches.  The
+   return value is the number of arguments used.  If
+   cpp_handle_options returns without using all arguments, it couldn't
+   understand the next switch.  When there are no switches left, you
+   must call cpp_post_options before calling cpp_start_read.  Only
+   after cpp_post_options are the contents of the cpp_options
+   structure reliable.  */
+extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
+extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
+extern void cpp_post_options PARAMS ((cpp_reader *));
+
 extern unsigned int cpp_token_len PARAMS ((const cpp_token *));
 extern unsigned char *cpp_token_as_text PARAMS ((cpp_reader *,
                                                 const cpp_token *));
 extern unsigned char *cpp_spell_token PARAMS ((cpp_reader *, const cpp_token *,
                                               unsigned char *));
-extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
-extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
 extern void cpp_register_pragma PARAMS ((cpp_reader *,
                                         const char *, const char *,
                                         void (*) PARAMS ((cpp_reader *))));
index 6fa158d284d5ae6a69ddfc87fc8499e8e95e4069..81fdac9ada3373a4f0bd8233206250e361eb7b05 100644 (file)
@@ -79,6 +79,7 @@ main (argc, argv)
   argi += cpp_handle_options (pfile, argc - argi , argv + argi);
   if (argi < argc && ! CPP_FATAL_ERRORS (pfile))
     cpp_fatal (pfile, "Invalid option %s", argv[argi]);
+  cpp_post_options (pfile);
   if (CPP_FATAL_ERRORS (pfile))
     return (FATAL_EXIT_CODE);
 
index 28cfe870974e8e6dfeccc365726155ca6e46749f..05485592d5f404c53c033207531d87b19ffc144b 100644 (file)
@@ -629,6 +629,7 @@ read_scan_file (in_fname, argc, argv)
   i = cpp_handle_options (scan_in, argc, argv);
   if (i < argc && ! CPP_FATAL_ERRORS (scan_in))
     cpp_fatal (scan_in, "Invalid option `%s'", argv[i]);
+  cpp_post_options (pfile);
   if (CPP_FATAL_ERRORS (scan_in))
     exit (FATAL_EXIT_CODE);
 
index 9d73608fa5a6f605b260661894807748abd14669..7a3c3640a467e976fa4c6f2416a3bd34998131de 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -586,7 +586,7 @@ static const char *cpp_options =
 "%{C:%{!E:%eGNU C does not support -C without using -E}}\
  %{std*} %{nostdinc*}\
  %{C} %{v} %{I*} %{P} %{$} %I\
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MP} %{MQ} %{MT}\
+ %{M} %{MM} %{MD:-M -MF %b.d} %{MMD:-MM -MF %b.d} %{MF} %{MG} %{MP} %{MQ} %{MT}\
  %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
  %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
  %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
index 06b0e8cbcf3d01f384f822e271dedf25342152ff..e2daab1651c27a74ce1ea4c0ab1ca665607f6384 100644 (file)
@@ -634,6 +634,7 @@ struct lang_hooks lang_hooks = {objc_post_options};
 static void
 objc_post_options ()
 {
+  cpp_post_options (parse_in);
 }
 
 /* Some platforms pass small structures through registers versus through
This page took 0.09507 seconds and 5 git commands to generate.