Hi,
This patch finishes the conversion of Fortran diagnostics to use the
common diagnostics by removing all gfc_error*_1 variants.
I noticed that whether some buffered gfc_error_1() end up printed may
depend on whether a gfc_error_now is given or not, and not only on
whether there is any output buffered. Thus, I reintroduced a new
error_buffer of type gfc_buffer_error.
The rest is mostly mechanic.
I did not make an attempt in this patch to remove all code that has
become obsolete now:
gfc_get_terminal_width (already implemented in diagnostics.c)
error_char (already empty, but used by other obsolete functions)
error_string (obsolete, just use %s)
error_uinteger (obsolete, just use %lu)
error_integer (obsolete, just use %ld)
gfc_widechar_display_length, gfc_wide_display_length,
print_wide_char_into_buffer, gfc_print_wide_char (I'm not sure how
this functionality differs from what the common diagnostics already
do, perhaps some of it should be moved to the common code)
show_locus (obsolete, except "Included at" handling should be moved to
the common diagnostics, no testcase is testing this).
show_loci (obsolete, except "During initialization" handling should be
moved to the common diagnostics, no testcase is testing this)
error_print, error_printf (obsolete)
Bootstrapped and regression tested on x86_64-linux-gnu.
OK?
gcc/fortran/ChangeLog:
2015-05-17 Manuel López-Ibáñez
PR fortran/44054
* gfortran.h (struct gfc_error_buf): Rename as
gfc_error_buffer. Move closer to push, pop and free
methods. Reimplement using an output_buffer.
* error.c (errors, warnings, warning_buffer, cur_error_buffer):
Delete everywhere in this file.
(error_char): Delete all contents.
(gfc_increment_error_count): Delete.
(gfc_error_now): Update comment. Set error_buffer.flag.
(gfc_warning_check): Do not handle warning_buffer.
(gfc_error_1): Delete.
(gfc_error_now_1): Delete.
(gfc_error_check): Simplify.
(gfc_move_error_buffer_from_to): Renamed from
gfc_move_output_buffer_from_to.
(gfc_push_error): Handle only gfc_error_buffer.
(gfc_pop_error): Likewise.
(gfc_free_error): Likewise.
(gfc_get_errors): Remove warnings and errors.
(gfc_diagnostics_init): Use static error_buffer.
(gfc_error_1,gfc_error_now_1): Delete declarations.
* symbol.c, decl.c, trans-common.c, data.c, expr.c, expr.c,
frontend-passes.c, resolve.c, match.c, parse.c: Replace
gfc_error_1 with gfc_error and gfc_error_now_1 with gfc_error_1
everywhere.
* f95-lang.c (gfc_be_parse_file): Do not update errorcount and
warningcount here.
* primary.c (match_complex_constant): Replace gfc_error_buf and
output_buffer with gfc_error_buffer.
Index: gcc/fortran/symbol.c
===
--- gcc/fortran/symbol.c(revision 223238)
+++ gcc/fortran/symbol.c(working copy)
@@ -1699,11 +1699,11 @@ gfc_add_type (gfc_symbol *sym, gfc_types
type = sym->ns->proc_name->ts.type;
if (type != BT_UNKNOWN && !(sym->attr.function && sym->attr.implicit_type))
{
if (sym->attr.use_assoc)
- gfc_error_1 ("Symbol '%s' at %L conflicts with symbol from module '%s',
"
+ gfc_error ("Symbol %qs at %L conflicts with symbol from module %qs, "
"use-associated at %L", sym->name, where, sym->module,
&sym->declared_at);
else
gfc_error ("Symbol %qs at %L already has basic type of %s", sym->name,
where, gfc_basic_typename (type));
@@ -1893,22 +1893,22 @@ gfc_add_component (gfc_symbol *sym, cons
for (p = sym->components; p; p = p->next)
{
if (strcmp (p->name, name) == 0)
{
- gfc_error_1 ("Component '%s' at %C already declared at %L",
+ gfc_error ("Component %qs at %C already declared at %L",
name, &p->loc);
return false;
}
tail = p;
}
if (sym->attr.extension
&& gfc_find_component (sym->components->ts.u.derived, name, true, true))
{
- gfc_error_1 ("Component '%s' at %C already in the parent type "
+ gfc_error ("Component %qs at %C already in the parent type "
"at %L", name, &sym->components->ts.u.derived->declared_at);
return false;
}
/* Allocate a new component. */
@@ -2216,11 +2216,11 @@ gfc_define_st_label (gfc_st_label *lp, g
int labelno;
labelno = lp->value;
if (lp->defined != ST_LABEL_UNKNOWN)
-gfc_error_1 ("Duplicate statement label %d at %L and %L", labelno,
+gfc_error ("Duplicate statement label %d at %L and %L", labelno,
&lp->where, label_locus);
else
{
lp->where = *label_locus;
@@ -3893,34 +3893,34 @@ verify_bind_c_derived_type (gfc_symbol *
{
/* The components cannot be pointers (fortran sense).
J3/04-007, Section 15.2.3, C1505. */
if (curr_comp->attr.pointer != 0)
{
-