xref: /llvm-project/flang/test/Semantics/OpenMP/reduction14.f90 (revision f44023980de08c7554c4b735ca8e467c32b2f4f7)
1*f4402398STom Eccles! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2*f4402398STom Eccles! OpenMP Version 4.5
3*f4402398STom Eccles! 2.15.3.6 Reduction Clause
4*f4402398STom Ecclesprogram omp_reduction
5*f4402398STom Eccles  integer :: i
6*f4402398STom Eccles  real :: r
7*f4402398STom Eccles  character :: c
8*f4402398STom Eccles  complex :: z
9*f4402398STom Eccles  logical :: l
10*f4402398STom Eccles
11*f4402398STom Eccles  ! * is allowed for integer, real, and complex
12*f4402398STom Eccles  ! but not for logical or character
13*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
14*f4402398STom Eccles  ! ERROR: The type of 'l' is incompatible with the reduction operator.
15*f4402398STom Eccles  !$omp parallel reduction(*:i,r,c,z,l)
16*f4402398STom Eccles  !$omp end parallel
17*f4402398STom Eccles
18*f4402398STom Eccles  ! + is allowed for integer, real, and complex
19*f4402398STom Eccles  ! but not for logical or character
20*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
21*f4402398STom Eccles  ! ERROR: The type of 'l' is incompatible with the reduction operator.
22*f4402398STom Eccles  !$omp parallel reduction(+:i,r,c,z,l)
23*f4402398STom Eccles  !$omp end parallel
24*f4402398STom Eccles
25*f4402398STom Eccles  ! - is deprecated for all types
26*f4402398STom Eccles  ! ERROR: The minus reduction operator is deprecated since OpenMP 5.2 and is not supported in the REDUCTION clause.
27*f4402398STom Eccles  !$omp parallel reduction(-:i,r,c,z,l)
28*f4402398STom Eccles  !$omp end parallel
29*f4402398STom Eccles
30*f4402398STom Eccles  ! .and. is only supported for logical operations
31*f4402398STom Eccles  ! ERROR: The type of 'i' is incompatible with the reduction operator.
32*f4402398STom Eccles  ! ERROR: The type of 'r' is incompatible with the reduction operator.
33*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
34*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
35*f4402398STom Eccles  !$omp parallel reduction(.and.:i,r,c,z,l)
36*f4402398STom Eccles  !$omp end parallel
37*f4402398STom Eccles
38*f4402398STom Eccles  ! .or. is only supported for logical operations
39*f4402398STom Eccles  ! ERROR: The type of 'i' is incompatible with the reduction operator.
40*f4402398STom Eccles  ! ERROR: The type of 'r' is incompatible with the reduction operator.
41*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
42*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
43*f4402398STom Eccles  !$omp parallel reduction(.or.:i,r,c,z,l)
44*f4402398STom Eccles  !$omp end parallel
45*f4402398STom Eccles
46*f4402398STom Eccles  ! .eqv. is only supported for logical operations
47*f4402398STom Eccles  ! ERROR: The type of 'i' is incompatible with the reduction operator.
48*f4402398STom Eccles  ! ERROR: The type of 'r' is incompatible with the reduction operator.
49*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
50*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
51*f4402398STom Eccles  !$omp parallel reduction(.eqv.:i,r,c,z,l)
52*f4402398STom Eccles  !$omp end parallel
53*f4402398STom Eccles
54*f4402398STom Eccles  ! .neqv. is only supported for logical operations
55*f4402398STom Eccles  ! ERROR: The type of 'i' is incompatible with the reduction operator.
56*f4402398STom Eccles  ! ERROR: The type of 'r' is incompatible with the reduction operator.
57*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
58*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
59*f4402398STom Eccles  !$omp parallel reduction(.neqv.:i,r,c,z,l)
60*f4402398STom Eccles  !$omp end parallel
61*f4402398STom Eccles
62*f4402398STom Eccles  ! iand only supports integers
63*f4402398STom Eccles  ! ERROR: The type of 'r' is incompatible with the reduction operator.
64*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
65*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
66*f4402398STom Eccles  ! ERROR: The type of 'l' is incompatible with the reduction operator.
67*f4402398STom Eccles  !$omp parallel reduction(iand:i,r,c,z,l)
68*f4402398STom Eccles  !$omp end parallel
69*f4402398STom Eccles
70*f4402398STom Eccles  ! ior only supports integers
71*f4402398STom Eccles  ! ERROR: The type of 'r' is incompatible with the reduction operator.
72*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
73*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
74*f4402398STom Eccles  ! ERROR: The type of 'l' is incompatible with the reduction operator.
75*f4402398STom Eccles  !$omp parallel reduction(ior:i,r,c,z,l)
76*f4402398STom Eccles  !$omp end parallel
77*f4402398STom Eccles
78*f4402398STom Eccles  ! ieor only supports integers
79*f4402398STom Eccles  ! ERROR: The type of 'r' is incompatible with the reduction operator.
80*f4402398STom Eccles  ! ERROR: The type of 'c' is incompatible with the reduction operator.
81*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
82*f4402398STom Eccles  ! ERROR: The type of 'l' is incompatible with the reduction operator.
83*f4402398STom Eccles  !$omp parallel reduction(ieor:i,r,c,z,l)
84*f4402398STom Eccles  !$omp end parallel
85*f4402398STom Eccles
86*f4402398STom Eccles  ! max arguments may be integer, real, or character:
87*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
88*f4402398STom Eccles  ! ERROR: The type of 'l' is incompatible with the reduction operator.
89*f4402398STom Eccles  !$omp parallel reduction(max:i,r,c,z,l)
90*f4402398STom Eccles  !$omp end parallel
91*f4402398STom Eccles
92*f4402398STom Eccles  ! min arguments may be integer, real, or character:
93*f4402398STom Eccles  ! ERROR: The type of 'z' is incompatible with the reduction operator.
94*f4402398STom Eccles  ! ERROR: The type of 'l' is incompatible with the reduction operator.
95*f4402398STom Eccles  !$omp parallel reduction(min:i,r,c,z,l)
96*f4402398STom Eccles  !$omp end parallel
97*f4402398STom Ecclesend program omp_reduction
98