1! { dg-do compile }
2
3module declare_target_2
4  !$omp declare target to (a) link (a)	! { dg-error "TO clause and later in LINK" }
5  !$omp declare target (b)
6  !$omp declare target link (b)		! { dg-error "TO clause and later in LINK" }
7  !$omp declare target link (f)
8  !$omp declare target to (f)		! { dg-error "LINK clause and later in TO" }
9  !$omp declare target(c, c)		! { dg-error "mentioned multiple times in clauses of the same" }
10  !$omp declare target to (d) to (d)	! { dg-error "mentioned multiple times in clauses of the same" }
11  !$omp declare target link (e, e)	! { dg-error "mentioned multiple times in clauses of the same" }
12  integer, save :: a, b, c, d, e, f
13  interface
14    integer function f1 (a)
15      !$omp declare target (f1)		! { dg-error "form without clauses is allowed in interface block" }
16      integer :: a
17    end function
18  end interface
19  interface
20    integer function f2 (a)
21      !$omp declare target to (f2)	! { dg-error "form without clauses is allowed in interface block" }
22      integer :: a
23    end function
24  end interface
25end
26subroutine bar
27  !$omp declare target link (baz)	! { dg-error "isn.t SAVEd" }
28  call baz				! { dg-error "attribute conflicts" }
29end subroutine
30subroutine foo				! { dg-error "attribute conflicts" }
31  integer :: g, h, i, j, k, l, m, n, o, p, q
32  common /c1/ g, h
33  common /c2/ i, j
34  common /c3/ k, l
35  common /c4/ m, n
36  common /c5/ o, p, q
37  !$omp declare target to (g)		! { dg-error "is an element of a COMMON block" }
38  !$omp declare target link (foo)
39  !$omp declare target to (/c2/)
40  !$omp declare target (/c2/)
41  !$omp declare target to(/c2/)
42  !$omp declare target link(/c2/)	! { dg-error "TO clause and later in LINK" }
43  !$omp declare target link(/c3/)
44  !$omp declare target (/c3/)		! { dg-error "LINK clause and later in TO" }
45  !$omp declare target (/c4/, /c4/)	! { dg-error "mentioned multiple times in clauses of the same" }
46  !$omp declare target to (/c4/) to(/c4/) ! { dg-error "mentioned multiple times in clauses of the same" }
47  !$omp declare target link (/c5/)
48  !$omp declare target link (/c5/)
49  !$omp declare target link(/c5/)link(/c5/) ! { dg-error "mentioned multiple times in clauses of the same" }
50  !$omp declare target link(/c5/,/c5/)	! { dg-error "mentioned multiple times in clauses of the same" }
51end subroutine
52