| 1 |
! Check for invalid syntax with !$ACC ROUTINE. |
| 2 |
|
| 3 |
module m |
| 4 |
integer m1int |
| 5 |
contains |
| 6 |
subroutine subr5 (x) |
| 7 |
implicit none |
| 8 |
!$acc routine (m) ! { dg-error "Invalid NAME 'm' in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 9 |
!$acc routine (subr5) |
| 10 |
!$acc routine (m1int) ! { dg-error "Invalid NAME 'm1int' in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 11 |
integer f_1 ! Referenced. |
| 12 |
!$acc routine (f_1) |
| 13 |
integer f_2 ! Not referenced. |
| 14 |
!$acc routine (f_2) ! { dg-error "NAME 'f_2' does not refer to a subroutine or function in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 15 |
integer v_1 |
| 16 |
!$acc routine (v_1) ! { dg-error "NAME 'v_1' does not refer to a subroutine or function in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 17 |
integer, intent(inout) :: x |
| 18 |
!$acc routine (x) ! { dg-error "NAME 'x' does not refer to a subroutine or function in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 19 |
v_1 = x |
| 20 |
if (x < 1) then |
| 21 |
x = 1 |
| 22 |
else |
| 23 |
x = x * x - 1 |
| 24 |
x = f_1(x) + v_1 |
| 25 |
end if |
| 26 |
end subroutine subr5 |
| 27 |
end module m |
| 28 |
|
| 29 |
program main |
| 30 |
implicit none |
| 31 |
!$acc routine (main) ! { dg-error "PROGRAM attribute conflicts with SUBROUTINE attribute in 'main'" } |
| 32 |
interface |
| 33 |
function subr6 (x) |
| 34 |
!$acc routine (subr6) ! { dg-error "without list is allowed in interface" } |
| 35 |
integer, intent (in) :: x |
| 36 |
integer :: subr6 |
| 37 |
end function subr6 |
| 38 |
end interface |
| 39 |
integer, parameter :: n = 10 |
| 40 |
integer :: a(n), i |
| 41 |
!$acc routine (n) ! { dg-error "NAME 'n' does not refer to a subroutine or function in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 42 |
!$acc routine (a) ! { dg-error "NAME 'a' does not refer to a subroutine or function in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 43 |
!$acc routine (i) ! { dg-error "NAME 'i' does not refer to a subroutine or function in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 44 |
!$acc routine (subr1) ! { dg-error "Invalid NAME 'subr1' in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 45 |
external :: subr2 |
| 46 |
!$acc routine (subr2) |
| 47 |
|
| 48 |
external :: R1, R2 |
| 49 |
!$acc routine (R1 R2 R3) ! { dg-error "Syntax error in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), expecting .\\). after NAME" } |
| 50 |
!$acc routine (R1, R2, R3) ! { dg-error "Syntax error in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), expecting .\\). after NAME" } |
| 51 |
!$acc routine (R1) |
| 52 |
!$acc routine (R2) |
| 53 |
|
| 54 |
!$acc parallel |
| 55 |
!$acc loop |
| 56 |
do i = 1, n |
| 57 |
call subr1 (i) |
| 58 |
call subr2 (i) |
| 59 |
end do |
| 60 |
!$acc end parallel |
| 61 |
end program main |
| 62 |
|
| 63 |
! Ensure that we recover from incomplete function definitions. |
| 64 |
|
| 65 |
integer function f1 ! { dg-error "Expected formal argument list in function definition" } |
| 66 |
!$acc routine ! { dg-error "Unclassifiable OpenACC directive" } |
| 67 |
end function f1 ! { dg-error "Expecting END PROGRAM statement" } |
| 68 |
|
| 69 |
subroutine subr1 (x) |
| 70 |
!$acc routine |
| 71 |
integer, intent(inout) :: x |
| 72 |
if (x < 1) then |
| 73 |
x = 1 |
| 74 |
else |
| 75 |
x = x * x - 1 |
| 76 |
end if |
| 77 |
end subroutine subr1 |
| 78 |
|
| 79 |
subroutine subr2 (x) |
| 80 |
!$acc routine (subr1) ! { dg-error "Invalid NAME 'subr1' in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 81 |
integer, intent(inout) :: x |
| 82 |
!$acc routine (x) ! { dg-error "NAME 'x' does not refer to a subroutine or function in \\!\\\$ACC ROUTINE \\( NAME \\)" } |
| 83 |
if (x < 1) then |
| 84 |
x = 1 |
| 85 |
else |
| 86 |
x = x * x - 1 |
| 87 |
end if |
| 88 |
end subroutine subr2 |
| 89 |
|
| 90 |
subroutine subr3 (x) |
| 91 |
!$acc routine (subr3) |
| 92 |
integer, intent(inout) :: x |
| 93 |
if (x < 1) then |
| 94 |
x = 1 |
| 95 |
else |
| 96 |
call subr4 (x) |
| 97 |
end if |
| 98 |
end subroutine subr3 |
| 99 |
|
| 100 |
subroutine subr4 (x) |
| 101 |
!$acc routine (subr4) |
| 102 |
integer, intent(inout) :: x |
| 103 |
if (x < 1) then |
| 104 |
x = 1 |
| 105 |
else |
| 106 |
x = x * x - 1 |
| 107 |
end if |
| 108 |
end subroutine subr4 |
| 109 |
|
| 110 |
subroutine subr10 (x) |
| 111 |
!$acc routine (subr10) device ! { dg-error "Failed to match clause" } |
| 112 |
integer, intent(inout) :: x |
| 113 |
if (x < 1) then |
| 114 |
x = 1 |
| 115 |
else |
| 116 |
x = x * x - 1 |
| 117 |
end if |
| 118 |
end subroutine subr10 |
| 119 |
|
| 120 |
subroutine subr20 (x) |
| 121 |
!$acc routine (subr20) nohost nohost ! { dg-error "Duplicated 'nohost' clause" } |
| 122 |
integer, intent(inout) :: x |
| 123 |
if (x < 1) then |
| 124 |
x = 1 |
| 125 |
else |
| 126 |
x = x * x - 1 |
| 127 |
end if |
| 128 |
end subroutine subr20 |