From: Thomas Schwinge <thomas@codesourcery.com>
To: Tobias Burnus <tobias@codesourcery.com>,
<gcc-patches@gcc.gnu.org>, <fortran@gcc.gnu.org>
Subject: Re: [Patch, Fortran] PR 92793 - fix column used for error diagnostic
Date: Fri, 30 Oct 2020 11:47:00 +0100 [thread overview]
Message-ID: <87ft5wgfdn.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <87k0v8gfx8.fsf@euler.schwinge.homeip.net>
[-- Attachment #1: Type: text/plain, Size: 1718 bytes --]
Hi!
On 2020-10-30T11:35:15+0100, I wrote:
> On 2019-12-04T14:37:55+0100, Tobias Burnus <tobias@codesourcery.com> wrote:
>> As reported internally by Frederik, gfortran currently passes
>> LOCATION_COLUMN == 0 to the middle end. The reason for that is how
>> parsing works – gfortran reads the input line by line.
>>
>> For internal error diagnostic (fortran/error.c), the column location was
>> corrected – but not for locations passed to the middle end. Hence, the
>> diagnostic there wasn't optimal.
>
> Thanks for fixing that aspect.
While working on something completely different -- of course... ;-) -- I
ran into:
>> Fixed by introducing a new function; now one only needs to make sure
>> that no new code will re-introduce "lb->location" :-)
... another *existing instance* of this problem.
>> - space = build_decl (sym->declared_at.lb->location,
>> + space = build_decl (gfc_get_location (&sym->declared_at),
The same change is required in
'gcc/fortran/trans.c:gfc_set_backend_locus'.
That took me a while to figure out... :-| In OMP offloading compilation
I saw diagnostics *with* column location information for C, C++, but the
very same diagnostics *without* column location information for Fortran.
Once I had some understood the Fortran front end locaiton processing --
uh... ;-\ -- I came up with the attached patch to "Further improve
Fortran column location information [PR92793]". OK to push? (No
testsuite regressions.)
Grüße
Thomas
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Further-improve-Fortran-column-location-information-.patch --]
[-- Type: text/x-diff, Size: 4987 bytes --]
From 3f284dd076b313c2ffbd02a8d7327118ce910c49 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 29 Oct 2020 14:42:28 +0100
Subject: [PATCH] Further improve Fortran column location information [PR92793]
Building on top of commit 9c81750c5bedd7883182ee2684a012c6210ebe1d "Fortran] PR
92793 - fix column used for error diagnostic", there is another place where we
have to use 'gfc_get_location' returning column-corrected locations.
For example, this improves column location information for OMP constructs.
gcc/fortran/
PR fortran/92793
* trans.c (gfc_set_backend_locus): Use 'gfc_get_location'.
gcc/testsuite/
PR fortran/92793
* gfortran.dg/goacc/pr92793-1.f90: Adjust.
---
gcc/fortran/trans.c | 2 +-
gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 | 24 +++++++++----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index 8caa625ab0e8..72ea24125232 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -1829,7 +1829,7 @@ void
gfc_set_backend_locus (locus * loc)
{
gfc_current_backend_file = loc->lb->file;
- input_location = loc->lb->location;
+ input_location = gfc_get_location (loc);
}
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 b/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90
index a572c6b3437b..72dd6b7b8f81 100644
--- a/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90
@@ -13,22 +13,22 @@ subroutine check ()
integer :: i, j, sum, diff
!$acc parallel &
- !$acc & & ! Fortran location information points to the last line of the directive, and there is no column location information.
-!$acc && ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:18:0\\\] #pragma acc parallel" 1 "original" } }
- !$acc & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:18:0\\\] #pragma omp target oacc_parallel" 1 "gimple" } }
+ !$acc & & ! Fortran location information points to the last line, and last character of the directive.
+!$acc && ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:18:123\\\] #pragma acc parallel" 1 "original" } }
+ !$acc & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:18:123\\\] #pragma omp target oacc_parallel" 1 "gimple" } }
!$acc loop &
- !$acc & & ! Fortran location information points to the last line of the directive, and there is no column location information.
- !$acc & & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:26:0\\\] #pragma acc loop" 1 "original" } }
- !$acc & & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:26:0\\\] #pragma acc loop" 1 "gimple" } }
+ !$acc & & ! Fortran location information points to the last line, and last character of the directive.
+ !$acc & & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:26:22\\\] #pragma acc loop" 1 "original" } }
+ !$acc & & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:26:22\\\] #pragma acc loop" 1 "gimple" } }
!$acc& reduction ( + : sum ) & ! { dg-line sum1 }
!$acc && ! Fortran location information points to the ':' in 'reduction(+:sum)'.
!$acc & & ! { dg-message "36: location of the previous reduction for 'sum'" "" { target *-*-* } sum1 }
!$acc& independent
do i = 1, 10
!$acc loop &
-!$acc & & ! Fortran location information points to the last line of the directive, and there is no column location information.
- !$acc & & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:36:0\\\] #pragma acc loop" 1 "original" } }
- !$acc & & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:36:0\\\] #pragma acc loop" 1 "gimple" } }
+!$acc & & ! Fortran location information points to the last line, and last character of the directive.
+ !$acc & & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:36:34\\\] #pragma acc loop" 1 "original" } }
+ !$acc & & ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:36:34\\\] #pragma acc loop" 1 "gimple" } }
!$acc & reduction(-: diff ) &
!$acc&reduction(- : sum) & ! { dg-line sum2 }
!$acc & & ! Fortran location information points to the ':' in 'reduction(-:sum)'.
@@ -38,9 +38,9 @@ subroutine check ()
sum &
& = &
& 1
- ! Fortran location information points to the last line of the statement, and there is no column location information.
- ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:40:0\\\] sum = 1" 1 "original" } }
- ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:40:0\\\] sum = 1" 1 "gimple" } }
+ ! Fortran location information points to the last line, and last character of the statement.
+ ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:40:9\\\] sum = 1" 1 "original" } }
+ ! { dg-final { scan-tree-dump-times "pr92793-1\\\.f90:40:9\\\] sum = 1" 1 "gimple" } }
end do
end do
!$acc end parallel
--
2.17.1
next prev parent reply other threads:[~2020-10-30 10:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 13:38 Tobias Burnus
2019-12-04 14:30 ` Harwath, Frederik
2019-12-06 8:02 ` *PING* – " Tobias Burnus
2019-12-06 16:42 ` Janne Blomqvist
2019-12-09 15:58 ` [PATCH] Fix column information for omp_clauses in Fortran code Harwath, Frederik
2019-12-09 16:03 ` Tobias Burnus
2019-12-10 14:23 ` [PATCH 1/2] Use clause locations in OpenACC nested reduction warnings Frederik Harwath
2019-12-10 14:23 ` [PATCH 2/2] Add tests to verify OpenACC clause locations Frederik Harwath
2019-12-10 14:23 ` [PATCH 0/2] " Frederik Harwath
2019-12-10 14:44 ` Thomas Schwinge
2019-12-10 15:12 ` Harwath, Frederik
2019-12-10 16:22 ` Harwath, Frederik
2019-12-11 8:38 ` [PATCH, committed] Fix PR92901: Change test expectation for C++ in OpenACC test clause-locations.c Harwath, Frederik
2020-11-03 8:17 ` [PATCH 0/2] Add tests to verify OpenACC clause locations Thomas Schwinge
2020-11-03 21:34 ` Thomas Schwinge
2020-11-03 8:26 ` [PATCH] Fix column information for omp_clauses in Fortran code Thomas Schwinge
2020-10-30 10:35 ` [Patch, Fortran] PR 92793 - fix column used for error diagnostic Thomas Schwinge
2020-10-30 10:47 ` Thomas Schwinge [this message]
2020-10-30 11:16 ` Tobias Burnus
2020-11-02 13:43 ` Thomas Schwinge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ft5wgfdn.fsf@euler.schwinge.homeip.net \
--to=thomas@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=tobias@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).