xref: /llvm-project/flang/test/Semantics/OpenACC/acc-declare-validity.f90 (revision b096b8b1ff30abc9983da12d1b8c099530663627)
1! RUN: %python %S/../test_errors.py %s %flang -fopenacc
2
3! Check OpenACC clause validity for the following construct and directive:
4!   2.13 Declare
5
6module openacc_declare_validity
7
8  implicit none
9
10  real(8), dimension(10) :: aa, bb, ab, ac, ad, ae, af, cc, dd
11
12  !ERROR: At least one clause is required on the DECLARE directive
13  !$acc declare
14
15  !$acc declare create(aa, bb)
16
17  !WARNING: 'aa' in the CREATE clause is already present in the same clause in this module
18  !$acc declare create(aa)
19
20  !$acc declare link(ab)
21
22  !$acc declare device_resident(cc)
23
24  !ERROR: COPYOUT clause is not allowed on the DECLARE directive in module declaration section
25  !$acc declare copyout(ac)
26
27  !ERROR: COPY clause is not allowed on the DECLARE directive in module declaration section
28  !$acc declare copy(af)
29
30  !ERROR: PRESENT clause is not allowed on the DECLARE directive in module declaration section
31  !$acc declare present(ad)
32
33  !ERROR: DEVICEPTR clause is not allowed on the DECLARE directive in module declaration section
34  !$acc declare deviceptr(ae)
35
36  !ERROR: The ZERO modifier is not allowed for the CREATE clause on the DECLARE directive
37  !$acc declare create(zero: dd)
38
39  !ERROR: 'bb' in the COPYIN clause is already present in another CREATE clause in this module
40  !$acc declare copyin(bb)
41
42contains
43
44  subroutine sub1(cc, dd)
45    real(8) :: cc(:)
46    real(8) :: dd(:)
47    !$acc declare present(cc, dd)
48    !ERROR: 'cc' in the CREATE clause is already present in another PRESENT clause in this module
49    !$acc declare create(cc)
50  end subroutine sub1
51
52  function fct1(ee, ff, gg, hh, ii)
53    integer :: fct1
54    real(8), intent(in) :: ee(:)
55    !$acc declare copyin(readonly: ee)
56    real(8) :: ff(:), hh(:), ii(:,:)
57    !$acc declare link(hh) device_resident(ii)
58    real(8), intent(out) :: gg(:)
59    !$acc declare copy(ff) copyout(gg)
60  end function fct1
61
62  subroutine sub2(cc)
63    real(8), dimension(*) :: cc
64    !ERROR: Assumed-size dummy arrays may not appear on the DECLARE directive
65    !$acc declare present(cc)
66  end subroutine sub2
67
68  subroutine sub3()
69    real :: aa(100)
70    !ERROR: The ZERO modifier is not allowed for the COPYOUT clause on the DECLARE directive
71    !$acc declare copyout(zero: aa)
72  end subroutine
73
74end module openacc_declare_validity
75