Debian Codegraph @

gcc/testsuite/gfortran.dg/goacc/pure-elemental-procedures.f95

raw
1 ! { dg-do compile }
2 ! { dg-additional-options "-std=f2008 -fcoarray=single" }
3
4 module test
5 implicit none
6 contains
7 elemental subroutine test1
8 !$acc parallel ! { dg-error "may not appear in PURE procedures" }
9 !$acc serial ! { dg-error "may not appear in PURE procedures" }
10 end subroutine test1
11
12 pure subroutine test2
13 !$acc parallel ! { dg-error "may not appear in PURE procedures" }
14 !$acc serial ! { dg-error "may not appear in PURE procedures" }
15 end subroutine test2
16
17 ! Implicit pure
18 elemental real function test3(x)
19 real, intent(in) :: x
20 !$acc parallel ! { dg-error "may not appear in PURE procedures" }
21 !$acc serial ! { dg-error "may not appear in PURE procedures" }
22 test3 = x*x
23 end function test3
24
25 pure real function test4(x)
26 real, intent(in) :: x
27 !$acc parallel ! { dg-error "may not appear in PURE procedures" }
28 !$acc serial ! { dg-error "may not appear in PURE procedures" }
29 test4 = x
30 end function test4
31
32 subroutine test5
33 real :: x = 0.0
34 integer :: i
35 !$acc parallel loop collapse(1) reduction(+:x)
36 do i = 1,10
37 x = x + 0.3
38 enddo
39 !$acc serial loop collapse(1) reduction(+:x)
40 do i = 1,10
41 x = x + 0.3
42 enddo
43 print *, x
44 end subroutine test5
45
46 real function test6(x)
47 real :: x
48 integer :: i
49 !$acc parallel loop collapse(1) reduction(+:x)
50 do i = 1,10
51 x = x + 0.3
52 enddo
53 !$acc serial loop collapse(1) reduction(+:x)
54 do i = 1,10
55 x = x + 0.3
56 enddo
57 test6 = x
58 end function test6
59
60 impure elemental real function test7(x)
61 real, intent(in) :: x
62 !$acc parallel
63 test7 = x
64 !$acc end parallel
65 !$acc serial
66 test7 = x
67 !$acc end serial
68 end function test7
69
70 subroutine test8
71 real :: x = 0.0
72 integer :: i
73 !$acc parallel loop collapse(1) reduction(+:x)
74 do i = 1,10
75 critical ! { dg-error "CRITICAL block inside of" }
76 x = x + 0.3
77 end critical
78 enddo
79 !$acc serial loop collapse(1) reduction(+:x)
80 do i = 1,10
81 critical ! { dg-error "CRITICAL block inside of" }
82 x = x + 0.3
83 end critical
84 enddo
85 print *, x
86 end subroutine test8
87
88 real function test9(n)
89 integer, value :: n
90 BLOCK
91 integer i
92 real sum
93 !$acc loop reduction(+:sum)
94 do i=1, n
95 sum = sum + sin(real(i))
96 end do
97 END BLOCK
98 end function test9
99 end module test