aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-09-30 14:59:27 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-09-30 14:59:27 +0200
commit8b0a63e47cd83f4e8534d0d201739bdd10f321a2 (patch)
tree9331e8dd74b5c1ff5758a9de0a08daa18cd3ad16 /libgomp
parentfcc4891d7f3bff1a3f7428f12830bc942989306c (diff)
downloadgcc-8b0a63e47cd83f4e8534d0d201739bdd10f321a2.zip
gcc-8b0a63e47cd83f4e8534d0d201739bdd10f321a2.tar.gz
gcc-8b0a63e47cd83f4e8534d0d201739bdd10f321a2.tar.bz2
OpenMP: Add implicit declare target for nested procedures
gcc/ChangeLog: * omp-offload.c (omp_discover_implicit_declare_target): Also handled nested functions. libgomp/ChangeLog: * testsuite/libgomp.fortran/declare-target-3.f90: New test.
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/testsuite/libgomp.fortran/declare-target-3.f9045
1 files changed, 45 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.fortran/declare-target-3.f90 b/libgomp/testsuite/libgomp.fortran/declare-target-3.f90
new file mode 100644
index 0000000..6e5301d
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/declare-target-3.f90
@@ -0,0 +1,45 @@
+! { dg-additional-options "-fdump-tree-omplower" }
+
+module m
+ implicit none (type, external)
+contains
+ subroutine mod_proc(x)
+ integer :: x(2)
+ x = x + 5
+ end subroutine
+end module m
+
+program main
+ use m
+ implicit none (type, external)
+ if (any (foo() /= [48, 49])) stop 1
+contains
+ integer function fourty_two(y)
+ integer :: y
+ fourty_two = y + 42
+ end function
+
+ integer function wrapper (x, y)
+ integer :: x, y(2)
+ call mod_proc(y)
+ wrapper = fourty_two(x) + 1
+ end function
+
+ function foo()
+ integer :: foo(2)
+ integer :: a(2)
+ integer :: b, summed(2)
+ a = [1, 2]
+ b = -1
+ !$omp target map (tofrom: a, b, summed)
+ summed = wrapper (b, a)
+ !$omp end target
+ if (b /= -1) stop 2 ! unchanged
+ if (any (summed /= 42)) stop 3 ! b + 42 + 1 = 42
+ if (any (a /= [6, 7])) stop 4 ! [1, 2] + 5
+ foo = summed + a ! [48, 49]
+ end function
+end
+
+! 3 times: mod_proc, fourty_two and wrapper:
+! { dg-final { scan-tree-dump-times "__attribute__..omp declare target" 3 "omplower" } }