This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Make driver diagnostics interfaces follow diagnostic.c
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org, gdr at integrable-solutions dot net
- Date: Fri, 28 May 2010 17:03:41 +0000 (UTC)
- Subject: Make driver diagnostics interfaces follow diagnostic.c
This patch adjusts diagnostics interfaces in the driver to follow
those of diagnostic.c more closely, so making it easier to replace the
driver's diagnostic code with diagnostic.c.
Various functions are renamed to follow the names in diagnostic.c;
"notice" becomes "fnotice" with an explicit fp parameter. The main
change relates to the "error" function, which was used for all kinds
of diagnostics; now it is indeed a function for actual errors only and
will cause the driver to exit with failure status (but not
immediately; that's fatal_error). "warning" and "inform" functions
are added for other kinds of messages. This required deciding for
each existing "error" call whether it should indeed be an error or
another kind of message; I left the bulk as errors. That will cause
the driver to exit with error status in some cases where it didn't
before - at least, for unknown options (which fixes PR 15303; unknown
options that got passed from the driver to the compiler proper were
already errors from the compiler proper).
The expected subsequent diagnostics patches after this one are (a)
actually making the driver use diagnostic.c to replace its own
diagnostic code and (b) adjusting diagnostics to use GCC formats such
as %m, %< and %> which they will be able to use once using the common
code. Then I can get on to sharing more option processing code
between the driver and the compiler proper.
Bootstrapped with no regressions on x86_64-unknown-linux-gnu. OK to
commit?
2010-05-28 Joseph Myers <joseph@codesourcery.com>
PR driver/15303
* gcc.c (inform, warning, inform): New functions.
(fatal_ice): Rename to internal_error; change cmsgid parameter to
gmsgid. All callers changed.
(notice): Rename to fnotice; add parameter fp. All callers
changed.
(fatal_error): Rename to fatal_signal. All users changed.
(fatal): Rename to fatal_error; change cmsgid parameter to
gmsgid. All callers changed.
(process_command): Use warning instead of error for warnings.
(end_going_arg): Don't use _() around argument of error.
(do_spec_1): Use inform for message from %n specs. Use warning
instead of error for warnings.
(main): Use inform for comparison messages. Use warning for
message about unused linker input.
(error): Increment error_count. Print "error: ".
* gcc.h (fatal): Change to fatal_error.
(warning): Declare.
* config/darwin-driver.c (darwin_default_min_version): Use warning
instead of fprintf for warnings.
* cppspec.c (lang_specific_driver): Use fatal_error instead of
fatal.
cp:
2010-05-28 Joseph Myers <joseph@codesourcery.com>
* g++spec.c (lang_specific_driver): Use fatal_error instead of
fatal.
fortran:
2010-05-28 Joseph Myers <joseph@codesourcery.com>
* gfortranspec.c (append_arg, lang_specific_driver): Use
fatal_error instead of fatal. Use warning instead of fprintf for
warnings.
java:
2010-05-28 Joseph Myers <joseph@codesourcery.com>
* jvspec.c (lang_specific_driver): Use fatal_error instead of
fatal. Use warning instead of error for warnings.
Index: java/jvspec.c
===================================================================
--- java/jvspec.c (revision 159969)
+++ java/jvspec.c (working copy)
@@ -1,7 +1,7 @@
/* Specific flags and argument handling of the front-end of the
GNU compiler for the Java(TM) language.
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
This file is part of GCC.
@@ -400,33 +400,33 @@ lang_specific_driver (int *in_argc, cons
}
if (quote)
- fatal ("argument to '%s' missing\n", quote);
+ fatal_error ("argument to '%s' missing\n", quote);
if (saw_D && ! main_class_name)
- fatal ("can't specify '-D' without '--main'\n");
+ fatal_error ("can't specify '-D' without '--main'\n");
if (main_class_name && ! verify_class_name (main_class_name))
- fatal ("'%s' is not a valid class name", main_class_name);
+ fatal_error ("'%s' is not a valid class name", main_class_name);
num_args = argc + added;
if (saw_resource)
{
if (! saw_o)
- fatal ("--resource requires -o");
+ fatal_error ("--resource requires -o");
}
if (saw_C)
{
num_args += 3;
if (class_files_count + zip_files_count > 0)
{
- error ("warning: already-compiled .class files ignored with -C");
+ warning (0, "already-compiled .class files ignored with -C");
num_args -= class_files_count + zip_files_count;
class_files_count = 0;
zip_files_count = 0;
}
num_args += 2; /* For -o NONE. */
if (saw_o)
- fatal ("cannot specify both -C and -o");
+ fatal_error ("cannot specify both -C and -o");
}
if ((saw_o && java_files_count + class_files_count + zip_files_count > 1)
|| (saw_C && java_files_count > 1)
@@ -438,7 +438,7 @@ lang_specific_driver (int *in_argc, cons
{
filelist_filename = make_temp_file ("jx");
if (filelist_filename == NULL)
- fatal ("cannot create temporary file");
+ fatal_error ("cannot create temporary file");
record_temp_file (filelist_filename, ! saw_save_temps, 0);
filelist_file = fopen (filelist_filename, "w");
if (filelist_file == NULL)
@@ -460,7 +460,7 @@ lang_specific_driver (int *in_argc, cons
if (combine_inputs || indirect_files_count > 0)
num_args += 1; /* for "-ffilelist-file" */
if (combine_inputs && indirect_files_count > 0)
- fatal("using both @FILE with multiple files not implemented");
+ fatal_error ("using both @FILE with multiple files not implemented");
/* There's no point adding -shared-libgcc if we don't have a shared
libgcc. */
@@ -582,7 +582,7 @@ lang_specific_driver (int *in_argc, cons
if (strncmp (argv[i], "-fmain=", 7) == 0)
{
if (! will_link)
- fatal ("cannot specify 'main' class when not linking");
+ fatal_error ("cannot specify 'main' class when not linking");
--j;
continue;
}
Index: cppspec.c
===================================================================
--- cppspec.c (revision 159969)
+++ cppspec.c (working copy)
@@ -1,5 +1,5 @@
/* Specific flags and argument handling of the C preprocessor.
- Copyright (C) 1999, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2007, 2010 Free Software Foundation, Inc.
This file is part of GCC.
@@ -103,8 +103,8 @@ lang_specific_driver (int *in_argc, cons
need_E = 0;
else if (argv[i][1] == 'S' || argv[i][1] == 'c')
{
- fatal ("\"%s\" is not a valid option to the preprocessor",
- argv[i]);
+ fatal_error ("\"%s\" is not a valid option to the "
+ "preprocessor", argv[i]);
return;
}
else if (argv[i][1] == 'x')
@@ -125,7 +125,7 @@ lang_specific_driver (int *in_argc, cons
seen_input++;
if (seen_input == 3)
{
- fatal ("too many input files");
+ fatal_error ("too many input files");
return;
}
else if (seen_input == 2)
Index: gcc.c
===================================================================
--- gcc.c (revision 159969)
+++ gcc.c (working copy)
@@ -377,9 +377,11 @@ static int used_arg (const char *, int);
static int default_arg (const char *, int);
static void set_multilib_dir (void);
static void print_multilib_info (void);
+static void inform (int, const char *, ...) ATTRIBUTE_PRINTF_2;
static void perror_with_name (const char *);
-static void fatal_ice (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
-static void notice (const char *, ...) ATTRIBUTE_PRINTF_1;
+static void internal_error (const char *, ...)
+ ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+static void fnotice (FILE *, const char *, ...) ATTRIBUTE_PRINTF_2;
static void display_help (void);
static void add_preprocessor_option (const char *, int);
static void add_assembler_option (const char *, int);
@@ -388,7 +390,7 @@ static void process_command (int, const
static int execute (void);
static void alloc_args (void);
static void clear_args (void);
-static void fatal_error (int);
+static void fatal_signal (int);
#if defined(ENABLE_SHARED_LIBGCC) && !defined(REAL_LIBGCC_SPEC)
static void init_gcc_specs (struct obstack *, const char *, const char *,
const char *);
@@ -1795,7 +1797,7 @@ init_spec (void)
return; /* Already initialized. */
if (verbose_flag)
- notice ("Using built-in specs.\n");
+ fnotice (stderr, "Using built-in specs.\n");
#ifdef EXTRA_SPECS
extra_specs = XCNEWVEC (struct spec_list, ARRAY_SIZE (extra_specs_1));
@@ -1980,7 +1982,7 @@ set_spec (const char *name, const char *
#ifdef DEBUG_SPECS
if (verbose_flag)
- notice ("Setting spec %s to '%s'\n\n", name, *(sl->ptr_spec));
+ fnotice (stderr, "Setting spec %s to '%s'\n\n", name, *(sl->ptr_spec));
#endif
/* Free the old spec. */
@@ -2103,7 +2105,7 @@ load_specs (const char *filename)
char *specs_p;
if (verbose_flag)
- notice ("Reading specs from %s\n", filename);
+ fnotice (stderr, "Reading specs from %s\n", filename);
/* Open and stat the file. */
desc = open (filename, O_RDONLY, 0);
@@ -2199,8 +2201,9 @@ read_specs (const char *filename, int ma
p1++;
if (*p1++ != '<' || p[-2] != '>')
- fatal ("specs %%include syntax malformed after %ld characters",
- (long) (p1 - buffer + 1));
+ fatal_error ("specs %%include syntax malformed after "
+ "%ld characters",
+ (long) (p1 - buffer + 1));
p[-2] = '\0';
new_filename = find_a_file (&startfile_prefixes, p1, R_OK, true);
@@ -2218,15 +2221,16 @@ read_specs (const char *filename, int ma
p1++;
if (*p1++ != '<' || p[-2] != '>')
- fatal ("specs %%include syntax malformed after %ld characters",
- (long) (p1 - buffer + 1));
+ fatal_error ("specs %%include syntax malformed after "
+ "%ld characters",
+ (long) (p1 - buffer + 1));
p[-2] = '\0';
new_filename = find_a_file (&startfile_prefixes, p1, R_OK, true);
if (new_filename)
read_specs (new_filename, FALSE);
else if (verbose_flag)
- notice ("could not find specs file %s\n", p1);
+ fnotice (stderr, "could not find specs file %s\n", p1);
continue;
}
else if (!strncmp (p1, "%rename", sizeof "%rename" - 1)
@@ -2243,16 +2247,18 @@ read_specs (const char *filename, int ma
p1++;
if (! ISALPHA ((unsigned char) *p1))
- fatal ("specs %%rename syntax malformed after %ld characters",
- (long) (p1 - buffer));
+ fatal_error ("specs %%rename syntax malformed after "
+ "%ld characters",
+ (long) (p1 - buffer));
p2 = p1;
while (*p2 && !ISSPACE ((unsigned char) *p2))
p2++;
if (*p2 != ' ' && *p2 != '\t')
- fatal ("specs %%rename syntax malformed after %ld characters",
- (long) (p2 - buffer));
+ fatal_error ("specs %%rename syntax malformed after "
+ "%ld characters",
+ (long) (p2 - buffer));
name_len = p2 - p1;
*p2++ = '\0';
@@ -2260,8 +2266,9 @@ read_specs (const char *filename, int ma
p2++;
if (! ISALPHA ((unsigned char) *p2))
- fatal ("specs %%rename syntax malformed after %ld characters",
- (long) (p2 - buffer));
+ fatal_error ("specs %%rename syntax malformed after "
+ "%ld characters",
+ (long) (p2 - buffer));
/* Get new spec name. */
p3 = p2;
@@ -2269,8 +2276,9 @@ read_specs (const char *filename, int ma
p3++;
if (p3 != p - 1)
- fatal ("specs %%rename syntax malformed after %ld characters",
- (long) (p3 - buffer));
+ fatal_error ("specs %%rename syntax malformed after "
+ "%ld characters",
+ (long) (p3 - buffer));
*p3 = '\0';
for (sl = specs; sl; sl = sl->next)
@@ -2278,21 +2286,22 @@ read_specs (const char *filename, int ma
break;
if (!sl)
- fatal ("specs %s spec was not found to be renamed", p1);
+ fatal_error ("specs %s spec was not found to be renamed", p1);
if (strcmp (p1, p2) == 0)
continue;
for (newsl = specs; newsl; newsl = newsl->next)
if (strcmp (newsl->name, p2) == 0)
- fatal ("%s: attempt to rename spec '%s' to already defined spec '%s'",
+ fatal_error ("%s: attempt to rename spec '%s' to "
+ "already defined spec '%s'",
filename, p1, p2);
if (verbose_flag)
{
- notice ("rename spec %s to %s\n", p1, p2);
+ fnotice (stderr, "rename spec %s to %s\n", p1, p2);
#ifdef DEBUG_SPECS
- notice ("spec is '%s'\n\n", *(sl->ptr_spec));
+ fnotice (stderr, "spec is '%s'\n\n", *(sl->ptr_spec));
#endif
}
@@ -2305,8 +2314,8 @@ read_specs (const char *filename, int ma
continue;
}
else
- fatal ("specs unknown %% command after %ld characters",
- (long) (p1 - buffer));
+ fatal_error ("specs unknown %% command after %ld characters",
+ (long) (p1 - buffer));
}
/* Find the colon that should end the suffix. */
@@ -2316,8 +2325,8 @@ read_specs (const char *filename, int ma
/* The colon shouldn't be missing. */
if (*p1 != ':')
- fatal ("specs file malformed after %ld characters",
- (long) (p1 - buffer));
+ fatal_error ("specs file malformed after %ld characters",
+ (long) (p1 - buffer));
/* Skip back over trailing whitespace. */
p2 = p1;
@@ -2329,8 +2338,8 @@ read_specs (const char *filename, int ma
/* Find the next line. */
p = skip_whitespace (p1 + 1);
if (p[1] == 0)
- fatal ("specs file malformed after %ld characters",
- (long) (p - buffer));
+ fatal_error ("specs file malformed after %ld characters",
+ (long) (p - buffer));
p1 = p;
/* Find next blank line or end of string. */
@@ -2381,7 +2390,7 @@ read_specs (const char *filename, int ma
}
if (link_command_spec == 0)
- fatal ("spec file has no spec for linking");
+ fatal_error ("spec file has no spec for linking");
}
/* Record the names of temporary files we tell compilers to write,
@@ -2709,7 +2718,7 @@ static void
xputenv (const char *string)
{
if (verbose_flag)
- notice ("%s\n", string);
+ fnotice (stderr, "%s\n", string);
putenv (CONST_CAST (char *, string));
}
@@ -2910,7 +2919,7 @@ add_sysrooted_prefix (struct path_prefix
int require_machine_suffix, int os_multilib)
{
if (!IS_ABSOLUTE_PATH (prefix))
- fatal ("system path '%s' is not absolute", prefix);
+ fatal_error ("system path '%s' is not absolute", prefix);
if (target_system_root)
{
@@ -2982,7 +2991,7 @@ execute (void)
if (strcmp (argbuf[i], "|") == 0)
{ /* each command. */
#if defined (__MSDOS__) || defined (OS2) || defined (VMS)
- fatal ("-pipe not supported");
+ fatal_error ("-pipe not supported");
#endif
argbuf[i] = 0; /* termination of command args. */
commands[n_commands].prog = argbuf[i + 1];
@@ -3053,7 +3062,7 @@ execute (void)
return 0;
}
#ifdef DEBUG
- notice ("\nGo ahead? (y or n) ");
+ fnotice (stderr, "\nGo ahead? (y or n) ");
fflush (stderr);
i = getchar ();
if (i != '\n')
@@ -3114,7 +3123,7 @@ execute (void)
if (errmsg != NULL)
{
if (err == 0)
- fatal (errmsg);
+ fatal_error (errmsg);
else
{
errno = err;
@@ -3169,7 +3178,7 @@ execute (void)
}
else
#endif
- fatal_ice ("\
+ internal_error ("\
Internal error: %s (program %s)\n\
Please submit a full bug report.\n\
See %s for instructions.",
@@ -3197,7 +3206,8 @@ See %s for instructions.",
if (ut + st != 0)
{
if (report_times)
- notice ("# %s %.2f %.2f\n", commands[i].prog, ut, st);
+ fnotice (stderr, "# %s %.2f %.2f\n",
+ commands[i].prog, ut, st);
if (report_times_to_file)
{
@@ -3912,7 +3922,7 @@ process_command (int argc, const char **
else if (strcmp (argv[i], "-Xlinker") == 0)
{
if (i + 1 == argc)
- fatal ("argument to '-Xlinker' is missing");
+ fatal_error ("argument to '-Xlinker' is missing");
n_infiles++;
i++;
@@ -3920,21 +3930,21 @@ process_command (int argc, const char **
else if (strcmp (argv[i], "-Xpreprocessor") == 0)
{
if (i + 1 == argc)
- fatal ("argument to '-Xpreprocessor' is missing");
+ fatal_error ("argument to '-Xpreprocessor' is missing");
add_preprocessor_option (argv[i+1], strlen (argv[i+1]));
}
else if (strcmp (argv[i], "-Xassembler") == 0)
{
if (i + 1 == argc)
- fatal ("argument to '-Xassembler' is missing");
+ fatal_error ("argument to '-Xassembler' is missing");
add_assembler_option (argv[i+1], strlen (argv[i+1]));
}
else if (strcmp (argv[i], "-l") == 0)
{
if (i + 1 == argc)
- fatal ("argument to '-l' is missing");
+ fatal_error ("argument to '-l' is missing");
n_infiles++;
i++;
@@ -3955,7 +3965,7 @@ process_command (int argc, const char **
|| strcmp (argv[i]+12, "object") == 0)
save_temps_flag = SAVE_TEMPS_OBJ;
else
- fatal ("'%s' is an unknown -save-temps option", argv[i]);
+ fatal_error ("'%s' is an unknown -save-temps option", argv[i]);
}
else if (strcmp (argv[i], "-no-canonical-prefixes") == 0)
/* Already handled as a special case, so ignored here. */
@@ -3969,7 +3979,7 @@ process_command (int argc, const char **
{
struct user_specs *user = XNEW (struct user_specs);
if (++i >= argc)
- fatal ("argument to '-specs' is missing");
+ fatal_error ("argument to '-specs' is missing");
user->next = (struct user_specs *) 0;
user->filename = argv[i];
@@ -3983,7 +3993,7 @@ process_command (int argc, const char **
{
struct user_specs *user = XNEW (struct user_specs);
if (strlen (argv[i]) == 7)
- fatal ("argument to '-specs=' is missing");
+ fatal_error ("argument to '-specs=' is missing");
user->next = (struct user_specs *) 0;
user->filename = argv[i] + 7;
@@ -4011,7 +4021,7 @@ process_command (int argc, const char **
else if (strcmp (argv[i], "-wrapper") == 0)
{
if (++i >= argc)
- fatal ("argument to '-wrapper' is missing");
+ fatal_error ("argument to '-wrapper' is missing");
wrapper_string = argv[i];
n_switches++;
@@ -4039,7 +4049,7 @@ process_command (int argc, const char **
int len;
if (p[1] == 0 && i + 1 == argc)
- fatal ("argument to '-B' is missing");
+ fatal_error ("argument to '-B' is missing");
if (p[1] == 0)
value = argv[++i];
else
@@ -4216,7 +4226,7 @@ process_command (int argc, const char **
{
/* -save-temps overrides -pipe, so that temp files are produced */
if (save_temps_flag)
- error ("warning: -pipe ignored because -save-temps specified");
+ warning (0, "-pipe ignored because -save-temps specified");
use_pipes = 0;
}
@@ -4432,7 +4442,7 @@ process_command (int argc, const char **
if (c == 'x')
{
if (p[1] == 0 && i + 1 == argc)
- fatal ("argument to '-x' is missing");
+ fatal_error ("argument to '-x' is missing");
if (p[1] == 0)
spec_lang = argv[++i];
else
@@ -4460,7 +4470,7 @@ process_command (int argc, const char **
n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0);
}
if (i + n_args >= argc)
- fatal ("argument to '-%s' is missing", p);
+ fatal_error ("argument to '-%s' is missing", p);
switches[n_switches].args
= XNEWVEC (const char *, n_args + 1);
while (j < n_args)
@@ -4552,7 +4562,7 @@ process_command (int argc, const char **
}
if (n_infiles == last_language_n_infiles && spec_lang != 0)
- error ("warning: '-x %s' after last input file has no effect", spec_lang);
+ warning (0, "'-x %s' after last input file has no effect", spec_lang);
if (compare_debug == 2 || compare_debug == 3)
{
@@ -4715,7 +4725,7 @@ end_going_arg (void)
if (full_script_path == NULL)
{
- error (_("unable to locate default linker script '%s' in the library search paths"), string);
+ error ("unable to locate default linker script '%s' in the library search paths", string);
/* Script was not found on search path. */
return;
}
@@ -4903,7 +4913,7 @@ do_self_spec (const char *spec)
/* Each switch should start with '-'. */
if (c != '-')
- fatal ("switch '%s' does not start with '-'", argbuf[i]);
+ fatal_error ("switch '%s' does not start with '-'", argbuf[i]);
p++;
c = *p;
@@ -4927,7 +4937,7 @@ do_self_spec (const char *spec)
n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0);
}
if (i + n_args >= argbuf_index)
- fatal ("argument to '-%s' is missing", p);
+ fatal_error ("argument to '-%s' is missing", p);
sw->args
= XNEWVEC (const char *, n_args + 1);
while (j < n_args)
@@ -5019,20 +5029,20 @@ create_at_file (char **argv)
int status;
if (f == NULL)
- fatal ("could not open temporary response file %s",
- temp_file);
+ fatal_error ("could not open temporary response file %s",
+ temp_file);
status = writeargv (argv, f);
if (status)
- fatal ("could not write to temporary response file %s",
- temp_file);
+ fatal_error ("could not write to temporary response file %s",
+ temp_file);
status = fclose (f);
if (EOF == status)
- fatal ("could not close temporary response file %s",
- temp_file);
+ fatal_error ("could not close temporary response file %s",
+ temp_file);
store_arg (at_argument, 0, 0);
@@ -5133,7 +5143,7 @@ do_spec_1 (const char *spec, int inswitc
switch (c = *p++)
{
case 0:
- fatal ("spec '%s' invalid", spec);
+ fatal_error ("spec '%s' invalid", spec);
case 'b':
if (save_temps_length)
@@ -5209,7 +5219,7 @@ do_spec_1 (const char *spec, int inswitc
buf = (char *) alloca (p - q + 1);
strncpy (buf, q, p - q);
buf[p - q] = 0;
- notice ("%s\n", _(buf));
+ inform (0, "%s", _(buf));
if (*p)
p++;
}
@@ -5282,7 +5292,7 @@ do_spec_1 (const char *spec, int inswitc
p += 2;
/* We don't support extra suffix characters after %O. */
if (*p == '.' || ISALNUM ((unsigned char) *p))
- fatal ("spec '%s' has invalid '%%0%c'", spec, *p);
+ fatal_error ("spec '%s' has invalid '%%0%c'", spec, *p);
if (suffix_length == 0)
suffix = TARGET_OBJECT_SUFFIX;
else
@@ -5591,7 +5601,7 @@ do_spec_1 (const char *spec, int inswitc
int cur_index = argbuf_index;
/* Handle the {...} following the %W. */
if (*p != '{')
- fatal ("spec '%s' has invalid '%%W%c", spec, *p);
+ fatal_error ("spec '%s' has invalid '%%W%c", spec, *p);
p = handle_braces (p + 1);
if (p == 0)
return -1;
@@ -5611,7 +5621,7 @@ do_spec_1 (const char *spec, int inswitc
/* Skip past the option value and make a copy. */
if (*p != '{')
- fatal ("spec '%s' has invalid '%%x%c'", spec, *p);
+ fatal_error ("spec '%s' has invalid '%%x%c'", spec, *p);
while (*p++ != '}')
;
string = save_string (p1 + 1, p - p1 - 2);
@@ -5815,7 +5825,7 @@ do_spec_1 (const char *spec, int inswitc
%[...] modifies -D options the way %P does;
%(...) uses the spec unmodified. */
case '[':
- error ("warning: use of obsolete %%[ operator in specs");
+ warning (0, "use of obsolete %%[ operator in specs");
case '(':
{
const char *name = p;
@@ -5833,7 +5843,7 @@ do_spec_1 (const char *spec, int inswitc
{
name = *(sl->ptr_spec);
#ifdef DEBUG_SPECS
- notice ("Processing spec %c%s%c, which is '%s'\n",
+ fnotice (stderr, "Processing spec %c%s%c, which is '%s'\n",
c, sl->name, (c == '(') ? ')' : ']', name);
#endif
break;
@@ -5958,7 +5968,7 @@ eval_spec_function (const char *func, co
sf = lookup_spec_function (func);
if (sf == NULL)
- fatal ("unknown spec function '%s'", func);
+ fatal_error ("unknown spec function '%s'", func);
/* Push the spec processing context. */
save_argbuf_index = argbuf_index;
@@ -5978,7 +5988,7 @@ eval_spec_function (const char *func, co
alloc_args ();
if (do_spec_2 (args) < 0)
- fatal ("error in args to spec function '%s'", func);
+ fatal_error ("error in args to spec function '%s'", func);
/* argbuf_index is an index for the next argument to be inserted, and
so contains the count of the args already inserted. */
@@ -6027,10 +6037,10 @@ handle_spec_function (const char *p)
break;
/* Only allow [A-Za-z0-9], -, and _ in function names. */
if (!ISALNUM (*endp) && !(*endp == '-' || *endp == '_'))
- fatal ("malformed spec function name");
+ fatal_error ("malformed spec function name");
}
if (*endp != '(') /* ) */
- fatal ("no arguments for spec function");
+ fatal_error ("no arguments for spec function");
func = save_string (p, endp - p);
p = ++endp;
@@ -6049,7 +6059,7 @@ handle_spec_function (const char *p)
}
/* ( */
if (*endp != ')')
- fatal ("malformed spec function arguments");
+ fatal_error ("malformed spec function arguments");
args = save_string (p, endp - p);
p = ++endp;
@@ -6295,7 +6305,7 @@ handle_braces (const char *p)
return p;
invalid:
- fatal ("braced spec '%s' is invalid at '%c'", orig, *p);
+ fatal_error ("braced spec '%s' is invalid at '%c'", orig, *p);
#undef SKIP_WHITE
}
@@ -6383,7 +6393,7 @@ process_brace_body (const char *p, const
return p;
invalid:
- fatal ("braced spec body '%s' is invalid", body);
+ fatal_error ("braced spec body '%s' is invalid", body);
}
/* Return 0 iff switch number SWITCHNUM is obsoleted by a later switch
@@ -6600,7 +6610,7 @@ set_input (const char *filename)
/* On fatal signals, delete all the temporary files. */
static void
-fatal_error (int signum)
+fatal_signal (int signum)
{
signal (signum, SIG_DFL);
delete_failure_queue ();
@@ -6775,16 +6785,16 @@ main (int argc, char **argv)
gcc_init_libintl ();
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
- signal (SIGINT, fatal_error);
+ signal (SIGINT, fatal_signal);
#ifdef SIGHUP
if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
- signal (SIGHUP, fatal_error);
+ signal (SIGHUP, fatal_signal);
#endif
if (signal (SIGTERM, SIG_IGN) != SIG_IGN)
- signal (SIGTERM, fatal_error);
+ signal (SIGTERM, fatal_signal);
#ifdef SIGPIPE
if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
- signal (SIGPIPE, fatal_error);
+ signal (SIGPIPE, fatal_signal);
#endif
#ifdef SIGCHLD
/* We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will
@@ -7154,7 +7164,7 @@ main (int argc, char **argv)
else
/* The error status indicates that only one set of fixed
headers should be built. */
- fatal ("not configured with sysroot headers suffix");
+ fatal_error ("not configured with sysroot headers suffix");
}
if (print_help_list)
@@ -7200,8 +7210,8 @@ warranty; not even for MERCHANTABILITY o
int n;
const char *thrmod;
- notice ("Target: %s\n", spec_machine);
- notice ("Configured with: %s\n", configuration_arguments);
+ fnotice (stderr, "Target: %s\n", spec_machine);
+ fnotice (stderr, "Configured with: %s\n", configuration_arguments);
#ifdef THREAD_MODEL_SPEC
/* We could have defined THREAD_MODEL_SPEC to "%*" by default,
@@ -7215,7 +7225,7 @@ warranty; not even for MERCHANTABILITY o
thrmod = thread_model;
#endif
- notice ("Thread model: %s\n", thrmod);
+ fnotice (stderr, "Thread model: %s\n", thrmod);
/* compiler_version is truncated at the first space when initialized
from version string, so truncate version_string at the first space
@@ -7226,17 +7236,18 @@ warranty; not even for MERCHANTABILITY o
if (! strncmp (version_string, compiler_version, n)
&& compiler_version[n] == 0)
- notice ("gcc version %s %s\n", version_string, pkgversion_string);
+ fnotice (stderr, "gcc version %s %s\n", version_string,
+ pkgversion_string);
else
- notice ("gcc driver version %s %sexecuting gcc version %s\n",
- version_string, pkgversion_string, compiler_version);
+ fnotice (stderr, "gcc driver version %s %sexecuting gcc version %s\n",
+ version_string, pkgversion_string, compiler_version);
if (n_infiles == 0)
return (0);
}
if (n_infiles == added_libraries)
- fatal ("no input files");
+ fatal_error ("no input files");
/* Make a place to record the compiler output file names
that correspond to the input files. */
@@ -7285,7 +7296,7 @@ warranty; not even for MERCHANTABILITY o
}
if (!combine_inputs && have_c && have_o && lang_n_infiles > 1)
- fatal ("cannot specify -o with -c, -S or -E with multiple files");
+ fatal_error ("cannot specify -o with -c, -S or -E with multiple files");
if (combine_flag && save_temps_flag)
{
@@ -7319,7 +7330,8 @@ warranty; not even for MERCHANTABILITY o
value = do_spec (input_file_compiler->spec);
infiles[i].preprocessed = true;
if (!have_o_argbuf_index)
- fatal ("spec '%s' is invalid", input_file_compiler->spec);
+ fatal_error ("spec '%s' is invalid",
+ input_file_compiler->spec);
infiles[i].name = argbuf[have_o_argbuf_index];
infiles[i].incompiler
= lookup_compiler (infiles[i].name,
@@ -7397,7 +7409,7 @@ warranty; not even for MERCHANTABILITY o
else if (compare_debug && debug_check_temp_file[0])
{
if (verbose_flag)
- error ("Recompiling with -fcompare-debug");
+ inform (0, "recompiling with -fcompare-debug");
compare_debug = -compare_debug;
n_switches = n_switches_debug_check[1];
@@ -7420,7 +7432,7 @@ warranty; not even for MERCHANTABILITY o
debug_check_temp_file[1]));
if (verbose_flag)
- error ("Comparing final insns dumps");
+ inform (0, "comparing final insns dumps");
if (compare_files (debug_check_temp_file))
this_file_error = 1;
@@ -7510,12 +7522,12 @@ warranty; not even for MERCHANTABILITY o
"liblto_plugin.so", R_OK,
false);
if (!linker_plugin_file_spec)
- fatal ("-fuse-linker-plugin, but liblto_plugin.so not found");
+ fatal_error ("-fuse-linker-plugin, but liblto_plugin.so not found");
lto_libgcc_spec = find_a_file (&startfile_prefixes, "libgcc.a",
R_OK, true);
if (!lto_libgcc_spec)
- fatal ("could not find libgcc.a");
+ fatal_error ("could not find libgcc.a");
}
lto_gcc_spec = argv[0];
@@ -7544,8 +7556,8 @@ warranty; not even for MERCHANTABILITY o
for (i = 0; (int) i < n_infiles; i++)
if (explicit_link_files[i]
&& !(infiles[i].language && infiles[i].language[0] == '*'))
- error ("%s: linker input file unused because linking not done",
- outfiles[i]);
+ warning (0, "%s: linker input file unused because linking not done",
+ outfiles[i]);
/* Delete some or all of the temporary files we made. */
@@ -7663,20 +7675,20 @@ perror_with_name (const char *name)
void
fancy_abort (const char *file, int line, const char *func)
{
- fatal_ice ("internal gcc abort in %s, at %s:%d", func, file, line);
+ internal_error ("internal gcc abort in %s, at %s:%d", func, file, line);
}
/* Output an error message and exit. */
void
-fatal_ice (const char *cmsgid, ...)
+internal_error (const char *gmsgid, ...)
{
va_list ap;
- va_start (ap, cmsgid);
+ va_start (ap, gmsgid);
fprintf (stderr, "%s: ", programname);
- vfprintf (stderr, _(cmsgid), ap);
+ vfprintf (stderr, _(gmsgid), ap);
va_end (ap);
fprintf (stderr, "\n");
delete_temp_files ();
@@ -7684,14 +7696,14 @@ fatal_ice (const char *cmsgid, ...)
}
void
-fatal (const char *cmsgid, ...)
+fatal_error (const char *gmsgid, ...)
{
va_list ap;
- va_start (ap, cmsgid);
+ va_start (ap, gmsgid);
fprintf (stderr, "%s: ", programname);
- vfprintf (stderr, _(cmsgid), ap);
+ vfprintf (stderr, _(gmsgid), ap);
va_end (ap);
fprintf (stderr, "\n");
delete_temp_files ();
@@ -7710,7 +7722,21 @@ error (const char *gmsgid, ...)
va_list ap;
va_start (ap, gmsgid);
- fprintf (stderr, "%s: ", programname);
+ error_count++;
+ fprintf (stderr, "%s: %s: ", programname, _("error: "));
+ vfprintf (stderr, _(gmsgid), ap);
+ va_end (ap);
+
+ fprintf (stderr, "\n");
+}
+
+void
+warning (int dummy ATTRIBUTE_UNUSED, const char *gmsgid, ...)
+{
+ va_list ap;
+
+ va_start (ap, gmsgid);
+ fprintf (stderr, "%s: %s: ", programname, _("warning: "));
vfprintf (stderr, _(gmsgid), ap);
va_end (ap);
@@ -7718,12 +7744,25 @@ error (const char *gmsgid, ...)
}
static void
-notice (const char *cmsgid, ...)
+inform (int dummy ATTRIBUTE_UNUSED, const char *gmsgid, ...)
+{
+ va_list ap;
+
+ va_start (ap, gmsgid);
+ fprintf (stderr, "%s: %s: ", programname, _("note: "));
+ vfprintf (stderr, _(gmsgid), ap);
+ va_end (ap);
+
+ fprintf (stderr, "\n");
+}
+
+static void
+fnotice (FILE *fp, const char *cmsgid, ...)
{
va_list ap;
va_start (ap, cmsgid);
- vfprintf (stderr, _(cmsgid), ap);
+ vfprintf (fp, _(cmsgid), ap);
va_end (ap);
}
@@ -7879,7 +7918,8 @@ used_arg (const char *p, int len)
if (*q == '\0')
{
invalid_matches:
- fatal ("multilib spec '%s' is invalid", multilib_matches);
+ fatal_error ("multilib spec '%s' is invalid",
+ multilib_matches);
}
q++;
}
@@ -8070,8 +8110,8 @@ set_multilib_dir (void)
if (*p == '\0')
{
invalid_exclusions:
- fatal ("multilib exclusions '%s' is invalid",
- multilib_exclusions);
+ fatal_error ("multilib exclusions '%s' is invalid",
+ multilib_exclusions);
}
if (! ok)
@@ -8128,8 +8168,8 @@ set_multilib_dir (void)
if (*p == '\0')
{
invalid_select:
- fatal ("multilib select '%s' is invalid",
- multilib_select);
+ fatal_error ("multilib select '%s' is invalid",
+ multilib_select);
}
++p;
}
@@ -8269,7 +8309,7 @@ print_multilib_info (void)
if (*p == '\0')
{
invalid_select:
- fatal ("multilib select '%s' is invalid", multilib_select);
+ fatal_error ("multilib select '%s' is invalid", multilib_select);
}
++p;
@@ -8307,8 +8347,8 @@ print_multilib_info (void)
if (*e == '\0')
{
invalid_exclusion:
- fatal ("multilib exclusion '%s' is invalid",
- multilib_exclusions);
+ fatal_error ("multilib exclusion '%s' is invalid",
+ multilib_exclusions);
}
if (! m)
@@ -8513,7 +8553,7 @@ getenv_spec_function (int argc, const ch
value = getenv (argv[0]);
if (!value)
- fatal ("environment variable \"%s\" not defined", argv[0]);
+ fatal_error ("environment variable \"%s\" not defined", argv[0]);
/* We have to escape every character of the environment variable so
they are not interpreted as active spec characters. A
@@ -8604,12 +8644,12 @@ compare_version_strings (const char *v1,
abort ();
rresult = regexec (&r, v1, 0, NULL, 0);
if (rresult == REG_NOMATCH)
- fatal ("invalid version number `%s'", v1);
+ fatal_error ("invalid version number `%s'", v1);
else if (rresult != 0)
abort ();
rresult = regexec (&r, v2, 0, NULL, 0);
if (rresult == REG_NOMATCH)
- fatal ("invalid version number `%s'", v2);
+ fatal_error ("invalid version number `%s'", v2);
else if (rresult != 0)
abort ();
@@ -8652,13 +8692,13 @@ version_compare_spec_function (int argc,
bool result;
if (argc < 3)
- fatal ("too few arguments to %%:version-compare");
+ fatal_error ("too few arguments to %%:version-compare");
if (argv[0][0] == '\0')
abort ();
if ((argv[0][1] == '<' || argv[0][1] == '>') && argv[0][0] != '!')
nargs = 2;
if (argc != nargs + 3)
- fatal ("too many arguments to %%:version-compare");
+ fatal_error ("too many arguments to %%:version-compare");
switch_len = strlen (argv[nargs + 1]);
for (i = 0; i < n_switches; i++)
@@ -8699,7 +8739,7 @@ version_compare_spec_function (int argc,
break;
default:
- fatal ("unknown operator '%s' in %%:version-compare", argv[0]);
+ fatal_error ("unknown operator '%s' in %%:version-compare", argv[0]);
}
if (! result)
return NULL;
@@ -8796,7 +8836,7 @@ compare_debug_dump_opt_spec_function (in
static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
if (arg != 0)
- fatal ("too many arguments to %%:compare-debug-dump-opt");
+ fatal_error ("too many arguments to %%:compare-debug-dump-opt");
do_spec_2 ("%{fdump-final-insns=*:%*}");
do_spec_1 (" ", 0, NULL);
@@ -8863,7 +8903,7 @@ compare_debug_self_opt_spec_function (in
const char **argv ATTRIBUTE_UNUSED)
{
if (arg != 0)
- fatal ("too many arguments to %%:compare-debug-self-opt");
+ fatal_error ("too many arguments to %%:compare-debug-self-opt");
if (compare_debug >= 0)
return NULL;
@@ -8898,17 +8938,18 @@ compare_debug_auxbase_opt_spec_function
int len;
if (arg == 0)
- fatal ("too few arguments to %%:compare-debug-auxbase-opt");
+ fatal_error ("too few arguments to %%:compare-debug-auxbase-opt");
if (arg != 1)
- fatal ("too many arguments to %%:compare-debug-auxbase-opt");
+ fatal_error ("too many arguments to %%:compare-debug-auxbase-opt");
if (compare_debug >= 0)
return NULL;
len = strlen (argv[0]);
if (len < 3 || strcmp (argv[0] + len - 3, ".gk") != 0)
- fatal ("argument to %%:compare-debug-auxbase-opt does not end in .gk");
+ fatal_error ("argument to %%:compare-debug-auxbase-opt "
+ "does not end in .gk");
if (debug_auxbase_opt)
return debug_auxbase_opt;
Index: gcc.h
===================================================================
--- gcc.h (revision 159969)
+++ gcc.h (working copy)
@@ -59,8 +59,10 @@ struct spec_function
/* These are exported by gcc.c. */
extern int do_spec (const char *);
extern void record_temp_file (const char *, int, int);
-extern void fatal (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+extern void fatal_error (const char *, ...)
+ ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
extern void error (const char *, ...) ATTRIBUTE_PRINTF_1;
+extern void warning (int, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void pfatal_with_name (const char *) ATTRIBUTE_NORETURN;
extern void set_input (const char *);
Index: cp/g++spec.c
===================================================================
--- cp/g++spec.c (revision 159969)
+++ cp/g++spec.c (working copy)
@@ -1,6 +1,6 @@
/* Specific flags and argument handling of the C++ front end.
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GCC.
@@ -258,7 +258,7 @@ lang_specific_driver (int *in_argc, cons
}
if (quote)
- fatal ("argument to '%s' missing\n", quote);
+ fatal_error ("argument to '%s' missing\n", quote);
/* There's no point adding -shared-libgcc if we don't have a shared
libgcc. */
Index: fortran/gfortranspec.c
===================================================================
--- fortran/gfortranspec.c (revision 159969)
+++ fortran/gfortranspec.c (working copy)
@@ -244,7 +244,7 @@ append_arg (const char *arg)
}
if (g77_newargc == newargsize)
- fatal ("overflowed output arg list for '%s'", arg);
+ fatal_error ("overflowed output arg list for '%s'", arg);
g77_newargv[g77_newargc++] = arg;
}
@@ -402,11 +402,11 @@ For more information about these matters
if (i + skip < argc)
i += skip;
else
- fatal ("argument to '%s' missing", argv[i]);
+ fatal_error ("argument to '%s' missing", argv[i]);
}
if ((n_outfiles != 0) && (n_infiles == 0))
- fatal ("no input files; unwilling to write output files");
+ fatal_error ("no input files; unwilling to write output files");
/* If there are no input files, no need for the library. */
if (n_infiles == 0)
@@ -428,8 +428,7 @@ For more information about these matters
{
char *p;
- fprintf (stderr, _("Warning: Using -M <directory> is deprecated, "
- "use -J instead\n"));
+ warning (0, "using -M <directory> is deprecated, use -J instead");
if (argv[i][2] == '\0')
{
if (i+1 < argc)
@@ -441,7 +440,7 @@ For more information about these matters
i++;
}
else
- fatal ("argument to '%s' missing", argv[i]);
+ fatal_error ("argument to '%s' missing", argv[i]);
}
else
{
Index: config/darwin-driver.c
===================================================================
--- config/darwin-driver.c (revision 159969)
+++ config/darwin-driver.c (working copy)
@@ -1,5 +1,5 @@
/* Additional functions for the GCC driver on Darwin native.
- Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
Contributed by Apple Computer Inc.
This file is part of GCC.
@@ -107,7 +107,7 @@ darwin_default_min_version (int * argc_p
if (sysctl (osversion_name, ARRAY_SIZE (osversion_name), osversion,
&osversion_len, NULL, 0) == -1)
{
- fprintf (stderr, "sysctl for kern.osversion failed: %s\n",
+ warning (0, "sysctl for kern.osversion failed: %s",
xstrerror (errno));
return;
}
@@ -151,7 +151,7 @@ darwin_default_min_version (int * argc_p
return;
parse_failed:
- fprintf (stderr, "couldn't understand kern.osversion `%.*s'\n",
+ warning (0, "couldn't understand kern.osversion `%.*s'",
(int) osversion_len, osversion);
return;
}
--
Joseph S. Myers
joseph@codesourcery.com