Created attachment 49539 [details] testcase Tobias, please see the '-fdump-tree-original-lineno' dump of the testcase I'm attaching. Instead of expected line 9, the '#pragma acc kernels' has location information for line 18, which happens to be the second '#pragma acc loop'. The same happens for other OpenACC compute constructs. I have not checked OpenMP. Amongst other things, this confuses the '-fopt-info-omp-all' checking (that one's specific to OpenACC 'kernels').
Created attachment 49540 [details] Draft patch There are probably more – like 'omp sections', 'omp parallel', if I glanced at it correctly. (Search for 'input_location' after 'gfc_trans_omp_code'.)
Technically, the issue is (was): The input_location is used which is obtained when finishing the the block (= '!$acc end kernels') - or rather whatever comes before and bumps the line location.
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>: https://gcc.gnu.org/g:b71ff8c15f5a7d6b1cc1524b4d27843f0d88dbda commit r11-4942-gb71ff8c15f5a7d6b1cc1524b4d27843f0d88dbda Author: Tobias Burnus <tobias@codesourcery.com> Date: Thu Nov 12 14:13:45 2020 +0100 Fortran: improve location data for OpenACC/OpenMP directives [PR97782] gcc/fortran/ChangeLog: PR fortran/97782 * trans-openmp.c (gfc_trans_oacc_construct, gfc_trans_omp_parallel_do, gfc_trans_omp_parallel_do_simd, gfc_trans_omp_parallel_sections, gfc_trans_omp_parallel_workshare, gfc_trans_omp_sections gfc_trans_omp_single, gfc_trans_omp_task, gfc_trans_omp_teams gfc_trans_omp_target, gfc_trans_omp_target_data, gfc_trans_omp_workshare): Use code->loc instead of input_location when building the OMP_/OACC_ construct. gcc/testsuite/ChangeLog: PR fortran/97782 * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Move dg-message one line up. * gfortran.dg/goacc/classify-kernels.f95: Likewise.
The releases/gcc-10 branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>: https://gcc.gnu.org/g:5eebaff9f992814a2f8f915e436716b1b2c983df commit r10-9018-g5eebaff9f992814a2f8f915e436716b1b2c983df Author: Tobias Burnus <tobias@codesourcery.com> Date: Thu Nov 12 14:16:53 2020 +0100 Fortran: improve location data for OpenACC/OpenMP directives [PR97782] gcc/fortran/ChangeLog: PR fortran/97782 * trans-openmp.c (gfc_trans_oacc_construct, gfc_trans_omp_parallel_do, gfc_trans_omp_parallel_do_simd, gfc_trans_omp_parallel_sections, gfc_trans_omp_parallel_workshare, gfc_trans_omp_sections gfc_trans_omp_single, gfc_trans_omp_task, gfc_trans_omp_teams gfc_trans_omp_target, gfc_trans_omp_target_data, gfc_trans_omp_workshare): Use code->loc instead of input_location when building the OMP_/OACC_ construct. gcc/testsuite/ChangeLog: PR fortran/97782 * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Move dg-message one line up. * gfortran.dg/goacc/classify-kernels.f95: Likewise. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> (cherry picked from commit b71ff8c15f5a7d6b1cc1524b4d27843f0d88dbda)
FIXED for mainline (GCC 11) and GCC 10. If the testcase is not covered by your upcoming patch merges, feel free to commit it yourself (or tell me to commit it for you). Thanks for the report!
The master branch has been updated by Thomas Schwinge <tschwinge@gcc.gnu.org>: https://gcc.gnu.org/g:9106c51e57c06e88a0dddf994fb5432b4bbe68c0 commit r11-4951-g9106c51e57c06e88a0dddf994fb5432b4bbe68c0 Author: Thomas Schwinge <thomas@codesourcery.com> Date: Thu Nov 12 20:07:25 2020 +0100 Adjust 'libgomp.oacc-fortran/attach-descriptor-1.f90' for improved location information Fix-up for commit b71ff8c15f5a7d6b1cc1524b4d27843f0d88dbda "Fortran: improve location data for OpenACC/OpenMP directives [PR97782]". libgomp/ PR fortran/97782 * testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90: Adjust.