Commit 981e3997 by Tobias Burnus

[Fortran] Fix column of %C diagnostic location

        gcc/fortran/
        * error (error_print, gfc_format_decoder): Fix off-by one issue with %C.

        gcc/testsuite/
        * gfortran.dg/use_without_only_1.f90: Update column num in dg-warning.

From-SVN: r276567
parent 48528394
2019-10-04 Tobias Burnus <tobias@codesourcery.com>
* error (error_print, gfc_format_decoder): Fix off-by one issue with %C.
2019-10-03 Steven G. Kargl <kargl@gcc.gnu.org> 2019-10-03 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91497 PR fortran/91497
...@@ -91,7 +95,7 @@ ...@@ -91,7 +95,7 @@
2019-10-01 Jan Hubicka <jh@suse.cz> 2019-10-01 Jan Hubicka <jh@suse.cz>
* module.c (load_commons): Initialize flags to 0 to silecne * module.c (load_commons): Initialize flags to 0 to silence
-Wmaybe-uninitialized warning. -Wmaybe-uninitialized warning.
(read_module): Likewise for n and comp_name. (read_module): Likewise for n and comp_name.
......
...@@ -618,12 +618,18 @@ error_print (const char *type, const char *format0, va_list argp) ...@@ -618,12 +618,18 @@ error_print (const char *type, const char *format0, va_list argp)
{ {
l2 = loc; l2 = loc;
arg[pos].u.stringval = "(2)"; arg[pos].u.stringval = "(2)";
/* Point %C first offending character not the last good one. */
if (arg[pos].type == TYPE_CURRENTLOC)
l2->nextc++;
} }
else else
{ {
l1 = loc; l1 = loc;
have_l1 = 1; have_l1 = 1;
arg[pos].u.stringval = "(1)"; arg[pos].u.stringval = "(1)";
/* Point %C first offending character not the last good one. */
if (arg[pos].type == TYPE_CURRENTLOC)
l1->nextc++;
} }
break; break;
...@@ -963,6 +969,9 @@ gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec, ...@@ -963,6 +969,9 @@ gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec,
loc = va_arg (*text->args_ptr, locus *); loc = va_arg (*text->args_ptr, locus *);
gcc_assert (loc->nextc - loc->lb->line >= 0); gcc_assert (loc->nextc - loc->lb->line >= 0);
unsigned int offset = loc->nextc - loc->lb->line; unsigned int offset = loc->nextc - loc->lb->line;
if (*spec == 'C')
/* Point %C first offending character not the last good one. */
offset++;
/* If location[0] != UNKNOWN_LOCATION means that we already /* If location[0] != UNKNOWN_LOCATION means that we already
processed one of %C/%L. */ processed one of %C/%L. */
int loc_num = text->get_location (0) == UNKNOWN_LOCATION ? 0 : 1; int loc_num = text->get_location (0) == UNKNOWN_LOCATION ? 0 : 1;
...@@ -1401,7 +1410,7 @@ gfc_internal_error (const char *gmsgid, ...) ...@@ -1401,7 +1410,7 @@ gfc_internal_error (const char *gmsgid, ...)
void void
gfc_clear_error (void) gfc_clear_error (void)
{ {
error_buffer.flag = 0; error_buffer.flag = false;
warnings_not_errors = false; warnings_not_errors = false;
gfc_clear_pp_buffer (pp_error_buffer); gfc_clear_pp_buffer (pp_error_buffer);
} }
......
2019-10-04 Tobias Burnus <tobias@codesourcery.com>
* gfortran.dg/use_without_only_1.f90: Update column num in dg-warning.
2019-10-04 Jakub Jelinek <jakub@redhat.com> 2019-10-04 Jakub Jelinek <jakub@redhat.com>
PR c++/71504 PR c++/71504
......
...@@ -6,16 +6,16 @@ MODULE foo ...@@ -6,16 +6,16 @@ MODULE foo
END MODULE END MODULE
MODULE testmod MODULE testmod
USE foo ! { dg-warning "6:has no ONLY qualifier" } USE foo ! { dg-warning "7:has no ONLY qualifier" }
IMPLICIT NONE IMPLICIT NONE
CONTAINS CONTAINS
SUBROUTINE S1 SUBROUTINE S1
USE foo ! { dg-warning "9:has no ONLY qualifier" } USE foo ! { dg-warning "10:has no ONLY qualifier" }
END SUBROUTINE S1 END SUBROUTINE S1
SUBROUTINE S2 SUBROUTINE S2
USE foo, ONLY: bar USE foo, ONLY: bar
END SUBROUTINE END SUBROUTINE
SUBROUTINE S3 SUBROUTINE S3
USE ISO_C_BINDING ! { dg-warning "9:has no ONLY qualifier" } USE ISO_C_BINDING ! { dg-warning "10:has no ONLY qualifier" }
END SUBROUTINE S3 END SUBROUTINE S3
END MODULE END MODULE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment