From: Tobias Burnus Date: Fri, 4 Oct 2019 09:29:31 +0000 (+0200) Subject: [Fortran] Fix column of %C diagnostic location X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=981e39974ea31cb418507eadcb2cd7bbdf27ed79;p=gcc.git [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 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9a2a800408b..196b40b950c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2019-10-04 Tobias Burnus + + * error (error_print, gfc_format_decoder): Fix off-by one issue with %C. + 2019-10-03 Steven G. Kargl 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 - * 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 a7c27f0c3fe..1019f17d73c 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 60e6caa2520..b8c9f4cd663 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-10-04 Tobias Burnus + + * gfortran.dg/use_without_only_1.f90: Update column num in dg-warning. + 2019-10-04 Jakub Jelinek 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 06af9853933..ad64b206b76 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