OSDN Git Service

add sparc64-*-solaris2 support just like sparcv9-*-solaris2
[pf3gnuchains/gcc-fork.git] / gcc / gcc.c
index ed86fa0..cbf62f8 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -2,22 +2,22 @@
    Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
    1999, 2000, 2001 Free Software Foundation, Inc.
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
 
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
 
 This paragraph is here to try to keep Sun CC from dying.
 The number of chars here seems crucial!!!!  */
@@ -185,7 +185,7 @@ static int print_help_list;
 
 static int verbose_flag;
 
-/* Flag indicating to print target specific command line options. */
+/* Flag indicating to print target specific command line options.  */
 
 static int target_help_flag;
 
@@ -289,7 +289,6 @@ static void clear_failure_queue PARAMS ((void));
 static int check_live_switch   PARAMS ((int, int));
 static const char *handle_braces PARAMS ((const char *));
 static char *save_string       PARAMS ((const char *, int));
-static void set_collect_gcc_options PARAMS ((void));
 static int do_spec_1           PARAMS ((const char *, int, const char *));
 static const char *find_file   PARAMS ((const char *));
 static int is_directory                PARAMS ((const char *, const char *, int));
@@ -313,6 +312,7 @@ static void process_command         PARAMS ((int, const char *const *));
 static int execute                     PARAMS ((void));
 static void clear_args                 PARAMS ((void));
 static void fatal_error                        PARAMS ((int));
+static void set_input                  PARAMS ((const char *));
 static void init_gcc_specs              PARAMS ((struct obstack *,
                                                 const char *,
                                                 const char *));
@@ -1205,7 +1205,7 @@ skip_whitespace (p)
 
 struct prefix_list
 {
-  char *prefix;               /* String to prepend to the path.  */
+  const char *prefix;        /* String to prepend to the path.  */
   struct prefix_list *next;   /* Next in linked list.  */
   int require_machine_suffix; /* Don't use without machine_suffix.  */
   /* 2 means try both machine_suffix and just_machine_suffix.  */
@@ -2285,8 +2285,12 @@ make_relative_prefix (progname, bin_prefix, prefix)
       GET_ENV_PATH_LIST (temp, "PATH");
       if (temp)
        {
-         char *startp, *endp;
-         char *nstore = (char *) alloca (strlen (temp) + strlen (progname) + 1);
+         char *startp, *endp, *nstore;
+         size_t prefixlen = strlen (temp) + 1;
+         if (prefixlen < 2)
+           prefixlen = 2;
+
+         nstore = (char *) alloca (prefixlen + strlen (progname) + 1);
 
          startp = endp = temp;
          while (1)
@@ -2607,7 +2611,7 @@ add_prefix (pprefix, prefix, component, priority, require_machine_suffix, warn)
     pprefix->max_len = len;
 
   pl = (struct prefix_list *) xmalloc (sizeof (struct prefix_list));
-  pl->prefix = save_string (prefix, len);
+  pl->prefix = prefix;
   pl->require_machine_suffix = require_machine_suffix;
   pl->used_flag_ptr = warn;
   pl->priority = priority;
@@ -3280,7 +3284,7 @@ process_command (argc, argv)
        }
       else if (strcmp (argv[i], "-ftarget-help") == 0)
         {
-          /* translate_options() has turned --target-help into -ftarget-help. */
+          /* translate_options() has turned --target-help into -ftarget-help.  */
           target_help_flag = 1;
 
           /* We will be passing a dummy file on to the sub-processes.  */
@@ -3573,9 +3577,9 @@ process_command (argc, argv)
                              have_c = 1;
                              break;
                            }
-                         else if (skip = SWITCH_TAKES_ARG (argv[j][1]))
+                         else if ((skip = SWITCH_TAKES_ARG (argv[j][1])))
                            j += skip - (argv[j][2] != 0);
-                         else if (skip = WORD_SWITCH_TAKES_ARG (argv[j] + 1))
+                         else if ((skip = WORD_SWITCH_TAKES_ARG (argv[j] + 1)))
                            j += skip;
                        }
                      j++;
@@ -3960,63 +3964,6 @@ process_command (argc, argv)
   switches[n_switches].part1 = 0;
   infiles[n_infiles].name = 0;
 }
-
-/* Store switches not filtered out but %{<S} in spec in COLLECT_GCC_OPTIONS
-   and place that in the environment.  */
-
-static void
-set_collect_gcc_options ()
-{
-  int i;
-  int first_time;
-
-  /* Build COLLECT_GCC_OPTIONS to have all of the options specified to
-     the compiler.  */
-  obstack_grow (&collect_obstack, "COLLECT_GCC_OPTIONS=",
-               sizeof ("COLLECT_GCC_OPTIONS=") - 1);
-
-  first_time = TRUE;
-  for (i = 0; (int) i < n_switches; i++)
-    {
-      const char *const *args;
-      const char *p, *q;
-      if (!first_time)
-       obstack_grow (&collect_obstack, " ", 1);
-
-      first_time = FALSE;
-
-      /* Ignore elided switches.  */
-      if (switches[i].live_cond == SWITCH_IGNORE)
-       continue;
-
-      obstack_grow (&collect_obstack, "'-", 2);
-      q = switches[i].part1;
-      while ((p = strchr (q, '\'')))
-       {
-         obstack_grow (&collect_obstack, q, p - q);
-         obstack_grow (&collect_obstack, "'\\''", 4);
-         q = ++p;
-       }
-      obstack_grow (&collect_obstack, q, strlen (q));
-      obstack_grow (&collect_obstack, "'", 1);
-
-      for (args = switches[i].args; args && *args; args++)
-       {
-         obstack_grow (&collect_obstack, " '", 2);
-         q = *args;
-         while ((p = strchr (q, '\'')))
-           {
-             obstack_grow (&collect_obstack, q, p - q);
-             obstack_grow (&collect_obstack, "'\\''", 4);
-             q = ++p;
-           }
-         obstack_grow (&collect_obstack, q, strlen (q));
-         obstack_grow (&collect_obstack, "'", 1);
-       }
-    }
-  obstack_grow (&collect_obstack, "\0", 1);
-  putenv (obstack_finish (&collect_obstack));
-}
 \f
 /* Process a spec string, accumulating and running commands.  */
 
@@ -4061,7 +4008,7 @@ static int this_is_library_file;
 static int input_from_pipe;
 
 /* Nonnull means substitute this for any suffix when outputting a switches
-   arguments. */
+   arguments.  */
 static const char *suffix_subst;
 
 /* Process the spec SPEC and run the commands specified therein.
@@ -4160,8 +4107,6 @@ do_spec_1 (spec, inswitch, soft_matched_part)
              argbuf_index--;
          }
 
-       set_collect_gcc_options ();
-
        if (argbuf_index > 0)
          {
            value = execute ();
@@ -5147,7 +5092,7 @@ next_member:
              else if (*q == '}')
                count--;
              else if (*q == 0)
-               abort ();
+               fatal ("Mismatched braces in specs");
              q++;
            }
          endbody = q;
@@ -5545,7 +5490,7 @@ is_directory (path1, path2, linker)
 /* Set up the various global variables to indicate that we're processing
    the input file named FILENAME.  */
 
-void
+static void
 set_input (filename)
      const char *filename;
 {
@@ -5718,6 +5663,52 @@ main (argc, argv)
 
   process_command (argc, argv);
 
+  {
+    int first_time;
+
+    /* Build COLLECT_GCC_OPTIONS to have all of the options specified to
+       the compiler.  */
+    obstack_grow (&collect_obstack, "COLLECT_GCC_OPTIONS=",
+                 sizeof ("COLLECT_GCC_OPTIONS=") - 1);
+
+    first_time = TRUE;
+    for (i = 0; (int) i < n_switches; i++)
+      {
+       const char *const *args;
+       const char *p, *q;
+       if (!first_time)
+         obstack_grow (&collect_obstack, " ", 1);
+
+       first_time = FALSE;
+       obstack_grow (&collect_obstack, "'-", 2);
+       q = switches[i].part1;
+       while ((p = strchr (q, '\'')))
+         {
+           obstack_grow (&collect_obstack, q, p - q);
+           obstack_grow (&collect_obstack, "'\\''", 4);
+           q = ++p;
+         }
+       obstack_grow (&collect_obstack, q, strlen (q));
+       obstack_grow (&collect_obstack, "'", 1);
+
+       for (args = switches[i].args; args && *args; args++)
+         {
+           obstack_grow (&collect_obstack, " '", 2);
+           q = *args;
+           while ((p = strchr (q, '\'')))
+             {
+               obstack_grow (&collect_obstack, q, p - q);
+               obstack_grow (&collect_obstack, "'\\''", 4);
+               q = ++p;
+             }
+           obstack_grow (&collect_obstack, q, strlen (q));
+           obstack_grow (&collect_obstack, "'", 1);
+         }
+      }
+    obstack_grow (&collect_obstack, "\0", 1);
+    putenv (obstack_finish (&collect_obstack));
+  }
+
   /* Initialize the vector of specs to just the default.
      This means one element containing 0s, as a terminator.  */
 
@@ -5892,7 +5883,7 @@ main (argc, argv)
       /* We do not exit here. Instead we have created a fake input file
          called 'target-dummy' which needs to be compiled, and we pass this
          on to the various sub-processes, along with the --target-help
-         switch. */
+         switch.  */
     }
 
   if (print_help_list)
@@ -6213,20 +6204,12 @@ fancy_abort ()
 void
 fatal VPARAMS ((const char *msgid, ...))
 {
-#ifndef ANSI_PROTOTYPES
-  const char *msgid;
-#endif
-  va_list ap;
-
-  VA_START (ap, msgid);
-
-#ifndef ANSI_PROTOTYPES
-  msgid = va_arg (ap, const char *);
-#endif
+  VA_OPEN (ap, msgid);
+  VA_FIXEDARG (ap, const char *, msgid);
 
   fprintf (stderr, "%s: ", programname);
   vfprintf (stderr, _(msgid), ap);
-  va_end (ap);
+  VA_CLOSE (ap);
   fprintf (stderr, "\n");
   delete_temp_files ();
   exit (1);
@@ -6235,20 +6218,12 @@ fatal VPARAMS ((const char *msgid, ...))
 void
 error VPARAMS ((const char *msgid, ...))
 {
-#ifndef ANSI_PROTOTYPES
-  const char *msgid;
-#endif
-  va_list ap;
-
-  VA_START (ap, msgid);
-
-#ifndef ANSI_PROTOTYPES
-  msgid = va_arg (ap, const char *);
-#endif
+  VA_OPEN (ap, msgid);
+  VA_FIXEDARG (ap, const char *, msgid);
 
   fprintf (stderr, "%s: ", programname);
   vfprintf (stderr, _(msgid), ap);
-  va_end (ap);
+  VA_CLOSE (ap);
 
   fprintf (stderr, "\n");
 }
@@ -6256,19 +6231,11 @@ error VPARAMS ((const char *msgid, ...))
 static void
 notice VPARAMS ((const char *msgid, ...))
 {
-#ifndef ANSI_PROTOTYPES
-  const char *msgid;
-#endif
-  va_list ap;
-
-  VA_START (ap, msgid);
-
-#ifndef ANSI_PROTOTYPES
-  msgid = va_arg (ap, const char *);
-#endif
+  VA_OPEN (ap, msgid);
+  VA_FIXEDARG (ap, const char *, msgid);
 
   vfprintf (stderr, _(msgid), ap);
-  va_end (ap);
+  VA_CLOSE (ap);
 }
 \f
 static void