aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2015-01-30 16:15:00 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2015-01-30 16:15:00 +0000
commit40fecdd62f7d293a214dd71b81de5e0f1099bba7 (patch)
tree205b68f7ca81a40e0ec33999911c7cd124be49b1 /gcc/gcc.c
parent4811c44ee01bba9fd09fe5e2b6b9fc9be66b33c9 (diff)
downloadgcc-40fecdd62f7d293a214dd71b81de5e0f1099bba7.zip
gcc-40fecdd62f7d293a214dd71b81de5e0f1099bba7.tar.gz
gcc-40fecdd62f7d293a214dd71b81de5e0f1099bba7.tar.bz2
Always pass explicit location to fatal_error.
The patch <https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00698.html> adding an overload for fatal_error that passes an explicit location broke gcc.pot regeneration because xgettext cannot handle function overloads with the diagnostic string argument in different positions. As the desired direction is for all diagnostics to have explicit locations, this patch addresses the regression by removing the version of fatal_error that does not pass a location, passing explicit input_location everywhere (in the hope that those will incrementally be changed to other locations, much as with the addition of a location argument to pedwarn some time ago - a lot of cases aren't meaningfully associated with a source file so UNKNOWN_LOCATION may be better). Note that this patch does not attempt to fix any existing issues with these diagnostics (such as wrongly starting with capital letters or ending with '.' or '\n'); it just adds the input_location argument. Bootstrapped with no regressions for x86_64-unknown-linux-gnu (Go excluded). gcc: * diagnostic.c (fatal_error (const char *, ...)): Remove function. * diagnostic-core.h (fatal_error (const char *, ...)): Remove prototype. * toplev.h (init_asm_output): Update comment on use of UNKNOWN_LOCATION with fatal_error. * cgraph.c, collect-utils.c, collect2.c, config/arc/arc.c, config/arc/arc.md, config/avr/avr.c, config/c6x/c6x.h, config/darwin.c, config/host-darwin.c, config/i386/host-cygwin.c, config/i386/intelmic-mkoffload.c, config/nios2/nios2.c, config/nvptx/mkoffload.c, config/nvptx/nvptx.h, config/rs6000/host-darwin.c, config/rs6000/rs6000.c, config/s390/s390.c, gcc.c, gcov-io.h, gcov-tool.c, ggc-common.c, ggc-page.c, graph.c, ipa-inline-analysis.c, ipa-reference.c, lto-cgraph.c, lto-section-in.c, lto-streamer-in.c, lto-streamer.c, lto-wrapper.c, objc/objc-act.c, opts.c, passes.c, plugin.c, tlink.c, toplev.c, tree-streamer-in.c, varpool.c: All callers of fatal_error changed to pass input_location as first argument. gcc/c-family: * c-opts.c, c-pch.c, cppspec.c: All callers of fatal_error changed to pass input_location as first argument. gcc/cp: * class.c, except.c, parser.c, pt.c: All callers of fatal_error changed to pass input_location as first argument. gcc/fortran: * f95-lang.c, gfortranspec.c, trans-const.c, trans-expr.c: All callers of fatal_error changed to pass input_location as first argument. gcc/java: * class.c, expr.c, jcf-parse.c, jvspec.c: All callers of fatal_error changed to pass input_location as first argument. gcc/lto: * lto-object.c, lto-symtab.c, lto.c: All callers of fatal_error changed to pass input_location as first argument. libcc1: * plugin.cc: All callers of fatal_error changed to pass input_location as first argument. From-SVN: r220293
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c152
1 files changed, 91 insertions, 61 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index f682c3b..186f0ae 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1896,7 +1896,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
p1++;
if (*p1++ != '<' || p[-2] != '>')
- fatal_error ("specs %%include syntax malformed after "
+ fatal_error (input_location,
+ "specs %%include syntax malformed after "
"%ld characters",
(long) (p1 - buffer + 1));
@@ -1916,7 +1917,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
p1++;
if (*p1++ != '<' || p[-2] != '>')
- fatal_error ("specs %%include syntax malformed after "
+ fatal_error (input_location,
+ "specs %%include syntax malformed after "
"%ld characters",
(long) (p1 - buffer + 1));
@@ -1942,7 +1944,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
p1++;
if (! ISALPHA ((unsigned char) *p1))
- fatal_error ("specs %%rename syntax malformed after "
+ fatal_error (input_location,
+ "specs %%rename syntax malformed after "
"%ld characters",
(long) (p1 - buffer));
@@ -1951,7 +1954,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
p2++;
if (*p2 != ' ' && *p2 != '\t')
- fatal_error ("specs %%rename syntax malformed after "
+ fatal_error (input_location,
+ "specs %%rename syntax malformed after "
"%ld characters",
(long) (p2 - buffer));
@@ -1961,7 +1965,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
p2++;
if (! ISALPHA ((unsigned char) *p2))
- fatal_error ("specs %%rename syntax malformed after "
+ fatal_error (input_location,
+ "specs %%rename syntax malformed after "
"%ld characters",
(long) (p2 - buffer));
@@ -1971,7 +1976,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
p3++;
if (p3 != p - 1)
- fatal_error ("specs %%rename syntax malformed after "
+ fatal_error (input_location,
+ "specs %%rename syntax malformed after "
"%ld characters",
(long) (p3 - buffer));
*p3 = '\0';
@@ -1981,14 +1987,16 @@ read_specs (const char *filename, bool main_p, bool user_p)
break;
if (!sl)
- fatal_error ("specs %s spec was not found to be renamed", p1);
+ fatal_error (input_location,
+ "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_error ("%s: attempt to rename spec %qs to "
+ fatal_error (input_location,
+ "%s: attempt to rename spec %qs to "
"already defined spec %qs",
filename, p1, p2);
@@ -2009,7 +2017,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
continue;
}
else
- fatal_error ("specs unknown %% command after %ld characters",
+ fatal_error (input_location,
+ "specs unknown %% command after %ld characters",
(long) (p1 - buffer));
}
@@ -2020,7 +2029,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
/* The colon shouldn't be missing. */
if (*p1 != ':')
- fatal_error ("specs file malformed after %ld characters",
+ fatal_error (input_location,
+ "specs file malformed after %ld characters",
(long) (p1 - buffer));
/* Skip back over trailing whitespace. */
@@ -2033,7 +2043,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
/* Find the next line. */
p = skip_whitespace (p1 + 1);
if (p[1] == 0)
- fatal_error ("specs file malformed after %ld characters",
+ fatal_error (input_location,
+ "specs file malformed after %ld characters",
(long) (p - buffer));
p1 = p;
@@ -2085,7 +2096,7 @@ read_specs (const char *filename, bool main_p, bool user_p)
}
if (link_command_spec == 0)
- fatal_error ("spec file has no spec for linking");
+ fatal_error (input_location, "spec file has no spec for linking");
}
/* Record the names of temporary files we tell compilers to write,
@@ -2630,7 +2641,7 @@ add_sysrooted_prefix (struct path_prefix *pprefix, const char *prefix,
int require_machine_suffix, int os_multilib)
{
if (!IS_ABSOLUTE_PATH (prefix))
- fatal_error ("system path %qs is not absolute", prefix);
+ fatal_error (input_location, "system path %qs is not absolute", prefix);
if (target_system_root)
{
@@ -2718,7 +2729,7 @@ execute (void)
if (arg && strcmp (arg, "|") == 0)
{ /* each command. */
#if defined (__MSDOS__) || defined (OS2) || defined (VMS)
- fatal_error ("-pipe not supported");
+ fatal_error (input_location, "-pipe not supported");
#endif
argbuf[i] = 0; /* Termination of
command args. */
@@ -2841,7 +2852,7 @@ execute (void)
? PEX_RECORD_TIMES : 0),
progname, temp_filename);
if (pex == NULL)
- fatal_error ("pex_init failed: %m");
+ fatal_error (input_location, "pex_init failed: %m");
for (i = 0; i < n_commands; i++)
{
@@ -2857,7 +2868,7 @@ execute (void)
if (errmsg != NULL)
{
if (err == 0)
- fatal_error (errmsg);
+ fatal_error (input_location, errmsg);
else
{
errno = err;
@@ -2880,13 +2891,13 @@ execute (void)
statuses = (int *) alloca (n_commands * sizeof (int));
if (!pex_get_status (pex, n_commands, statuses))
- fatal_error ("failed to get exit status: %m");
+ fatal_error (input_location, "failed to get exit status: %m");
if (report_times || report_times_to_file)
{
times = (struct pex_time *) alloca (n_commands * sizeof (struct pex_time));
if (!pex_get_times (pex, n_commands, times))
- fatal_error ("failed to get process times: %m");
+ fatal_error (input_location, "failed to get process times: %m");
}
pex_free (pex);
@@ -3420,7 +3431,8 @@ handle_foffload_option (const char *arg)
}
if (!c)
- fatal_error ("GCC is not configured to support %s as offload target",
+ fatal_error (input_location,
+ "GCC is not configured to support %s as offload target",
target);
if (!offload_targets)
@@ -3719,7 +3731,7 @@ driver_handle_option (struct gcc_options *opts,
|| strcmp (arg, "object") == 0)
save_temps_flag = SAVE_TEMPS_OBJ;
else
- fatal_error ("%qs is an unknown -save-temps option",
+ fatal_error (input_location, "%qs is an unknown -save-temps option",
decoded->orig_option_with_args_text);
break;
@@ -4174,7 +4186,8 @@ process_command (unsigned int decoded_options_count,
for (i = 0; i < n_infiles; i++)
if ((!infiles[i].language || infiles[i].language[0] != '*')
&& canonical_filename_eq (infiles[i].name, output_file))
- fatal_error ("input file %qs is the same as output file",
+ fatal_error (input_location,
+ "input file %qs is the same as output file",
output_file);
}
@@ -4655,10 +4668,12 @@ do_self_spec (const char *spec)
/* Specs should only generate options, not input
files. */
if (strcmp (decoded_options[j].arg, "-") != 0)
- fatal_error ("switch %qs does not start with %<-%>",
+ fatal_error (input_location,
+ "switch %qs does not start with %<-%>",
decoded_options[j].arg);
else
- fatal_error ("spec-generated switch is just %<-%>");
+ fatal_error (input_location,
+ "spec-generated switch is just %<-%>");
break;
case OPT_fcompare_debug_second:
@@ -4749,19 +4764,20 @@ create_at_file (char **argv)
int status;
if (f == NULL)
- fatal_error ("could not open temporary response file %s",
+ fatal_error (input_location, "could not open temporary response file %s",
temp_file);
status = writeargv (argv, f);
if (status)
- fatal_error ("could not write to temporary response file %s",
+ fatal_error (input_location,
+ "could not write to temporary response file %s",
temp_file);
status = fclose (f);
if (EOF == status)
- fatal_error ("could not close temporary response file %s",
+ fatal_error (input_location, "could not close temporary response file %s",
temp_file);
store_arg (at_argument, 0, 0);
@@ -4884,7 +4900,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
switch (c = *p++)
{
case 0:
- fatal_error ("spec %qs invalid", spec);
+ fatal_error (input_location, "spec %qs invalid", spec);
case 'b':
if (save_temps_length)
@@ -5033,7 +5049,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
p += 2;
/* We don't support extra suffix characters after %O. */
if (*p == '.' || ISALNUM ((unsigned char) *p))
- fatal_error ("spec %qs has invalid %<%%0%c%>", spec, *p);
+ fatal_error (input_location,
+ "spec %qs has invalid %<%%0%c%>", spec, *p);
if (suffix_length == 0)
suffix = TARGET_OBJECT_SUFFIX;
else
@@ -5352,7 +5369,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
unsigned int cur_index = argbuf.length ();
/* Handle the {...} following the %W. */
if (*p != '{')
- fatal_error ("spec %qs has invalid %<%%W%c%>", spec, *p);
+ fatal_error (input_location,
+ "spec %qs has invalid %<%%W%c%>", spec, *p);
p = handle_braces (p + 1);
if (p == 0)
return -1;
@@ -5374,7 +5392,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
/* Skip past the option value and make a copy. */
if (*p != '{')
- fatal_error ("spec %qs has invalid %<%%x%c%>", spec, *p);
+ fatal_error (input_location,
+ "spec %qs has invalid %<%%x%c%>", spec, *p);
while (*p++ != '}')
;
string = save_string (p1 + 1, p - p1 - 2);
@@ -5690,7 +5709,7 @@ eval_spec_function (const char *func, const char *args)
sf = lookup_spec_function (func);
if (sf == NULL)
- fatal_error ("unknown spec function %qs", func);
+ fatal_error (input_location, "unknown spec function %qs", func);
/* Push the spec processing context. */
save_argbuf = argbuf;
@@ -5720,7 +5739,7 @@ eval_spec_function (const char *func, const char *args)
alloc_args ();
if (do_spec_2 (args) < 0)
- fatal_error ("error in args to spec function %qs", func);
+ fatal_error (input_location, "error in args to spec function %qs", func);
/* argbuf_index is an index for the next argument to be inserted, and
so contains the count of the args already inserted. */
@@ -5774,10 +5793,10 @@ handle_spec_function (const char *p, bool *retval_nonnull)
break;
/* Only allow [A-Za-z0-9], -, and _ in function names. */
if (!ISALNUM (*endp) && !(*endp == '-' || *endp == '_'))
- fatal_error ("malformed spec function name");
+ fatal_error (input_location, "malformed spec function name");
}
if (*endp != '(') /* ) */
- fatal_error ("no arguments for spec function");
+ fatal_error (input_location, "no arguments for spec function");
func = save_string (p, endp - p);
p = ++endp;
@@ -5796,7 +5815,7 @@ handle_spec_function (const char *p, bool *retval_nonnull)
}
/* ( */
if (*endp != ')')
- fatal_error ("malformed spec function arguments");
+ fatal_error (input_location, "malformed spec function arguments");
args = save_string (p, endp - p);
p = ++endp;
@@ -6070,7 +6089,7 @@ handle_braces (const char *p)
return p;
invalid:
- fatal_error ("braced spec %qs is invalid at %qc", orig, *p);
+ fatal_error (input_location, "braced spec %qs is invalid at %qc", orig, *p);
#undef SKIP_WHITE
}
@@ -6158,7 +6177,7 @@ process_brace_body (const char *p, const char *atom, const char *end_atom,
return p;
invalid:
- fatal_error ("braced spec body %qs is invalid", body);
+ fatal_error (input_location, "braced spec body %qs is invalid", body);
}
/* Return 0 iff switch number SWITCHNUM is obsoleted by a later switch
@@ -6454,7 +6473,7 @@ run_attempt (const char **new_argv, const char *out_temp,
pex = pex_init (PEX_USE_PIPES, new_argv[0], NULL);
if (!pex)
- fatal_error ("pex_init failed: %m");
+ fatal_error (input_location, "pex_init failed: %m");
errmsg = pex_run (pex, pex_flags, new_argv[0],
CONST_CAST2 (char *const *, const char **, &new_argv[1]), out_temp,
@@ -6462,7 +6481,7 @@ run_attempt (const char **new_argv, const char *out_temp,
if (errmsg != NULL)
{
if (err == 0)
- fatal_error (errmsg);
+ fatal_error (input_location, errmsg);
else
{
errno = err;
@@ -7003,7 +7022,7 @@ driver::global_initializations ()
#endif
if (atexit (delete_temp_files) != 0)
- fatal_error ("atexit failed");
+ fatal_error (input_location, "atexit failed");
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
signal (SIGINT, fatal_signal);
@@ -7527,7 +7546,8 @@ driver::maybe_print_and_exit () const
else
/* The error status indicates that only one set of fixed
headers should be built. */
- fatal_error ("not configured with sysroot headers suffix");
+ fatal_error (input_location,
+ "not configured with sysroot headers suffix");
}
if (print_help_list)
@@ -7588,7 +7608,7 @@ driver::prepare_infiles ()
int lang_n_infiles = 0;
if (n_infiles == added_libraries)
- fatal_error ("no input files");
+ fatal_error (input_location, "no input files");
if (seen_error ())
/* Early exit needed from main. */
@@ -7638,7 +7658,8 @@ driver::prepare_infiles ()
}
if (!combine_inputs && have_c && have_o && lang_n_infiles > 1)
- fatal_error ("cannot specify -o with -c, -S or -E with multiple files");
+ fatal_error (input_location,
+ "cannot specify -o with -c, -S or -E with multiple files");
/* No early exit needed from main; we can continue. */
return false;
@@ -7844,7 +7865,8 @@ driver::maybe_run_linker (const char *argv0) const
LTOPLUGINSONAME, R_OK,
false);
if (!temp_spec)
- fatal_error ("-fuse-linker-plugin, but %s not found",
+ fatal_error (input_location,
+ "-fuse-linker-plugin, but %s not found",
LTOPLUGINSONAME);
linker_plugin_file_spec = convert_white_space (temp_spec);
}
@@ -8156,7 +8178,7 @@ used_arg (const char *p, int len)
if (*q == '\0')
{
invalid_matches:
- fatal_error ("multilib spec %qs is invalid",
+ fatal_error (input_location, "multilib spec %qs is invalid",
multilib_matches);
}
q++;
@@ -8350,7 +8372,7 @@ set_multilib_dir (void)
if (*p == '\0')
{
invalid_exclusions:
- fatal_error ("multilib exclusions %qs is invalid",
+ fatal_error (input_location, "multilib exclusions %qs is invalid",
multilib_exclusions);
}
@@ -8414,7 +8436,7 @@ set_multilib_dir (void)
if (*p == '\0')
{
invalid_select:
- fatal_error ("multilib select %qs %qs is invalid",
+ fatal_error (input_location, "multilib select %qs %qs is invalid",
multilib_select, multilib_reuse);
}
++p;
@@ -8575,7 +8597,8 @@ print_multilib_info (void)
if (*p == '\0')
{
invalid_select:
- fatal_error ("multilib select %qs is invalid", multilib_select);
+ fatal_error (input_location,
+ "multilib select %qs is invalid", multilib_select);
}
++p;
@@ -8614,7 +8637,8 @@ print_multilib_info (void)
if (*e == '\0')
{
invalid_exclusion:
- fatal_error ("multilib exclusion %qs is invalid",
+ fatal_error (input_location,
+ "multilib exclusion %qs is invalid",
multilib_exclusions);
}
@@ -8820,7 +8844,8 @@ getenv_spec_function (int argc, const char **argv)
value = getenv (argv[0]);
if (!value)
- fatal_error ("environment variable %qs not defined", argv[0]);
+ fatal_error (input_location,
+ "environment variable %qs not defined", argv[0]);
/* We have to escape every character of the environment variable so
they are not interpreted as active spec characters. A
@@ -8959,12 +8984,12 @@ compare_version_strings (const char *v1, const char *v2)
abort ();
rresult = regexec (&r, v1, 0, NULL, 0);
if (rresult == REG_NOMATCH)
- fatal_error ("invalid version number %qs", v1);
+ fatal_error (input_location, "invalid version number %qs", v1);
else if (rresult != 0)
abort ();
rresult = regexec (&r, v2, 0, NULL, 0);
if (rresult == REG_NOMATCH)
- fatal_error ("invalid version number %qs", v2);
+ fatal_error (input_location, "invalid version number %qs", v2);
else if (rresult != 0)
abort ();
@@ -9007,13 +9032,13 @@ version_compare_spec_function (int argc, const char **argv)
bool result;
if (argc < 3)
- fatal_error ("too few arguments to %%:version-compare");
+ fatal_error (input_location, "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_error ("too many arguments to %%:version-compare");
+ fatal_error (input_location, "too many arguments to %%:version-compare");
switch_len = strlen (argv[nargs + 1]);
for (i = 0; i < n_switches; i++)
@@ -9054,7 +9079,8 @@ version_compare_spec_function (int argc, const char **argv)
break;
default:
- fatal_error ("unknown operator %qs in %%:version-compare", argv[0]);
+ fatal_error (input_location,
+ "unknown operator %qs in %%:version-compare", argv[0]);
}
if (! result)
return NULL;
@@ -9177,7 +9203,8 @@ compare_debug_dump_opt_spec_function (int arg,
static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
if (arg != 0)
- fatal_error ("too many arguments to %%:compare-debug-dump-opt");
+ fatal_error (input_location,
+ "too many arguments to %%:compare-debug-dump-opt");
do_spec_2 ("%{fdump-final-insns=*:%*}");
do_spec_1 (" ", 0, NULL);
@@ -9249,7 +9276,8 @@ compare_debug_self_opt_spec_function (int arg,
const char **argv ATTRIBUTE_UNUSED)
{
if (arg != 0)
- fatal_error ("too many arguments to %%:compare-debug-self-opt");
+ fatal_error (input_location,
+ "too many arguments to %%:compare-debug-self-opt");
if (compare_debug >= 0)
return NULL;
@@ -9284,17 +9312,19 @@ compare_debug_auxbase_opt_spec_function (int arg,
int len;
if (arg == 0)
- fatal_error ("too few arguments to %%:compare-debug-auxbase-opt");
+ fatal_error (input_location,
+ "too few arguments to %%:compare-debug-auxbase-opt");
if (arg != 1)
- fatal_error ("too many arguments to %%:compare-debug-auxbase-opt");
+ fatal_error (input_location,
+ "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_error ("argument to %%:compare-debug-auxbase-opt "
+ fatal_error (input_location, "argument to %%:compare-debug-auxbase-opt "
"does not end in .gk");
if (debug_auxbase_opt)
@@ -9368,7 +9398,7 @@ replace_extension_spec_func (int argc, const char **argv)
int i;
if (argc != 2)
- fatal_error ("too few arguments to %%:replace-extension");
+ fatal_error (input_location, "too few arguments to %%:replace-extension");
name = xstrdup (argv[0]);