]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cppspec.c (lang_specific_driver): Set is_cpp_driver.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Tue, 4 Dec 2001 22:26:16 +0000 (22:26 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Tue, 4 Dec 2001 22:26:16 +0000 (22:26 +0000)
* cppspec.c (lang_specific_driver): Set is_cpp_driver.
* gcc.c (process_command): Ensure the cpp driver sees
--help and --target-help, and that the help is printed
exactly once.

From-SVN: r47627

gcc/ChangeLog
gcc/cppspec.c
gcc/gcc.c

index 70064a1993f7226697813250b0ae34000b6149ff..b968b3bce1ab18633858c172f1119b457a8b03bb 100644 (file)
@@ -1,3 +1,10 @@
+2001-12-04  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * cppspec.c (lang_specific_driver): Set is_cpp_driver.
+       * gcc.c (process_command): Ensure the cpp driver sees
+       --help and --target-help, and that the help is printed
+       exactly once.
+
 2001-12-04  David Edelsohn  <edelsohn@gnu.org>
 
        * config/elfos.h (ASM_OUTPUT_INTERNAL_LABEL): Display count unsigned.
 2001-12-03  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        PR c/4988
-       * (process_command): Don't add a preprocessor option for
+       * gcc.c (process_command): Don't add a preprocessor option for
        --help and --target-help; cc1 is enough.
 
 2001-12-03  Neil Booth  <neil@daikokuya.demon.co.uk>
index 27a82360105b5cbb8483390620f863d65870636d..5f787d61c8dbbe8cfaa97a4b98c9386a78e6e048 100644 (file)
@@ -103,6 +103,9 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
   int i, j, quote = 0;
   const char **new_argv;
   int new_argc;
+  extern int is_cpp_driver;
+
+  is_cpp_driver = 1;
 
   /* First pass.  If we see an -S or -c, barf.  If we see an input file,
      turn off read_stdin.  If we see a second input file, it is actually
index cb2e47bc40b32a549e684677a7e29d58bcfcf539..b65cbb3c388b86f4925cebbdec7b185e12f0a243 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -143,6 +143,9 @@ static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
 
 #define MIN_FATAL_STATUS 1
 
+/* Flag set by cppspec.c to 1.  */
+int is_cpp_driver;
+
 /* Flag saying to pass the greatest exit code returned by a sub-process
    to the calling program.  */
 static int pass_exit_codes;
@@ -3310,6 +3313,9 @@ process_command (argc, argv)
          n_infiles++;
          n_switches++;
 
+         /* CPP driver cannot obtain switch from cc1_options.  */
+         if (is_cpp_driver)
+           add_preprocessor_option ("--help", 6);
          add_assembler_option ("--help", 6);
          add_linker_option ("--help", 6);
        }
@@ -3322,6 +3328,9 @@ process_command (argc, argv)
           n_infiles++;
           n_switches++;
 
+         /* CPP driver cannot obtain switch from cc1_options.  */
+         if (is_cpp_driver)
+           add_preprocessor_option ("--target-help", 13);
           add_assembler_option ("--target-help", 13);
           add_linker_option ("--target-help", 13);
         }
@@ -3792,41 +3801,10 @@ process_command (argc, argv)
        ;
       else if (! strcmp (argv[i], "-print-multi-directory"))
        ;
-      else if (strcmp (argv[i], "-ftarget-help") == 0)
-        {
-           /* Create a dummy input file, so that we can pass --target-help on to
-              the various sub-processes.  */
-           infiles[n_infiles].language = "c";
-           infiles[n_infiles++].name   = "target-dummy";
-
-           /* Preserve the --target-help switch so that it can be caught by
-              the cc1 spec string.  */
-           switches[n_switches].part1     = "--target-help";
-           switches[n_switches].args      = 0;
-           switches[n_switches].live_cond = SWITCH_OK;
-           switches[n_switches].validated = 0;
-
-           n_switches++;
-        }
-      else if (strcmp (argv[i], "-fhelp") == 0)
-       {
-         if (verbose_flag)
-           {
-             /* Create a dummy input file, so that we can pass --help on to
-                the various sub-processes.  */
-             infiles[n_infiles].language = "c";
-             infiles[n_infiles++].name   = "help-dummy";
-
-             /* Preserve the --help switch so that it can be caught by the
-                cc1 spec string.  */
-             switches[n_switches].part1     = "--help";
-             switches[n_switches].args      = 0;
-             switches[n_switches].live_cond = SWITCH_OK;
-             switches[n_switches].validated = 0;
-
-             n_switches++;
-           }
-       }
+      else if (! strcmp (argv[i], "-ftarget-help"))
+       ;
+      else if (! strcmp (argv[i], "-fhelp"))
+       ;
       else if (argv[i][0] == '+' && argv[i][1] == 'e')
        {
          /* Compensate for the +e options to the C++ front-end;
@@ -3989,6 +3967,37 @@ process_command (argc, argv)
   if (n_infiles == last_language_n_infiles && spec_lang != 0)
     error ("warning: `-x %s' after last input file has no effect", spec_lang);
 
+  /* Ensure we only invoke each subprocess once.  */
+  if (target_help_flag || print_help_list)
+    {
+      n_infiles = 1;
+
+      /* Create a dummy input file, so that we can pass --target-help on to
+        the various sub-processes.  */
+      infiles[0].language = "c";
+      infiles[0].name   = "help-dummy";
+
+      if (target_help_flag)
+       {
+         switches[n_switches].part1     = "--target-help";
+         switches[n_switches].args      = 0;
+         switches[n_switches].live_cond = SWITCH_OK;
+         switches[n_switches].validated = 0;
+
+         n_switches++;
+       }
+
+      if (print_help_list)
+       {
+         switches[n_switches].part1     = "--help";
+         switches[n_switches].args      = 0;
+         switches[n_switches].live_cond = SWITCH_OK;
+         switches[n_switches].validated = 0;
+
+         n_switches++;
+       }
+    }
+
   switches[n_switches].part1 = 0;
   infiles[n_infiles].name = 0;
 }