diff options
author | Tobias Burnus <burnus@gcc.gnu.org> | 2019-10-04 11:29:31 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2019-10-04 11:29:31 +0200 |
commit | 981e39974ea31cb418507eadcb2cd7bbdf27ed79 (patch) | |
tree | 0eea74af953348c7b5648931da79306b8a12f9ef | |
parent | 48528394eafa9d1db9f956570f910c76d429a3e5 (diff) | |
download | gcc-981e39974ea31cb418507eadcb2cd7bbdf27ed79.zip gcc-981e39974ea31cb418507eadcb2cd7bbdf27ed79.tar.gz gcc-981e39974ea31cb418507eadcb2cd7bbdf27ed79.tar.bz2 |
[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
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/error.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/use_without_only_1.f90 | 6 |
4 files changed, 24 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9a2a800..196b40b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +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> PR fortran/91497 @@ -54,7 +58,7 @@ messages instead of the original call to gfc_typename. * misc.c (gfc_typename): New function for gfc_expr *, use for where character types are possible it can get the character length from - gfc_expr for character literals. + gfc_expr for character literals. (gfc_dummy_typename): New functionfor gfc_typespec *, if no character length is present the character type is assumed and the appropriate string is return otherwise it calls gfc_typename for gfc_typespec *. @@ -88,10 +92,10 @@ a subroutine reference. * resolve.c (resolve_function): BOZ cannot be an actual argument in a function reference. - + 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. (read_module): Likewise for n and comp_name. diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index a7c27f0..1019f17 100644 --- a/gcc/fortran/error.c +++ b/gcc/fortran/error.c @@ -618,12 +618,18 @@ error_print (const char *type, const char *format0, va_list argp) { l2 = loc; arg[pos].u.stringval = "(2)"; + /* Point %C first offending character not the last good one. */ + if (arg[pos].type == TYPE_CURRENTLOC) + l2->nextc++; } else { l1 = loc; have_l1 = 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; @@ -963,6 +969,9 @@ gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec, loc = va_arg (*text->args_ptr, locus *); gcc_assert (loc->nextc - loc->lb->line >= 0); 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 processed one of %C/%L. */ int loc_num = text->get_location (0) == UNKNOWN_LOCATION ? 0 : 1; @@ -1401,7 +1410,7 @@ gfc_internal_error (const char *gmsgid, ...) void gfc_clear_error (void) { - error_buffer.flag = 0; + error_buffer.flag = false; warnings_not_errors = false; gfc_clear_pp_buffer (pp_error_buffer); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 60e6caa..b8c9f4c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +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> PR c++/71504 diff --git a/gcc/testsuite/gfortran.dg/use_without_only_1.f90 b/gcc/testsuite/gfortran.dg/use_without_only_1.f90 index 06af985..ad64b20 100644 --- a/gcc/testsuite/gfortran.dg/use_without_only_1.f90 +++ b/gcc/testsuite/gfortran.dg/use_without_only_1.f90 @@ -6,16 +6,16 @@ MODULE foo END MODULE MODULE testmod - USE foo ! { dg-warning "6:has no ONLY qualifier" } + USE foo ! { dg-warning "7:has no ONLY qualifier" } IMPLICIT NONE CONTAINS SUBROUTINE S1 - USE foo ! { dg-warning "9:has no ONLY qualifier" } + USE foo ! { dg-warning "10:has no ONLY qualifier" } END SUBROUTINE S1 SUBROUTINE S2 USE foo, ONLY: bar END SUBROUTINE 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 MODULE |