diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-01-30 16:15:00 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2015-01-30 16:15:00 +0000 |
commit | 40fecdd62f7d293a214dd71b81de5e0f1099bba7 (patch) | |
tree | 205b68f7ca81a40e0ec33999911c7cd124be49b1 /gcc/java | |
parent | 4811c44ee01bba9fd09fe5e2b6b9fc9be66b33c9 (diff) | |
download | gcc-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/java')
-rw-r--r-- | gcc/java/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/java/class.c | 2 | ||||
-rw-r--r-- | gcc/java/expr.c | 4 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 34 | ||||
-rw-r--r-- | gcc/java/jvspec.c | 17 |
5 files changed, 37 insertions, 25 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 3b77d48..0437f73 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2015-01-30 Joseph Myers <joseph@codesourcery.com> + + * class.c, expr.c, jcf-parse.c, jvspec.c: All callers of + fatal_error changed to pass input_location as first argument. + 2015-10-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> * builtins.c: Include calls.h dojump.h emit-rtl.h explow.h expmed.h diff --git a/gcc/java/class.c b/gcc/java/class.c index a3a8342..d1adb58 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -850,7 +850,7 @@ add_method (tree this_class, int access_flags, tree name, tree method_sig) = (const unsigned char *) IDENTIFIER_POINTER (method_sig); if (sig[0] != '(') - fatal_error ("bad method signature"); + fatal_error (input_location, "bad method signature"); function_type = get_type_from_signature (method_sig); fndecl = add_method_1 (this_class, access_flags, name, function_type); diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 81ae8da..9af9e75 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -2253,7 +2253,7 @@ build_known_method_ref (tree method, tree method_type ATTRIBUTE_UNUSED, if (method == meth) break; if (meth == NULL_TREE) - fatal_error ("method '%s' not found in class", + fatal_error (input_location, "method '%s' not found in class", IDENTIFIER_POINTER (DECL_NAME (method))); method_index++; } @@ -2445,7 +2445,7 @@ expand_invoke (int opcode, int method_ref_index, int nargs ATTRIBUTE_UNUSED) load_class (self_type, 1); safe_layout_class (self_type); if (TREE_CODE (TYPE_SIZE (self_type)) == ERROR_MARK) - fatal_error ("failed to find class '%s'", self_name); + fatal_error (input_location, "failed to find class '%s'", self_name); } layout_class_methods (self_type); diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 02e23c4..e609331 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -1114,7 +1114,7 @@ get_constant (JCF *jcf, int index) { int char_len = UT8_CHAR_LENGTH (*utf8); if (char_len < 0 || char_len > 3 || char_len > i) - fatal_error ("bad string constant"); + fatal_error (input_location, "bad string constant"); utf8 += char_len; i -= char_len; @@ -1132,7 +1132,7 @@ get_constant (JCF *jcf, int index) jcf->cpool.data[index].t = value; return value; bad: - fatal_error ("bad value constant type %d, index %d", + fatal_error (input_location, "bad value constant type %d, index %d", JPOOL_TAG (jcf, index), index); } @@ -1443,13 +1443,13 @@ jcf_parse (JCF* jcf) bitmap_clear (field_offsets); if (jcf_parse_preamble (jcf) != 0) - fatal_error ("not a valid Java .class file"); + fatal_error (input_location, "not a valid Java .class file"); code = jcf_parse_constant_pool (jcf); if (code != 0) - fatal_error ("error while parsing constant pool"); + fatal_error (input_location, "error while parsing constant pool"); code = verify_constant_pool (jcf); if (code > 0) - fatal_error ("error in constant pool entry #%d\n", code); + fatal_error (input_location, "error in constant pool entry #%d\n", code); jcf_parse_class (jcf); if (main_class == NULL_TREE) @@ -1461,7 +1461,8 @@ jcf_parse (JCF* jcf) if (CLASS_PARSED_P (current_class)) { /* FIXME - where was first time */ - fatal_error ("reading class %s for the second time from %s", + fatal_error (input_location, + "reading class %s for the second time from %s", IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))), jcf->filename); } @@ -1479,13 +1480,13 @@ jcf_parse (JCF* jcf) code = jcf_parse_fields (jcf); if (code != 0) - fatal_error ("error while parsing fields"); + fatal_error (input_location, "error while parsing fields"); code = jcf_parse_methods (jcf); if (code != 0) - fatal_error ("error while parsing methods"); + fatal_error (input_location, "error while parsing methods"); code = jcf_parse_final_attributes (jcf); if (code != 0) - fatal_error ("error while parsing final attributes"); + fatal_error (input_location, "error while parsing final attributes"); if (TYPE_REFLECTION_DATA (current_class)) annotation_write_byte (JV_DONE_ATTR); @@ -1769,7 +1770,8 @@ java_parse_file (void) int avail = 2000; finput = fopen (main_input_filename, "r"); if (finput == NULL) - fatal_error ("can%'t open %s: %m", LOCATION_FILE (input_location)); + fatal_error (input_location, + "can%'t open %s: %m", LOCATION_FILE (input_location)); list = XNEWVEC (char, avail); next = list; for (;;) @@ -1788,7 +1790,7 @@ java_parse_file (void) if (count == 0) { if (! feof (finput)) - fatal_error ("error closing %s: %m", + fatal_error (input_location, "error closing %s: %m", LOCATION_FILE (input_location)); *next = '\0'; break; @@ -1903,11 +1905,12 @@ java_parse_file (void) /* Close previous descriptor, if any */ if (finput && fclose (finput)) - fatal_error ("can%'t close input file %s: %m", main_input_filename); + fatal_error (input_location, + "can%'t close input file %s: %m", main_input_filename); finput = fopen (filename, "rb"); if (finput == NULL) - fatal_error ("can%'t open %s: %m", filename); + fatal_error (input_location, "can%'t open %s: %m", filename); #ifdef IO_BUFFER_SIZE setvbuf (finput, xmalloc (IO_BUFFER_SIZE), @@ -1946,7 +1949,7 @@ java_parse_file (void) linemap_add (line_table, LC_ENTER, false, filename, 0); input_location = linemap_line_start (line_table, 0, 1); if (open_in_zip (main_jcf, filename, NULL, 0) < 0) - fatal_error ("bad zip/jar file %s", filename); + fatal_error (input_location, "bad zip/jar file %s", filename); localToFile = SeenZipFiles; /* Register all the classes defined there. */ process_zip_dir ((FILE *) main_jcf->read_state); @@ -2148,7 +2151,8 @@ parse_zip_file_entries (void) jcf->zipd = zdir; if (read_zip_member (jcf, zdir, localToFile) < 0) - fatal_error ("error while reading %s from zip file", file_name); + fatal_error (input_location, + "error while reading %s from zip file", file_name); buffer = XNEWVEC (char, zdir->filename_length + 1 + (jcf->buffer_end - jcf->buffer)); diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c index 7177176..d4efb73 100644 --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c @@ -392,16 +392,17 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, } if (saw_D && ! main_class_name) - fatal_error ("can%'t specify %<-D%> without %<--main%>"); + fatal_error (input_location, "can%'t specify %<-D%> without %<--main%>"); if (main_class_name && ! verify_class_name (main_class_name)) - fatal_error ("%qs is not a valid class name", main_class_name); + fatal_error (input_location, + "%qs is not a valid class name", main_class_name); num_args = argc + added; if (saw_resource) { if (! saw_o) - fatal_error ("--resource requires -o"); + fatal_error (input_location, "--resource requires -o"); } if (saw_C) { @@ -415,7 +416,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, } num_args += 2; /* For -o NONE. */ if (saw_o) - fatal_error ("cannot specify both -C and -o"); + fatal_error (input_location, "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) @@ -427,7 +428,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, { filelist_filename = make_temp_file ("jx"); if (filelist_filename == NULL) - fatal_error ("cannot create temporary file"); + fatal_error (input_location, "cannot create temporary file"); record_temp_file (filelist_filename, ! saw_save_temps, 0); filelist_file = fopen (filelist_filename, "w"); if (filelist_file == NULL) @@ -449,7 +450,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, if (combine_inputs || indirect_files_count > 0) num_args += 1; /* for "-ffilelist-file" */ if (combine_inputs && indirect_files_count > 0) - fatal_error ("using both @FILE with multiple files not implemented"); + fatal_error (input_location, + "using both @FILE with multiple files not implemented"); /* There's no point adding -shared-libgcc if we don't have a shared libgcc. */ @@ -533,7 +535,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, case OPT_fmain_: if (! will_link) - fatal_error ("cannot specify %<main%> class when not linking"); + fatal_error (input_location, + "cannot specify %<main%> class when not linking"); --j; continue; } |