Hi Tobias, On 04.12.19 14:37, Tobias Burnus 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.
I am not sure if those changes have any impact on existing diagnostics - probably not or you would have needed to change some tests in your patch. Thus, I want to confirm that this fixes the problems that I had when trying to emit warnings that referenced the location of OpenACC reduction clauses from pass_lower_omp when compiling Fortran code. Where previously inform (OMP_CLAUSE_LOCATION (some_omp_clause), "Some message."); would produce [...] /gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90:19:0: note: Some message. I now get the expected result: [...] /gcc/testsuite/gfortran.dg/goacc/nested-reductions-warn.f90:19:27: note: Some message. (Well, not completely as expected. In this case where the clause is an OpenACC reduction clause, the location of the clause is a bit off because it points to the reduction variable and not to the beginning of the clause, but that's another issue which is not related to this patch ;-) ) The existing translation of the reduction clauses has another bug. It uses the location of the first clause from the reduction list for all clauses. This could be fixed by changing the patch as follows: > @@ -1854,7 +1854,7 @@ gfc_trans_omp_reduction_list (gfc_omp_namelist > *namelist, tree list, > tree t = gfc_trans_omp_variable (namelist->sym, false); > if (t != error_mark_node) > { > - tree node = build_omp_clause (where.lb->location, > + tree node = build_omp_clause (gfc_get_location (&where), > OMP_CLAUSE_REDUCTION); > OMP_CLAUSE_DECL (node) = t; > if (mark_addressable) Here "&where" should be "&namelist->where" to use the location of the current clause. I have verified that this yields the correct locations for all clauses using the nested-reductions-warn.f90 test. Thank you for fixing this! Best regards, Frederik