diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2019-10-02 10:33:42 +0000 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2019-10-02 12:33:42 +0200 |
commit | 67c259509c0ab6475a27e871afdf12434ac34d48 (patch) | |
tree | 4059685457e50ba972a2fc329e18d9e2a647346d /libgomp | |
parent | 73a28634098cb1aba4a1773e62b6387af120dd9e (diff) | |
download | gcc-67c259509c0ab6475a27e871afdf12434ac34d48.zip gcc-67c259509c0ab6475a27e871afdf12434ac34d48.tar.gz gcc-67c259509c0ab6475a27e871afdf12434ac34d48.tar.bz2 |
Fix omp target issue with Fortran optional arguments
gcc/
* omp-low.c (lower_omp_target): Dereference optional argument
to work with the right pointer.
gcc/testsuite/
* libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90: New.
From-SVN: r276445
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90 | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90 b/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90 new file mode 100644 index 0000000..93c6121 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90 @@ -0,0 +1,36 @@ +! Test whether use_device_ptr properly handles OPTIONAL arguments +! (Only case of present arguments is tested) +program test_it + implicit none + integer, target :: ixx + integer, pointer :: ptr_i, ptr_null + + ptr_i => ixx + call foo(ptr_i) + + ptr_null => null() + call bar(ptr_null) +contains + subroutine foo(ii) + integer, pointer, optional :: ii + + if (.not.present(ii)) call abort() + if (.not.associated(ii, ixx)) call abort() + !$omp target data map(to:ixx) use_device_ptr(ii) + if (.not.present(ii)) call abort() + if (.not.associated(ii)) call abort() + !$omp end target data + end subroutine foo + + ! For bar, it is assumed that a NULL ptr on the host maps to NULL on the device + subroutine bar(jj) + integer, pointer, optional :: jj + + if (.not.present(jj)) call abort() + if (associated(jj)) call abort() + !$omp target data map(to:ixx) use_device_ptr(jj) + if (.not.present(jj)) call abort() + if (associated(jj)) call abort() + !$omp end target data + end subroutine bar +end program test_it |