On 05/07/2019 15:04, Jakub Jelinek wrote:
For OpenMP, a warning is not good enough, because if Fortran PARAMETER is
not a variable, then the program is invalid and needs to be rejected.
You could improve the diagnostics by adding some explanation message that
fortran
PARAMETER is not a variable.
Got it confirmed, it might change in a future OpenMP release; and there has
been a change already in OpenMP 3.1 that might have intended to allow
Fortran PARAMETERs in firstprivate clause, but because the glossary hasn't
been changed, it is not valid even in firstprivate clause.
OK, here is an alternative patch that merely tries to make the error
message more informative.
Basically, the user needs to get past "it isn't working but I need that
value in this kernel", so hopefully this will help get them there.
WDYT?
Andrew
Tweak error message for mapped parameters.
2019-07-05 Andrew Stubbs <a...@codesourcery.com>
gcc/fortran/
* openmp.c (resolve_omp_clauses): Add custom error messages for
parameters in map clauses.
gcc/testsuite/
* gfortran.dg/gomp/map-1.f90: Update error message text.
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 1c7bce6c300..e05bf84faf2 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -4208,8 +4208,21 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
continue;
}
}
- gfc_error ("Object %qs is not a variable at %L", n->sym->name,
- &n->where);
+ if (list == OMP_LIST_MAP
+ && n->sym->attr.flavor == FL_PARAMETER)
+ {
+ if (openacc)
+ gfc_error ("Parameter %qs is not a variable at %L; it probably"
+ " doesn't need to be copied", n->sym->name,
+ &n->where);
+ else
+ gfc_error ("Parameter %qs is not a variable at %L; it probably"
+ " doesn't need to be mapped", n->sym->name,
+ &n->where);
+ }
+ else
+ gfc_error ("Object %qs is not a variable at %L", n->sym->name,
+ &n->where);
}
for (list = 0; list < OMP_LIST_NUM; list++)
diff --git a/gcc/testsuite/gfortran.dg/gomp/map-1.f90 b/gcc/testsuite/gfortran.dg/gomp/map-1.f90
index e78b56c8f39..8967b4dd0b5 100644
--- a/gcc/testsuite/gfortran.dg/gomp/map-1.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/map-1.f90
@@ -18,7 +18,7 @@ subroutine test(aas)
!$omp target map(j)
!$omp end target
- !$omp target map(p) ! { dg-error "Object 'p' is not a variable" }
+ !$omp target map(p) ! { dg-error "Parameter 'p' is not a variable" }
!$omp end target
!$omp target map(j(1))