This is the mail archive of the gcc-patches@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]

[PATCH diagnostics/fortran] dynamically generate locations from offset + handle %C


This patch adds handling of Fortran %C using the common diagnostics
machinery. This is achieved by dynamically generating a location given
a location and an offset. This only works for non-macro line-maps (for
now), but this is OK since Fortran does not have virtual locations
(and I'm afraid it won't have them in the foreseeable future).

Dodji, are the linemap_asserts() appropriate? I tried to follow your
previous comments whenever possible.

The output is now:

gfortran.dg/use_without_only_1.f90:9:6:

   USE foo ! { dg-warning "6:has no ONLY qualifier" }
      1
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only]
gfortran.dg/use_without_only_1.f90:13:9:

      USE foo ! { dg-warning "9:has no ONLY qualifier" }
         1
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only]
gfortran.dg/use_without_only_1.f90:19:9:

      USE ISO_C_BINDING ! { dg-warning "9:has no ONLY qualifier" }
         1
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only]

that is, almost identical to the current output apart from mentioning
the option and the colors. (Spacing is surely messed up, gmail sucks,
sorry).

Strangely, the new warning cannot be parsed by the regex in
gfortran-dg.exp because they got confused by the lack of caret
information (gfc_warning_now_2 obeys -fno-diagnostics-show-caret,
which is the default in the testsuite). Thus I rewrote them in a way
that seems to me more clear and less prone to failure (in particular
being more strict about matching at the start of the line). The new
regex have the benefit that one can test column numbers in testcases
now like the C/C++ FE do.

Of course, this opens the way to convert a large number of
warning/errors in Fortran to the common diagnostics machinery, but
before doing that I wanted to get the basic infrastructure right.

Boot&regtested on x86_64-linux-gnu.

OK?

libcpp/ChangeLog:

2014-10-16  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    PR fortran/44054
    * include/line-map.h (linemap_position_for_loc_and_offset):
    Declare.
    * line-map.c (linemap_position_for_loc_and_offset): New.


gcc/fortran/ChangeLog:

2014-10-16  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    PR fortran/44054
    * gfortran.h (warn_use_without_only): Remove.
    (gfc_diagnostics_finish): Declare.
    * error.c: Include tree-diagnostics.h
    (gfc_format_decoder): New.
    (gfc_diagnostics_init): Use gfc_format_decoder. Set default caret
    char.
    (gfc_diagnostics_finish): Restore tree diagnostics defaults, but
    keep gfc_diagnostics_starter and finalizer. Restore default caret.
    * options.c: Remove all uses of warn_use_without_only.
    * lang.opt (Wuse-without-only): Add Var.
    * module.c (gfc_use_module): Use gfc_warning_now_2.
    * f95-lang.c (gfc_be_parse_file): Call gfc_diagnostics_finish.

gcc/testsuite/ChangeLog:

2014-10-16  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    PR fortran/44054
    * lib/gfortran-dg.exp: Update regexp to match locus and message
    without caret.
    * gfortran.dg/use_without_only_1.f90: Add column numbers.

Attachment: fortran-diagnostics-5.diff
Description: Text document


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