This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[fortran, patch] PR32467 - structure containing allocatable array is wrongly accepted
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, jakub at gcc dot gnu dot org
- Date: Sun, 24 Jun 2007 20:39:07 +0200
- Subject: [fortran, patch] PR32467 - structure containing allocatable array is wrongly accepted
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:subject:date:user-agent:mime-version:content-type:message-id; b=P8vb7IpfAoCJfngxB0LY0K+wASKuYpoxUC2yXQgIFXDlq4fs4BZEubuCVTEniCUz35zDavrRxknUdddksXbvIeTe9L4oWqYdsqy5TtpZ0SseKTP1/lY0msiH2WOIu7gUKZhMmAWoAN0uOA1I15p/uOl2P3heFtnxbrZmvdmOhhA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:to:subject:date:user-agent:mime-version:content-type:message-id; b=pIFY/vM+jScOnazXmMR4zKnNvY7WBHGjX/BT1YHw0pOiEHS7Zn9f4TOU0f5mY33t/QE25TnZE0DzqeiRbIyIETTBj6UHCfNI6eyPjUQJ9+0X8PiFtU8jHi2/EQpqPmNyKGWzPW6HZHw4CfonRvs575dq6Sp6I8yPsI3B0gfCWIY=
As allocatable components in derived types are not part of F95, OpenMP v2.5
does not allow such in clauses where allocatable arrays are not allowed.
These clauses are: COPYIN, COPYPRIVATE, FIRSTPRIVATE, LASTPRIVATE, REDUCTION.
:ADDPATCH fortran:
2007-06-24 Daniel Franke <franke.daniel@gmail.com>
PR fortran/32467
* openmp.c (resolve_omp_clauses): Emit error on allocatable components
in COPYIN, COPYPRIVATE, FIRSTPRIVATE, LASTPRIVATE and REDUCTION clauses.
2007-06-24 Daniel Franke <franke.daniel@gmail.com>
PR fortran/32467
* gfortran.dg/gomp/allocatable_components_1.f90: New test.
Bootstrapped and regression tested on i686-pc-linux-gnu. Ok for trunk?
Regards
Daniel
Index: fortran/openmp.c
===================================================================
--- fortran/openmp.c (revision 125970)
+++ fortran/openmp.c (working copy)
@@ -779,6 +779,9 @@
if (n->sym->attr.allocatable)
gfc_error ("COPYIN clause object '%s' is ALLOCATABLE at %L",
n->sym->name, &code->loc);
+ if (n->sym->ts.type == BT_DERIVED && n->sym->ts.derived->attr.alloc_comp)
+ gfc_error ("COPYIN clause object '%s' at %L has ALLOCATABLE components",
+ n->sym->name, &code->loc);
}
break;
case OMP_LIST_COPYPRIVATE:
@@ -790,6 +793,9 @@
if (n->sym->attr.allocatable)
gfc_error ("COPYPRIVATE clause object '%s' is ALLOCATABLE "
"at %L", n->sym->name, &code->loc);
+ if (n->sym->ts.type == BT_DERIVED && n->sym->ts.derived->attr.alloc_comp)
+ gfc_error ("COPYPRIVATE clause object '%s' at %L has ALLOCATABLE components",
+ n->sym->name, &code->loc);
}
break;
case OMP_LIST_SHARED:
@@ -820,6 +826,9 @@
if (n->sym->attr.allocatable)
gfc_error ("%s clause object '%s' is ALLOCATABLE at %L",
name, n->sym->name, &code->loc);
+ if (n->sym->ts.type == BT_DERIVED && n->sym->ts.derived->attr.alloc_comp)
+ gfc_error ("%s clause object '%s' has ALLOCATABLE components at %L",
+ name, n->sym->name, &code->loc);
if (n->sym->attr.cray_pointer)
gfc_error ("Cray pointer '%s' in %s clause at %L",
n->sym->name, name, &code->loc);
Index: testsuite/gfortran.dg/gomp/allocatable_components_1.f90
===================================================================
--- testsuite/gfortran.dg/gomp/allocatable_components_1.f90 (revision 0)
+++ testsuite/gfortran.dg/gomp/allocatable_components_1.f90 (revision 0)
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! PR fortran/32467
+! Derived types with allocatable components in COPYIN
+!
+! Contributed by Bill Long <longb AT cray DOT com>
+!
+
+ type structure_1
+ integer, allocatable :: a(:)
+ end type structure_1
+ type(structure_1), save :: struc1
+
+!$omp threadprivate(struc1)
+!$omp parallel copyin(struc1) ! { dg-error "has ALLOCATABLE components" }
+ ! do something
+!$omp end parallel
+
+ END