Skip to content

Commit e460654

Browse files
committed
[flang][openacc] Add clause validity tests for the update directive
Add couple of clause validity tests for the update directive and check for the restriction where at least self, host or device clause must appear on the directive. Reviewed By: sameeranjoshi Differential Revision: https://reviews.llvm.org/D92447
1 parent f69936f commit e460654

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

flang/lib/Semantics/check-acc-structure.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ void AccStructureChecker::Leave(const parser::OpenACCStandaloneConstruct &x) {
201201
CheckRequireAtLeastOneOf();
202202
break;
203203
case llvm::acc::Directive::ACCD_update:
204+
// Restriction - line 2636
205+
CheckRequireAtLeastOneOf();
204206
// Restriction - 2301
205207
CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type,
206208
updateOnlyAllowedAfterDeviceTypeClauses);

flang/test/Semantics/acc-clause-validity.f90

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,37 @@ program openacc_clause_validity
138138
!ERROR: Unmatched PARALLEL directive
139139
!$acc end parallel
140140

141+
!ERROR: At least one of DEVICE, HOST, SELF clause must appear on the UPDATE directive
142+
!$acc update
143+
141144
!$acc update self(a, f) host(g) device(h)
142145

143-
!$acc update device(i) device_type(*) async
146+
!$acc update host(aa) async(1)
147+
148+
!$acc update device(bb) async(async1)
149+
150+
!ERROR: At most one ASYNC clause can appear on the UPDATE directive
151+
!$acc update host(aa, bb) async(1) async(2)
152+
153+
!$acc update self(bb, cc(:)) wait(1)
154+
155+
!$acc update device(aa, bb, cc) wait(wait1)
156+
157+
!$acc update host(aa) host(bb) device(cc) wait(1,2)
158+
159+
!$acc update device(aa, cc) wait(wait1, wait2)
160+
161+
!$acc update device(aa) device_type(*) async
162+
163+
!$acc update host(bb) device_type(*) wait
164+
165+
!$acc update self(cc) device_type(1,2) async device_type(3) wait
166+
167+
!ERROR: At most one IF clause can appear on the UPDATE directive
168+
!$acc update device(aa) if(.true.) if(ifCondition)
169+
170+
!ERROR: At most one IF_PRESENT clause can appear on the UPDATE directive
171+
!$acc update device(bb) if_present if_present
144172

145173
!ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the UPDATE directive
146174
!$acc update device(i) device_type(*) if(.TRUE.)

0 commit comments

Comments
 (0)