1! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2
3! Check OpenMP declarative directives
4
5!TODO: all internal errors
6!      enable declare-reduction example after name resolution
7
8! 2.8.2 declare-simd
9
10subroutine declare_simd_1(a, b)
11  real(8), intent(inout) :: a, b
12  !$omp declare simd(declare_simd_1) aligned(a)
13  a = 3.14 + b
14end subroutine declare_simd_1
15
16module m1
17  abstract interface
18     subroutine sub(x,y)
19       integer, intent(in)::x
20       integer, intent(in)::y
21     end subroutine sub
22  end interface
23end module m1
24
25subroutine declare_simd_2
26  use m1
27  procedure (sub) sub1
28  !ERROR: NOTINBRANCH and INBRANCH clauses are mutually exclusive and may not appear on the same DECLARE SIMD directive
29  !$omp declare simd(sub1) inbranch notinbranch
30  procedure (sub), pointer::p
31  p=>sub1
32  call p(5,10)
33end subroutine declare_simd_2
34
35subroutine sub1 (x,y)
36  integer, intent(in)::x, y
37  print *, x+y
38end subroutine sub1
39
40! 2.10.6 declare-target
41! 2.15.2 threadprivate
42
43module m2
44contains
45  subroutine foo
46    !$omp declare target
47    !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive
48    !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive
49    !$omp declare target (foo, N, M)
50    !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
51    !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
52    !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
53    !$omp declare target to(Q, S) link(R)
54    !ERROR: MAP clause is not allowed on the DECLARE TARGET directive
55    !$omp declare target map(from:Q)
56    integer, parameter :: N=10000, M=1024
57    integer :: i
58    real :: Q(N, N), R(N,M), S(M,M)
59    !ERROR: A variable that appears in a THREADPRIVATE directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
60    !$omp threadprivate(i)
61  end subroutine foo
62end module m2
63
64! 2.16 declare-reduction
65
66! subroutine declare_red_1()
67!   use omp_lib
68!   integer :: my_var
69!   !$omp declare reduction (my_add_red : integer : omp_out = omp_out + omp_in) initializer (omp_priv=0)
70!   my_var = 0
71!   !$omp parallel reduction (my_add_red : my_var) num_threads(4)
72!   my_var = omp_get_thread_num() + 1
73!   !$omp end parallel
74!   print *, "sum of thread numbers is ", my_var
75! end subroutine declare_red_1
76
77end
78