! RUN: %python %S/test_errors.py %s %flang_fc1 -fopenacc
module m
  real, device :: a(4,8)
  real, managed, allocatable :: b(:,:)
  integer, constant :: x = 1
  type :: int
     real :: i, s 
  end type int
  interface operator (+)
     module procedure addHost
     module procedure addDevice
  end interface operator (+)
 contains
  attributes(global) subroutine kernel(a,b,c,n,m)
    integer, value :: n
    integer, intent(in) :: m
    real a(n,m), c(n,m)
    real, managed :: b(n,m)
  end
  attributes(device) subroutine devsub(a,n)
    integer, value :: n
    real, device :: a(n)
  end
  subroutine test
    real c(4)
    allocate(b(4,8))
    !ERROR: dummy argument 'm=' has ATTRIBUTES(DEVICE) but its associated actual argument has no CUDA data attribute
    call kernel<<<1,32>>>(a,b,b,4,8)
    !$acc parallel loop copy(c)
    do j = 1, 1
      call devsub(c,4) ! not checked in OpenACC construct
    end do
  end
  attributes(global) subroutine sub1(x)
    integer :: x
  end
  subroutine sub2()
    call sub1<<<1,1>>>(x) ! actual constant to device dummy
  end
  function addHost(a, b) result(c)
    type(int), intent(in) :: a, b
    type(int) :: c
  end function addHost
  attributes(device) function addDevice(a, b) result(c)
    type(int), device :: c
    type(int), intent(in) :: a ,b
  end function addDevice
  attributes(global) subroutine overload(c, a, b)
    type (int) :: c, a, b
    c = a+b ! ok resolve to addDevice
  end subroutine overload

  attributes(host,device) subroutine hostdev(a)
    integer :: a(*)
  end subroutine
  
  subroutine host()
    integer :: a(10)
    call hostdev(a) ! ok because hostdev is attributes(host,device)
  end subroutine
    

end
