[Patch] Fortran: improve location data for OpenACC/OpenMP directives [PR97782]

Tobias Burnus tobias@codesourcery.com
Thu Nov 12 11:45:24 GMT 2020

For code like
  !$acc kernels
     ... a lot of loops and other code
  !$acc end kernels

gfortran generates
   #pragma ..._kernels
       ... lot of code

As the PR shows, the location associated with the #pragma
is not the 'acc kernels' line but the one near the 'acc end kernel'

The reason is that first the {...} code is generated and only then
the outer #pragma. And using input_location as location then points to
the wrong line:
  oacc_clauses = gfc_trans_omp_clauses (...) // fine so far
  stmt = gfc_trans_omp_code (code->block->next, true); // translates {...}
  stmt = build2_loc (input_location, construct_code, ... // wrong location

This patch tries to fix this in most cases; I am sure I missed some and
others could be handled better.

In the testsuite, it affects two tests by moving a 'dg-message' line with
   optimized: assigned OpenACC gang loop parallelism
from the loop-line one up to the 'kernels'-line; I think either location
is fine.

The PR has a testcase (not included) which works with -fopt-info-omp-all.
In principle, it should also have an effect on warnings (if there are
any) and it unsurprisingly affects --fdump-tree-*-lineno.

Comments, remarks, does it look good to you?


Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ompacc-loc.diff
Type: text/x-patch
Size: 9559 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201112/f9cb59ea/attachment.bin>

More information about the Gcc-patches mailing list