routine-10.f90 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ! { dg-do run }
  2. ! { dg-additional-options -Wuninitialized }
  3. module m
  4. implicit none
  5. contains
  6. pure subroutine add_ps_routine(a, b, c)
  7. implicit none
  8. !$acc routine seq
  9. integer, intent(in) :: a, b
  10. integer, intent(out) :: c
  11. integer, parameter :: n = 10
  12. integer :: i
  13. do i = 1, n
  14. if (i .eq. 5) then
  15. c = a + b
  16. end if
  17. end do
  18. end subroutine add_ps_routine
  19. elemental impure function add_ef(a, b) result(c)
  20. implicit none
  21. !$acc routine
  22. integer, intent(in) :: a, b
  23. integer :: c
  24. call add_ps_routine(a, b, c)
  25. end function add_ef
  26. ! This '-Wmaybe-uninitialized' diagnostic appears for '-O2' only; PR102192.
  27. ! { dg-xfail-if PR102192 { *-*-* } { -O2 } }
  28. ! There's another instance (again '-O2' only) further down, but as any number
  29. ! of 'dg-xfail-if' only apply to the first 'dg-bogus' etc., we have no way to
  30. ! XFAIL that other one, so we instead match all of them here (via line '0'):
  31. ! { dg-bogus {'c' may be used uninitialized} {} { target *-*-* } 0 }
  32. ! { TODO_dg-bogus {'c' may be used uninitialized} {} { target *-*-* } .-7 }
  33. end module m
  34. program main
  35. use m
  36. implicit none
  37. integer, parameter :: n = 10
  38. integer, dimension(n) :: a_a
  39. integer, dimension(n) :: b_a
  40. integer, dimension(n) :: c_a
  41. integer :: i
  42. a_a = [(3 * i, i = 1, n)]
  43. b_a = [(-2 * i, i = 1, n)]
  44. !$acc parallel copyin(a_a, b_a) copyout(c_a)
  45. !$acc loop gang
  46. do i = 1, n
  47. if (i .eq. 4) then
  48. c_a = add_ef(a_a, b_a)
  49. ! See above.
  50. ! { TODO_dg-xfail-if PR102192 { *-*-* } { -O2 } }
  51. ! { TODO_dg-bogus {'c' may be used uninitialized} {} { target *-*-* } .-3 }
  52. end if
  53. end do
  54. !$acc end parallel
  55. if (any (c_a /= [(i, i=1, 10)])) stop 1
  56. !print *, a
  57. end program main