Valentin Clement (バレンタイン クレメン) 2837fd7e5a
[flang][openacc] Allow if_present multiple times on host_data and update (#135422)
Similar to #135415.

The spec has not strict restriction to allow a single `if_present`
clause on the host_data and update directives. Allowing this clause
multiple times does not change the semantic of it. This patch relax the
rules in ACC.td since there is no restriction in the standard.

The OpenACC dialect represents the `if_present` clause with a `UnitAttr`
so the attribute will be set if the is one or more `if_present` clause.
2025-04-11 14:01:03 -07:00

42 lines
1.0 KiB
Fortran

! RUN: %python %S/../test_errors.py %s %flang -fopenacc
! Check OpenACC clause validity for the following construct and directive:
! 2.8 host_data
program openacc_host_data_validity
implicit none
integer, parameter :: N = 256
real(8), dimension(N, N) :: aa, bb
logical :: ifCondition = .TRUE.
!ERROR: At least one of USE_DEVICE clause must appear on the HOST_DATA directive
!$acc host_data
!$acc end host_data
!$acc host_data use_device(aa)
!$acc end host_data
!$acc host_data use_device(aa) if(.true.)
!$acc end host_data
!$acc host_data use_device(aa) if(ifCondition)
!$acc end host_data
!$acc host_data use_device(aa, bb) if_present
!$acc end host_data
! OK
!$acc host_data use_device(aa, bb) if_present if_present
!$acc end host_data
!$acc host_data use_device(aa, bb) if(.true.) if_present
!$acc end host_data
!ERROR: At most one IF clause can appear on the HOST_DATA directive
!$acc host_data use_device(aa, bb) if(.true.) if(ifCondition)
!$acc end host_data
end program openacc_host_data_validity