[OpenACC] XFAIL behavior of over-eager 'finalize' clause
[gcc.git] / libgomp / testsuite / libgomp.oacc-fortran / mdc-refcount-1-2-1.f90
1 ! { dg-do run }
2 ! { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } }
3
4 ! Adapted from 'libgomp.oacc-fortran/mdc-refcount-1-1-1.f90'.
5
6 program main
7 use openacc
8 implicit none
9 integer, parameter :: n = 512
10 type mytype
11 integer, allocatable :: a(:)
12 end type mytype
13 type(mytype) :: var
14
15 allocate(var%a(1:n))
16
17 !$acc data create(var)
18
19 call acc_create(var%a)
20 ! After mapping via runtime API call, separately trigger attach action; see <https://github.com/OpenACC/openacc-spec/issues/301>.
21 !$acc enter data attach(var%a)
22
23 if (.not. acc_is_present(var%a)) stop 1
24 if (.not. acc_is_present(var)) stop 2
25
26 !$acc exit data delete(var%a) finalize
27 if (acc_is_present(var%a)) stop 3
28 print *, "CheCKpOInT1"
29 ! { dg-output ".*CheCKpOInT1(\n|\r\n|\r)" }
30 if (.not. acc_is_present(var)) stop 4
31 !TODO { dg-output "STOP 4(\n|\r\n|\r)$" { target { ! openacc_host_selected } } } ! Scan for what we expect in the "XFAILed" case (without actually XFAILing).
32 !TODO { dg-shouldfail "XFAILed" { ! openacc_host_selected } } ! ... instead of 'dg-xfail-run-if' so that 'dg-output' is evaluated at all.
33 !TODO { dg-final { if { [dg-process-target { xfail { ! openacc_host_selected } }] == "F" } { xfail "[testname-for-summary] really is XFAILed" } } } ! ... so that we still get an XFAIL visible in the log.
34 print *, "CheCKpOInT2"
35 ! { dg-output ".CheCKpOInT2(\n|\r\n|\r)" { target { openacc_host_selected } } }
36
37 !$acc end data
38 if (acc_is_present(var%a)) stop 5
39 if (acc_is_present(var)) stop 6
40
41 deallocate(var%a)
42
43 end program main