https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91426
--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
The diagnostic is coming from
gfc_define_st_label in gcc/fortran/symbol.c:2711
2711 gfc_error ("Duplicate statement label %d at %L and %L", labelno,
2712 &lp->where, label_locus);
This ultimately leads to a call to diagnostic_show_locus from
gfc_diagnostic_starter, with a rich_location containing two locations.
A rich_location can contain an arbitrary number of location_t values. The
first is considered the "primary" location, subsequent ones are considered
"secondary" locations.
diagnostic_show_locus currently colorizes locations by using the
"diagnostic_kind" color for the primary location_t within the rich_location,
and then alternating between two other colors for any secondary location_t
values within the rich_location ("range1" and "range2" within GCC_COLORS).
It's not clear to me what ought to happen here for Fortran.
Currently the fortran/error.c seems to be set up to support at most 2 locations
per diagnostic (via the %L formatting code).
Some possible ways forward:
- generalize the fortran diagnostics-handling code to support more than 2
locations (though would any diagnostics use this?)
- special-case fortran's colorization so it uses the same color for both
locations
- something else I haven't thought of