From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id DB090383E82A; Tue, 3 Nov 2020 08:26:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DB090383E82A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Thomas_Schwinge@mentor.com IronPort-SDR: Si9LrkhoxMuaE6cqgH0SNCn0c4Vg10QdyfKJw2mHqcgXUR05YkZgzgK9dzl51w8hUgI7Ulqf14 6tmiqo3WJfnJ1o6R7/Ae1a58fyO+yFkY8uCRaUo5G9AZtmfaHkSbisiUNhf3HfTI8DsLIxuzh4 N/DXZkpenpi7A34CRHo82+0kMhcPSJW3wFfHSg4ZCluXam3gNIfDJ/RGa872cbaI3qAnubwCfk 0F+CghtvyamwcUWnxoQ+lW/0d7bvu6/Zh7wXoXuXRoZW4cGNtEwu4TuS6+EUUq2hkcX1pPM6Tu xy8= X-IronPort-AV: E=Sophos;i="5.77,447,1596528000"; d="scan'208,223";a="54739557" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 03 Nov 2020 00:26:20 -0800 IronPort-SDR: gyzmNbI79frfujS2KrBv3qqviKBPGKPDdBlHujoxehqYpLPp89y4EZOQejqfHBQtpRrR4t5CIF xIa6bVVSycRFUw8Ta1lLroQa9JnIF7b7RKxulCdBhTPU2jzDHBnBBrUK+CllVq+n7PvzjlaaA3 eh6CcqEKsNOVGmHIJbBXYvaDbDV3T/m/7x16LMKYW8UJErqUOgr5rQ95cVfWPCO3SvtYvJCpts WCcQdD1OFNmwhl8fRQD/n9T4DngwgN2TSIQBxXHbtCg8fcVw6q/L78m+e/dL2pDl0phDeanhiU DB0= From: Thomas Schwinge To: , CC: Frederik Harwath , Tobias Burnus Subject: Re: [PATCH] Fix column information for omp_clauses in Fortran code In-Reply-To: <0624ce85-2ee7-38eb-d115-509d600d3f20@codesourcery.com> References: <2f70a48d-ba2e-bc37-314b-7758a9ac1e0a@codesourcery.com> <0624ce85-2ee7-38eb-d115-509d600d3f20@codesourcery.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Tue, 3 Nov 2020 09:26:14 +0100 Message-ID: <87a6vyg82h.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LOTSOFHASH, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Nov 2020 08:26:24 -0000 --=-=-= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi! On 2019-12-09T16:58:44+0100, "Harwath, Frederik" wrote: > Tobias has recently fixed a problem with the column information in gfortr= an locations > ("PR 92793 - fix column used for error diagnostic"). In context of: > [use] the location of clauses in warnings instead of the location of the = loop to which the clause belongs. ..., Frederik then did: > Subject: [PATCH] Fix column information for omp_clauses in Fortran code > > The location of all OpenMP/OpenACC clauses on any given line in Fortran c= ode > always points to the first clause on that line. Hence, the column informa= tion > is wrong for all clauses but the first one. > > Use the correct location for each clause instead. Actually, that was specific for 'reduction' clauses: > --- a/gcc/fortran/trans-openmp.c > +++ b/gcc/fortran/trans-openmp.c > @@ -1982,7 +1982,7 @@ gfc_trans_omp_reduction_list (gfc_omp_namelist *nam= elist, tree list, > tree t =3D gfc_trans_omp_variable (namelist->sym, false); > if (t !=3D error_mark_node) > { > - tree node =3D build_omp_clause (gfc_get_location (&where), > + tree node =3D build_omp_clause (gfc_get_location (&namelist->wh= ere), > OMP_CLAUSE_REDUCTION); Similar changes are desirable for other directives/clauses, too. I've just pushed "[Fortran] More precise location information for OpenACC 'gang', 'worker', 'vector' clauses with argument [PR92793]" to master branch in commit 41f7f6178e2d35288273656dc55dae8fcf3edeb5, and backported to releases/gcc-10 in commit 5ceaf8a54abb3f9bd3c268fe420999a7962b2a15, see attached. Gr=C3=BC=C3=9Fe Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstra=C3=9Fe 201, 80634 M=C3=BCnch= en / Germany Registergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas = Heurung, Alexander Walter --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename="0001-Fortran-More-precise-location-information-for-OpenAC.patch" >From 41f7f6178e2d35288273656dc55dae8fcf3edeb5 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 27 Oct 2020 17:14:10 +0100 Subject: [PATCH] [Fortran] More precise location information for OpenACC 'gang', 'worker', 'vector' clauses with argument [PR92793] gcc/fortran/ PR fortran/92793 * trans-openmp.c (gfc_trans_omp_clauses): More precise location information for OpenACC 'gang', 'worker', 'vector' clauses with argument. gcc/testsuite/ PR fortran/92793 * gfortran.dg/goacc/pr92793-1.f90: Adjust. --- gcc/fortran/trans-openmp.c | 40 ++++++++++++------- gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 | 29 +++++--------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index d02949ecbe4a..1d652a09f9d2 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -3771,34 +3771,38 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, } if (clauses->vector) { + c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_VECTOR); + omp_clauses = gfc_trans_add_clause (c, omp_clauses); + if (clauses->vector_expr) { tree vector_var = gfc_convert_expr_to_tree (block, clauses->vector_expr); - c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_VECTOR); OMP_CLAUSE_VECTOR_EXPR (c) = vector_var; - omp_clauses = gfc_trans_add_clause (c, omp_clauses); - } - else - { - c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_VECTOR); - omp_clauses = gfc_trans_add_clause (c, omp_clauses); + + /* TODO: We're not capturing location information for individual + clauses. However, if we have an expression attached to the + clause, that one provides better location information. */ + OMP_CLAUSE_LOCATION (c) + = gfc_get_location (&clauses->vector_expr->where); } } if (clauses->worker) { + c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_WORKER); + omp_clauses = gfc_trans_add_clause (c, omp_clauses); + if (clauses->worker_expr) { tree worker_var = gfc_convert_expr_to_tree (block, clauses->worker_expr); - c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_WORKER); OMP_CLAUSE_WORKER_EXPR (c) = worker_var; - omp_clauses = gfc_trans_add_clause (c, omp_clauses); - } - else - { - c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_WORKER); - omp_clauses = gfc_trans_add_clause (c, omp_clauses); + + /* TODO: We're not capturing location information for individual + clauses. However, if we have an expression attached to the + clause, that one provides better location information. */ + OMP_CLAUSE_LOCATION (c) + = gfc_get_location (&clauses->worker_expr->where); } } if (clauses->gang) @@ -3806,11 +3810,19 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, tree arg; c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_GANG); omp_clauses = gfc_trans_add_clause (c, omp_clauses); + if (clauses->gang_num_expr) { arg = gfc_convert_expr_to_tree (block, clauses->gang_num_expr); OMP_CLAUSE_GANG_EXPR (c) = arg; + + /* TODO: We're not capturing location information for individual + clauses. However, if we have an expression attached to the + clause, that one provides better location information. */ + OMP_CLAUSE_LOCATION (c) + = gfc_get_location (&clauses->gang_num_expr->where); } + if (clauses->gang_static) { arg = clauses->gang_static_expr diff --git a/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 b/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 index 23d6886580a1..4651ccffaa1f 100644 --- a/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 @@ -52,13 +52,10 @@ subroutine gwv_sl () integer :: i !$acc serial loop & - !$acc & gang(num:5) & ! { dg-error "argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } .+6 } - !$acc & worker(num:5) & ! { dg-error "argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } .+4 } - !$acc & vector(length:5) & ! { dg-error "argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } } - !$acc & ! { dg-bogus "14: argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } .+2 } - ! { dg-message "99: enclosing parent compute construct" "" { target *-*-* } .-1 } + !$acc & gang(num:5) & ! { dg-error "25: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "24: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "28: argument not permitted on 'vector' clause" } + ! { dg-message "93: enclosing parent compute construct" "" { target *-*-* } .-1 } do i = 0, 10 end do !$acc end serial loop @@ -70,12 +67,9 @@ subroutine gwv_s_l () !$acc serial ! { dg-message "72: enclosing parent compute construct" } !$acc loop & - !$acc & gang(num:5) & ! { dg-error "argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } .+5 } - !$acc & worker(num:5) & ! { dg-error "argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } .+3 } - !$acc & vector(length:5) & ! { dg-error "argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } } - !$acc & ! { dg-bogus "14: argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } .+1 } + !$acc & gang(num:5) & ! { dg-error "27: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "23: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "29: argument not permitted on 'vector' clause" } do i = 0, 10 end do !$acc end serial @@ -88,12 +82,9 @@ subroutine gwv_r () ! { dg-message "16: enclosing routine" } !$acc routine(gwv_r) !$acc loop & - !$acc & gang(num:5) & ! { dg-error "argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } .+5 } - !$acc & worker(num:5) & ! { dg-error "argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } .+3 } - !$acc & vector(length:5) & ! { dg-error "argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } } - !$acc & ! { dg-bogus "14: argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } .+1 } + !$acc & gang(num:5) & ! { dg-error "23: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "26: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "27: argument not permitted on 'vector' clause" } do i = 0, 10 end do end subroutine gwv_r -- 2.17.1 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename="0001-Fortran-More-precise-location-information-for-Op.g10.patch" >From 5ceaf8a54abb3f9bd3c268fe420999a7962b2a15 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 27 Oct 2020 17:14:10 +0100 Subject: [PATCH] [Fortran] More precise location information for OpenACC 'gang', 'worker', 'vector' clauses with argument [PR92793] gcc/fortran/ PR fortran/92793 * trans-openmp.c (gfc_trans_omp_clauses): More precise location information for OpenACC 'gang', 'worker', 'vector' clauses with argument. gcc/testsuite/ PR fortran/92793 * gfortran.dg/goacc/pr92793-1.f90: Adjust. (cherry picked from commit 41f7f6178e2d35288273656dc55dae8fcf3edeb5) --- gcc/fortran/trans-openmp.c | 40 ++++++++++++------- gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 | 29 +++++--------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index c01c4d792195..b3d31c560435 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -3523,34 +3523,38 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, } if (clauses->vector) { + c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_VECTOR); + omp_clauses = gfc_trans_add_clause (c, omp_clauses); + if (clauses->vector_expr) { tree vector_var = gfc_convert_expr_to_tree (block, clauses->vector_expr); - c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_VECTOR); OMP_CLAUSE_VECTOR_EXPR (c) = vector_var; - omp_clauses = gfc_trans_add_clause (c, omp_clauses); - } - else - { - c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_VECTOR); - omp_clauses = gfc_trans_add_clause (c, omp_clauses); + + /* TODO: We're not capturing location information for individual + clauses. However, if we have an expression attached to the + clause, that one provides better location information. */ + OMP_CLAUSE_LOCATION (c) + = gfc_get_location (&clauses->vector_expr->where); } } if (clauses->worker) { + c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_WORKER); + omp_clauses = gfc_trans_add_clause (c, omp_clauses); + if (clauses->worker_expr) { tree worker_var = gfc_convert_expr_to_tree (block, clauses->worker_expr); - c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_WORKER); OMP_CLAUSE_WORKER_EXPR (c) = worker_var; - omp_clauses = gfc_trans_add_clause (c, omp_clauses); - } - else - { - c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_WORKER); - omp_clauses = gfc_trans_add_clause (c, omp_clauses); + + /* TODO: We're not capturing location information for individual + clauses. However, if we have an expression attached to the + clause, that one provides better location information. */ + OMP_CLAUSE_LOCATION (c) + = gfc_get_location (&clauses->worker_expr->where); } } if (clauses->gang) @@ -3558,11 +3562,19 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, tree arg; c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_GANG); omp_clauses = gfc_trans_add_clause (c, omp_clauses); + if (clauses->gang_num_expr) { arg = gfc_convert_expr_to_tree (block, clauses->gang_num_expr); OMP_CLAUSE_GANG_EXPR (c) = arg; + + /* TODO: We're not capturing location information for individual + clauses. However, if we have an expression attached to the + clause, that one provides better location information. */ + OMP_CLAUSE_LOCATION (c) + = gfc_get_location (&clauses->gang_num_expr->where); } + if (clauses->gang_static) { arg = clauses->gang_static_expr diff --git a/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 b/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 index 23d6886580a1..4651ccffaa1f 100644 --- a/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 @@ -52,13 +52,10 @@ subroutine gwv_sl () integer :: i !$acc serial loop & - !$acc & gang(num:5) & ! { dg-error "argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } .+6 } - !$acc & worker(num:5) & ! { dg-error "argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } .+4 } - !$acc & vector(length:5) & ! { dg-error "argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } } - !$acc & ! { dg-bogus "14: argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } .+2 } - ! { dg-message "99: enclosing parent compute construct" "" { target *-*-* } .-1 } + !$acc & gang(num:5) & ! { dg-error "25: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "24: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "28: argument not permitted on 'vector' clause" } + ! { dg-message "93: enclosing parent compute construct" "" { target *-*-* } .-1 } do i = 0, 10 end do !$acc end serial loop @@ -70,12 +67,9 @@ subroutine gwv_s_l () !$acc serial ! { dg-message "72: enclosing parent compute construct" } !$acc loop & - !$acc & gang(num:5) & ! { dg-error "argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } .+5 } - !$acc & worker(num:5) & ! { dg-error "argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } .+3 } - !$acc & vector(length:5) & ! { dg-error "argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } } - !$acc & ! { dg-bogus "14: argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } .+1 } + !$acc & gang(num:5) & ! { dg-error "27: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "23: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "29: argument not permitted on 'vector' clause" } do i = 0, 10 end do !$acc end serial @@ -88,12 +82,9 @@ subroutine gwv_r () ! { dg-message "16: enclosing routine" } !$acc routine(gwv_r) !$acc loop & - !$acc & gang(num:5) & ! { dg-error "argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'gang' clause" "TODO" { xfail *-*-* } .+5 } - !$acc & worker(num:5) & ! { dg-error "argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } } - !$acc & & ! { dg-bogus "14: argument not permitted on 'worker' clause" "TODO" { xfail *-*-* } .+3 } - !$acc & vector(length:5) & ! { dg-error "argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } } - !$acc & ! { dg-bogus "14: argument not permitted on 'vector' clause" "TODO" { xfail *-*-* } .+1 } + !$acc & gang(num:5) & ! { dg-error "23: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "26: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "27: argument not permitted on 'vector' clause" } do i = 0, 10 end do end subroutine gwv_r -- 2.17.1 --=-=-=--