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

--- Comment #10 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #8)
> /home/manuel/test1/test-gfc-warning.f03:11:0:
>    arr = (/ INTEGER(KIND=4) :: HUGE(0_8) /) ! { dg-warning "conversion from"
> }
>  1
> Warning: Possible change of value in conversion from INTEGER(8) to
> INTEGER(4) at (1) [-Wconversion]

Looks good to me at a glance. However, I have not yet applied the patch and
played around with it.

Thanks for working on this!


> Also, is there any case where gcf_linebuf.file->filename !=
> LOCATION_FILE(gcf_linebuf.location) ?

Seemingly not. I tried to use:
a) include "some_file"
b) #include "some_file"
and the latter using both "-cpp" and using the pre-processed output as input.
And it always worked.


Also looking at the code in scanner.c, it seems as if it is always set to the
correct value:

get_file (const char *name, enum lc_reason reason ATTRIBUTE_UNUSED)
...
  f->filename = xstrdup (name);
...
  linemap_add (line_table, reason, false, f->filename, 1);

Thus, on terms of the linebuffer, there should be no reason of having
"filename" at all. It seems to get used in scanner.c itself - where some of the
diagnostic by-passes the default diagnostic. Either by constructing the
file/line numbers manually or even by calling "fprintf(stderr" directly.

[One probably should do some clean up there as well… But having the 'proper'
diagnostic for the rest would be a start.]


> So the only remaining major issue is the offset. It is not clear to me why
> Fortran needs an explicit offset, don't you track locations when parsing
> using line-map.c

Seemingly, we don't. The offset within a line is calculated using:
  c1 = l1->nextc - l1->lb->line;
and in "next_char" one simply uses:
  c = *gfc_current_locus.nextc++;

For the line map, we just use:
     b->location
        = linemap_line_start (line_table, current_file->line++, 120);
which gives the line but not the offset.


One might handle this in a more clever way, but can't you use in gfc_warning2,
gfortran's normal "locus" and use linemap_position_for_column() to map from the
offset to the column?



Another thing I wonder how to handle best is the case of having two locations
in the same line, e.g.
  integer, allocatable :: v(:)
  allocate (v(3), v(4))
  end
that currently prints:
  foo.f90:foo.f90:2.10-16:
  allocate (v(3), v(4))
            1     2
  Error: Allocate-object at (1) also appears at (2)

or with line break (note the "&"):
  allocate (v(3), &
            v(4))
as
  foo.f90:foo.f90:2.10:
  allocate (v(3), &
            1
  foo.f90:foo.f90:3.10:
          v(4))
          2
  Error: Allocate-object at (1) also appears at (2)

Reply via email to