Skip to content

Commit

Permalink
[flang][openacc] Add clause validaty tests for data construct + fix d…
Browse files Browse the repository at this point in the history
…efault restriction

Add clause validity tests for the data construct. The default clause can appear only once
and this was not enforce in the ACC.td.

Reviewed By: sameeranjoshi

Differential Revision: https://reviews.llvm.org/D91888
  • Loading branch information
clementval committed Dec 4, 2020
1 parent 88c21f8 commit a366188
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
37 changes: 36 additions & 1 deletion flang/test/Semantics/acc-clause-validity.f90
Expand Up @@ -131,7 +131,42 @@ program openacc_clause_validity
!$acc data
!$acc end data

!$acc data copyin(i)
!$acc data copy(aa) if(.true.)
!$acc end data

!$acc data copy(aa) if(ifCondition)
!$acc end data

!$acc data copy(aa, bb, cc)
!$acc end data

!$acc data copyin(aa) copyin(readonly: bb) copyout(cc)
!$acc end data

!$acc data copyin(readonly: aa, bb) copyout(zero: cc)
!$acc end data

!$acc data create(aa, bb(:,:)) create(zero: cc(:,:))
!$acc end data

!$acc data no_create(aa) present(bb, cc)
!$acc end data

!$acc data deviceptr(aa) attach(bb, cc)
!$acc end data

!$acc data copy(aa, bb) default(none)
!$acc end data

!$acc data copy(aa, bb) default(present)
!$acc end data

!ERROR: At most one DEFAULT clause can appear on the DATA directive
!$acc data copy(aa, bb) default(none) default(present)
!$acc end data

!ERROR: At most one IF clause can appear on the DATA directive
!$acc data copy(aa) if(.true.) if(ifCondition)
!$acc end data

!$acc data copyin(i)
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/Frontend/OpenACC/ACC.td
Expand Up @@ -257,7 +257,8 @@ def ACC_Atomic : Directive<"atomic"> {}
// 2.6.5
def ACC_Data : Directive<"data"> {
let allowedOnceClauses = [
VersionedClause<ACCC_If>
VersionedClause<ACCC_If>,
VersionedClause<ACCC_Default>
];
let requiredClauses = [
VersionedClause<ACCC_Attach>,
Expand Down

0 comments on commit a366188

Please sign in to comment.