This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/44054] Handle -Werror, -Werror=, -fdiagnostics-show-option


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44054

--- Comment #5 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
Created attachment 32622
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32622&action=edit
proof of concept

The attached patch is a proof of concept. It gives the following output:

/home/manuel/test1/test-gfc-warning.f03:11:0:
Warning: Possible change of value in conversion from INTEGER(8) to INTEGER(4)
at (1) [-Wconversion]
   arr = (/ INTEGER(KIND=4) :: HUGE(0_8) /) ! { dg-warning "conversion from" }
 ^

This warning is controllable by -Wno-conversion, -Werror=conversion and the
#pragma GCC diagnostic. Also the diagnostic is in color (unfortunately it does
not show it here).

Contrary to what I said above, I think it is actually easier for Fortran to use
the common pretty printer rather than fake their own. It will also remove quite
a bit of duplicated code from the Fortran FE. The transition can be done in the
following steps (I chose the wrong warning to start with):

1. Warnings that don't use %L (so initially you don't have to deal with locus)
2. Warnings that use %C
3. Warnings that use one %L
4. Warnings that use two %L


If there is one or more willing Fortran developers that wants to tackle this
for the next release, I think the four steps are feasible within one release.
To fully match the current Fortran diagnostics, the common diagnostics
machinery needs the following features:

a. Make the printing of the caret line more customizable. For the C/C++ FE it
will be moved to the diagnostic_finalizer, whereas for Fortran it will go in
the diagnostic_starter, so it can be printed before the actual text.
b. A way to customize the caret symbol so Fortran can print '1' instead of '^'.
c. Pass down offsets relative to current location. This is anyway necessary for
printing more precise diagnostics for format strings, so it is a matter to add
an offset field to the diagnostic_info structure.
d. A way to print two locations in the caret line.

And that is all as far as I can see.

If a Fortran developer volunteers to tackle the Fortran bits, I will be happy
to implement the common diagnostics bits. From the above a) and b) are trivial.
c) is also trivial but requires writing a bit more of code. d) is a bit more
convoluted but it should work fine.

The Fortran transition can be incremental, that is, if Fortran disables colors
and -fdiagnostics-show-option by default, then the converted diagnostics will
be indistinguishable from the unconverted ones (except that -Wno-*, -Werror=
and the #pragmas will only work for the converted ones).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]