xref: /llvm-project/flang/test/Semantics/reduce.cuf (revision 4065d985ab0f012f7fc0718685f6c12cf0352929)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2subroutine s(n,m,a,l,c)
3  integer, intent(in) :: n
4  integer, device, intent(in) :: m(n)
5  real, device, intent(in) :: a(n)
6  logical, device, intent(in) :: l(n)
7  integer j, mr
8  real ar
9  logical lr
10  complex :: cr
11  complex, device, intent(in) :: c(n)
12!$cuf kernel do <<<*,*>>> reduce (+:mr,ar)
13  do j=1,n; mr = mr + m(j); ar = ar + a(j); end do
14!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type LOGICAL(4)
15!$cuf kernel do <<<*,*>>> reduce (+:lr)
16  do j=1,n; end do
17!$cuf kernel do <<<*,*>>> reduce (*:mr,ar)
18  do j=1,n; mr = mr * m(j); ar = ar * a(j); end do
19!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type LOGICAL(4)
20!$cuf kernel do <<<*,*>>> reduce (*:lr)
21  do j=1,n; end do
22!$cuf kernel do <<<*,*>>> reduce (max:mr,ar)
23  do j=1,n; mr = max(mr,m(j)); ar = max(ar,a(j)); end do
24!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type LOGICAL(4)
25!$cuf kernel do <<<*,*>>> reduce (max:lr)
26  do j=1,n; end do
27!$cuf kernel do <<<*,*>>> reduce (min:mr,ar)
28  do j=1,n; mr = min(mr,m(j)); ar = min(ar,a(j)); end do
29!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type LOGICAL(4)
30!$cuf kernel do <<<*,*>>> reduce (min:lr)
31  do j=1,n; end do
32!$cuf kernel do <<<*,*>>> reduce (iand:mr)
33  do j=1,n; mr = iand(mr,m(j)); end do
34!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
35!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type LOGICAL(4)
36!$cuf kernel do <<<*,*>>> reduce (iand:ar,lr)
37  do j=1,n; end do
38!$cuf kernel do <<<*,*>>> reduce (ieor:mr)
39  do j=1,n; mr = ieor(mr,m(j)); end do
40!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
41!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type LOGICAL(4)
42!$cuf kernel do <<<*,*>>> reduce (ieor:ar,lr)
43  do j=1,n; end do
44!$cuf kernel do <<<*,*>>> reduce (ior:mr)
45  do j=1,n; mr = ior(mr,m(j)); end do
46!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
47!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type LOGICAL(4)
48!$cuf kernel do <<<*,*>>> reduce (ior:ar,lr)
49  do j=1,n; end do
50!$cuf kernel do <<<*,*>>> reduce (.and.:lr)
51  do j=1,n; lr = lr .and. l(j); end do
52!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type INTEGER(4)
53!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
54!$cuf kernel do <<<*,*>>> reduce (.and.:mr,ar)
55  do j=1,n; end do
56!$cuf kernel do <<<*,*>>> reduce (.eqv.:lr)
57  do j=1,n; lr = lr .eqv. l(j); end do
58!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type INTEGER(4)
59!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
60!$cuf kernel do <<<*,*>>> reduce (.eqv.:mr,ar)
61  do j=1,n; end do
62!$cuf kernel do <<<*,*>>> reduce (.neqv.:lr)
63  do j=1,n; lr = lr .neqv. l(j); end do
64!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type INTEGER(4)
65!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
66!$cuf kernel do <<<*,*>>> reduce (.neqv.:mr,ar)
67  do j=1,n; end do
68!$cuf kernel do <<<*,*>>> reduce (.or.:lr)
69  do j=1,n; lr = lr .or. l(j); end do
70!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type INTEGER(4)
71!ERROR: !$CUF KERNEL DO REDUCE operation is not acceptable for a variable with type REAL(4)
72!$cuf kernel do <<<*,*>>> reduce (.or.:mr,ar)
73  do j=1,n; end do
74!$cuf kernel do <<<*,*>>> reduce (+:cr) ! ok complex type
75  do j=1,n; cr = cr + c(j); end do
76end
77