Colorizing error messages
David Malcolm
dmalcolm@redhat.com
Thu Nov 3 15:41:00 GMT 2016
On Thu, 2016-10-27 at 11:31 -0700, Jerry DeLisle wrote:
> Hi all,
>
> I notice that our front end diagnostics are colorized but the runtime
> messages
> are not. Does anyone know how we could add the color at runtime?
>
> Jerry
(sorry for the belated response; I just got back from vacation)
I maintain the diagnostics subsystem, but I'm not very familiar with
Fortran.
The frontend diagnostic colorization happens on the host via diagnostic
-color.c, which by default looks to see if stderr is directly connected
to a tty and colorizes if it is.
I'm guessing that the fortran runtime messages you refer to are the
ones emitted by libgfortran/runtime/error.c.
It's not clear to me exactly how you'd want the colorized errors to
look. Presumably diagnostic-color.c could be also built for the
*target* and integrated into libgfortran/runtime/error.c somehow
(perhaps calling colorize_init from main.c's init, or the first time an
error is emitted?). If so, there might need to be a licensing tweak,
to ensure that diagnostic-color.c has the runtime library exception (I
don't think it does at the moment).
You'd also want to have automated test coverage for this. I found
testing of colorization to be a little awkward to do in DejaGnu. For
the frontend diagnostics, we have tests like
gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c
though IIRC this merely tests the colorization of the source-code and
carets/underlining, not of the messages themselves.
Is it worth tracking this idea as a PR?
Hope this is helpful
Dave
More information about the Fortran
mailing list