This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp4] fix an ICE involving derived-typed subarray
- From: Cesar Philippidis <cesar at codesourcery dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Fortran List <fortran at gcc dot gnu dot org>
- Date: Fri, 31 Mar 2017 13:27:25 -0700
- Subject: [gomp4] fix an ICE involving derived-typed subarray
- Authentication-results: sourceware.org; auth=none
I'll apply this patch to gomp-4_0-branch shortly which fixes an ICE
triggered by using data clauses with derived-type subarray arguments.
Such subarrays can be handled generically.
Cesar
2017-03-31 Cesar Philippidis <cesar@codesourcery.com>
gcc/fortran/
* trans-openmp.c (gfc_trans_omp_clauses_1): Update handling of
subarrays with derived types elements.
libgomp/
* testsuite/libgomp.oacc-fortran/derived-type-1.f90: New test.
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index f3e1773..1d4a15b 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -2064,7 +2064,9 @@ gfc_trans_omp_clauses_1 (stmtblock_t *block, gfc_omp_clauses *clauses,
&& (n->expr->ref->next == NULL
|| (n->expr->ref->next != NULL
&& n->expr->ref->next->type == REF_ARRAY
- && n->expr->ref->next->u.ar.type == AR_FULL)))
+ && n->expr->ref->next->u.ar.type == AR_FULL))
+ && (n->expr->ref->type == REF_ARRAY
+ && n->expr->ref->u.ar.type != AR_SECTION))
{
gfc_ref *ref = n->expr->ref;
gfc_component *c = ref->u.c.component;
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/derived-type-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/derived-type-1.f90
new file mode 100644
index 0000000..19b25fc
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/derived-type-1.f90
@@ -0,0 +1,26 @@
+! Test derived types with subarrays
+
+ implicit none
+ type dtype
+ integer :: a, b, c
+ end type dtype
+ integer, parameter :: n = 100
+ integer i
+ type (dtype), dimension(n) :: d
+
+ !$acc data copy(d(1:n))
+ !$acc parallel loop
+ do i = 1, n
+ d(i)%a = i
+ d(i)%b = i-1
+ d(i)%c = i+1
+ end do
+ !$acc end data
+
+ do i = 1, n
+ if (d(i)%a /= i) call abort
+ if (d(i)%b /= i-1) call abort
+ if (d(i)%c /= i+1) call abort
+ end do
+end program
+