public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [gomp4] fix an ICE involving derived-typed subarray
@ 2017-03-31 20:27 Cesar Philippidis
  0 siblings, 0 replies; only message in thread
From: Cesar Philippidis @ 2017-03-31 20:27 UTC (permalink / raw)
  To: gcc-patches, Fortran List

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

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

[-- Attachment #2: gomp4-derived-types-subarrays.diff --]
[-- Type: text/x-patch, Size: 1678 bytes --]

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
+  

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-31 20:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-31 20:27 [gomp4] fix an ICE involving derived-typed subarray Cesar Philippidis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).