aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/openmp.c
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2020-01-03 10:06:15 -0800
committerJulian Brown <julian@codesourcery.com>2020-01-28 06:00:29 -0800
commit278c3214b344ac7c5daf974196fbebc531bff058 (patch)
tree5fb64b46ceb10ceee9647519ec7b68320c82abc8 /gcc/fortran/openmp.c
parent99b9f5b4067a8c5c5a706694b9a23516126984de (diff)
downloadgcc-278c3214b344ac7c5daf974196fbebc531bff058.zip
gcc-278c3214b344ac7c5daf974196fbebc531bff058.tar.gz
gcc-278c3214b344ac7c5daf974196fbebc531bff058.tar.bz2
Don't allow mixed component and non-component accesses for OpenACC/Fortran
gcc/fortran/ * gfortran.h (gfc_symbol): Add comp_mark bitfield. * openmp.c (resolve_omp_clauses): Disallow mixed component and full-derived-type accesses to the same variable within a single directive. libgomp/ * testsuite/libgomp.oacc-fortran/deep-copy-2.f90: Remove test from here. * testsuite/libgomp.oacc-fortran/deep-copy-3.f90: Don't use mixed component/non-component variable refs in a single directive. * testsuite/libgomp.oacc-fortran/classtypes-1.f95: Likewise. gcc/testsuite/ * gfortran.dg/goacc/deep-copy-2.f90: Move test here (from libgomp testsuite). Make a compilation test, and expect rejection of mixed component/non-component accesses. * gfortran.dg/goacc/mapping-tests-1.f90: New test.
Diffstat (limited to 'gcc/fortran/openmp.c')
-rw-r--r--gcc/fortran/openmp.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 3c61385..444fdcc 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -4248,6 +4248,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
for (n = omp_clauses->lists[list]; n; n = n->next)
{
n->sym->mark = 0;
+ n->sym->comp_mark = 0;
if (n->sym->attr.flavor == FL_VARIABLE
|| n->sym->attr.proc_pointer
|| (!code && (!n->sym->attr.dummy || n->sym->ns != ns)))
@@ -4313,23 +4314,25 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
&& (list != OMP_LIST_REDUCTION || !openacc))
for (n = omp_clauses->lists[list]; n; n = n->next)
{
- bool array_only_p = true;
- /* Disallow duplicate bare variable references and multiple
- subarrays of the same array here, but allow multiple components of
- the same (e.g. derived-type) variable. For the latter, duplicate
- components are detected elsewhere. */
- if (openacc && n->expr && n->expr->expr_type == EXPR_VARIABLE)
+ bool component_ref_p = false;
+
+ /* Allow multiple components of the same (e.g. derived-type)
+ variable here. Duplicate components are detected elsewhere. */
+ if (n->expr && n->expr->expr_type == EXPR_VARIABLE)
for (gfc_ref *ref = n->expr->ref; ref; ref = ref->next)
- if (ref->type != REF_ARRAY)
- {
- array_only_p = false;
- break;
- }
- if (array_only_p)
+ if (ref->type == REF_COMPONENT)
+ component_ref_p = true;
+ if ((!component_ref_p && n->sym->comp_mark)
+ || (component_ref_p && n->sym->mark))
+ gfc_error ("Symbol %qs has mixed component and non-component "
+ "accesses at %L", n->sym->name, &n->where);
+ else if (n->sym->mark)
+ gfc_error ("Symbol %qs present on multiple clauses at %L",
+ n->sym->name, &n->where);
+ else
{
- if (n->sym->mark)
- gfc_error ("Symbol %qs present on multiple clauses at %L",
- n->sym->name, &n->where);
+ if (component_ref_p)
+ n->sym->comp_mark = 1;
else
n->sym->mark = 1;
}