public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch][Fortran, OpenMP] Fix allocatable-components check (PR67311)
@ 2020-06-25 14:06 Tobias Burnus
  2020-07-14  6:09 ` *PING* – " Tobias Burnus
  2020-07-14  9:24 ` Jakub Jelinek
  0 siblings, 2 replies; 3+ messages in thread
From: Tobias Burnus @ 2020-06-25 14:06 UTC (permalink / raw)
  To: gcc-patches, fortran, Jakub Jelinek

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

The test case was giving an ICE as it recursively called itself.
Rather obvious fix.

OK for the trunk?

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Attachment #2: alloc-check.diff --]
[-- Type: text/x-patch, Size: 2516 bytes --]

[Fortran, OpenMP] Fix allocatable-components check (PR67311)

gcc/fortran/ChangeLog:

	PR fortran/67311
	* trans-openmp.c (gfc_has_alloc_comps): Return false also for
	pointers to arrays.

libgomp/ChangeLog:

	PR fortran/67311
	* testsuite/libgomp.fortran/target-map-1.f90: New test.

 gcc/fortran/trans-openmp.c                         |  5 +++
 libgomp/testsuite/libgomp.fortran/target-map-1.f90 | 41 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 22f8f96a60e..01d82ac11d1 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -330,6 +330,11 @@ gfc_has_alloc_comps (tree type, tree decl)
 	return false;
     }
 
+  if (GFC_DESCRIPTOR_TYPE_P (type)
+      && (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
+	  || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT))
+    return false;
+
   if (GFC_DESCRIPTOR_TYPE_P (type) || GFC_ARRAY_TYPE_P (type))
     type = gfc_get_element_type (type);
 
diff --git a/libgomp/testsuite/libgomp.fortran/target-map-1.f90 b/libgomp/testsuite/libgomp.fortran/target-map-1.f90
new file mode 100644
index 00000000000..6107530d292
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/target-map-1.f90
@@ -0,0 +1,41 @@
+! PR fortran/67311
+
+implicit none
+  TYPE myType
+    integer :: A
+    TYPE(myType), DIMENSION(:), POINTER :: x
+    TYPE(myType), DIMENSION(:), contiguous, POINTER :: y
+    integer :: B
+  END TYPE myType
+  call openmp_sub
+contains
+  subroutine openmp_sub
+    type(myType) :: argument
+
+    !$OMP PARALLEL DEFAULT(NONE) PRIVATE(argument)
+      argument%a = 5
+      argument%b = 7
+      call foo(argument)
+      if (.not.associated(argument%x) .or. size(argument%x) /= 2) stop 2
+      if (argument%a /= 8 .or. argument%b /= 9 &
+          .or. any(argument%x(:)%a /= [2, 3]) &
+          .or. any(argument%x(:)%b /= [9, 1])) stop 3
+      if (.not.associated(argument%y) .or. size(argument%y) /= 3) stop 4
+      if (any(argument%y(:)%a /= [11, 22, 33]) &
+          .or. any(argument%y(:)%b /= [44, 55, 66])) stop 5
+      deallocate (argument%x, argument%y)
+    !$OMP END PARALLEL
+  end subroutine openmp_sub
+  subroutine foo(x)
+    type(myType), intent(inout) :: x
+    !$omp declare target
+    if (x%a /= 5 .or. x%b /= 7) stop 1
+    x%a = 8; x%b = 9
+    allocate (x%x(2))
+    x%x(:)%a = [2, 3]
+    x%x(:)%b = [9, 1]
+    allocate (x%y(3))
+    x%y(:)%a = [11, 22, 33]
+    x%y(:)%b = [44, 55, 66]
+  end subroutine
+end

^ permalink raw reply	[flat|nested] 3+ messages in thread

* *PING* – Re: [Patch][Fortran, OpenMP] Fix allocatable-components check (PR67311)
  2020-06-25 14:06 [Patch][Fortran, OpenMP] Fix allocatable-components check (PR67311) Tobias Burnus
@ 2020-07-14  6:09 ` Tobias Burnus
  2020-07-14  9:24 ` Jakub Jelinek
  1 sibling, 0 replies; 3+ messages in thread
From: Tobias Burnus @ 2020-07-14  6:09 UTC (permalink / raw)
  To: gcc-patches, fortran, Jakub Jelinek

*PING*

On 6/25/20 4:06 PM, Tobias Burnus wrote:
> The test case was giving an ICE as it recursively called itself.
> Rather obvious fix.
>
> OK for the trunk?
>
> Tobias
>
> -----------------
> Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München /
> Germany
> Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung,
> Alexander Walter
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch][Fortran, OpenMP] Fix allocatable-components check (PR67311)
  2020-06-25 14:06 [Patch][Fortran, OpenMP] Fix allocatable-components check (PR67311) Tobias Burnus
  2020-07-14  6:09 ` *PING* – " Tobias Burnus
@ 2020-07-14  9:24 ` Jakub Jelinek
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2020-07-14  9:24 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, fortran

On Thu, Jun 25, 2020 at 04:06:24PM +0200, Tobias Burnus wrote:
> [Fortran, OpenMP] Fix allocatable-components check (PR67311)
> 
> gcc/fortran/ChangeLog:
> 
> 	PR fortran/67311
> 	* trans-openmp.c (gfc_has_alloc_comps): Return false also for
> 	pointers to arrays.
> 
> libgomp/ChangeLog:
> 
> 	PR fortran/67311
> 	* testsuite/libgomp.fortran/target-map-1.f90: New test.

Ok, thanks.

	Jakub


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-14  9:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 14:06 [Patch][Fortran, OpenMP] Fix allocatable-components check (PR67311) Tobias Burnus
2020-07-14  6:09 ` *PING* – " Tobias Burnus
2020-07-14  9:24 ` Jakub Jelinek

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).