aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2020-10-27 17:13:16 +0100
committerThomas Schwinge <thomas@codesourcery.com>2020-11-03 09:13:07 +0100
commitbeddd1762ad2bbe84dd776c54489153f83f21e56 (patch)
tree286689615ae9379690336505df761459d371cfd4 /gcc/omp-low.c
parentf5e18dd9c7dacc9671044fc669bd5c1b26b6bdba (diff)
downloadgcc-beddd1762ad2bbe84dd776c54489153f83f21e56.zip
gcc-beddd1762ad2bbe84dd776c54489153f83f21e56.tar.gz
gcc-beddd1762ad2bbe84dd776c54489153f83f21e56.tar.bz2
[OpenACC] More precise diagnostics for 'gang', 'worker', 'vector' clauses with arguments on 'loop' only allowed in 'kernels' regions
Instead of at the location of the 'loop' directive, 'error_at' the location of the improper clause, and 'inform' at the location of the enclosing parent compute construct/routine. The Fortran testcases come with some XFAILing, to be resolved later. gcc/ * omp-low.c (scan_omp_for) <OpenACC>: More precise diagnostics for 'gang', 'worker', 'vector' clauses with arguments only allowed in 'kernels' regions. gcc/testsuite/ * c-c++-common/goacc/pr92793-1.c: Extend. * gfortran.dg/goacc/pr92793-1.f90: Likewise.
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 5392fa7..de5142f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2418,30 +2418,39 @@ scan_omp_for (gomp_for *stmt, omp_context *outer_ctx)
if (!tgt || is_oacc_parallel_or_serial (tgt))
for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
{
- char const *check = NULL;
-
+ tree c_op0;
switch (OMP_CLAUSE_CODE (c))
{
case OMP_CLAUSE_GANG:
- check = "gang";
+ c_op0 = OMP_CLAUSE_GANG_EXPR (c);
break;
case OMP_CLAUSE_WORKER:
- check = "worker";
+ c_op0 = OMP_CLAUSE_WORKER_EXPR (c);
break;
case OMP_CLAUSE_VECTOR:
- check = "vector";
+ c_op0 = OMP_CLAUSE_VECTOR_EXPR (c);
break;
default:
- break;
+ continue;
}
- if (check && OMP_CLAUSE_OPERAND (c, 0))
- error_at (gimple_location (stmt),
- "argument not permitted on %qs clause in"
- " OpenACC %<parallel%> or %<serial%>", check);
+ if (c_op0)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "argument not permitted on %qs clause",
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ if (tgt)
+ inform (gimple_location (outer_ctx->stmt),
+ "enclosing parent compute construct");
+ else if (oacc_get_fn_attrib (current_function_decl))
+ inform (DECL_SOURCE_LOCATION (current_function_decl),
+ "enclosing routine");
+ else
+ gcc_unreachable ();
+ }
}
if (tgt && is_oacc_kernels (tgt))