diff --git a/flang/test/Semantics/acc-clause-validity.f90 b/flang/test/Semantics/acc-clause-validity.f90 --- a/flang/test/Semantics/acc-clause-validity.f90 +++ b/flang/test/Semantics/acc-clause-validity.f90 @@ -3,8 +3,8 @@ ! Check OpenACC clause validity for the following construct and directive: ! 2.6.5 Data ! 2.5.1 Parallel -! 2.5.2 Kernels -! 2.5.3 Serial +! 2.5.2 Serial +! 2.5.3 Kernels ! 2.9 Loop ! 2.12 Atomic ! 2.13 Declare @@ -491,6 +491,170 @@ end do !$acc end kernels loop + !$acc serial + !$acc end serial + + !$acc serial async + !$acc end serial + + !$acc serial async(1) + !$acc end serial + + !ERROR: At most one ASYNC clause can appear on the SERIAL directive + !$acc serial async(1) async(2) + !$acc end serial + + !$acc serial async(async1) + !$acc end serial + + !$acc serial wait + !$acc end serial + + !$acc serial wait(1) + !$acc end serial + + !$acc serial wait(wait1) + !$acc end serial + + !$acc serial wait(1,2) + !$acc end serial + + !$acc serial wait(wait1, wait2) + !$acc end serial + + !$acc serial wait(wait1) wait(wait2) + !$acc end serial + + !ERROR: NUM_GANGS clause is not allowed on the SERIAL directive + !$acc serial num_gangs(8) + !$acc end serial + + !ERROR: NUM_WORKERS clause is not allowed on the SERIAL directive + !$acc serial num_workers(8) + !$acc end serial + + !ERROR: VECTOR_LENGTH clause is not allowed on the SERIAL directive + !$acc serial vector_length(128) + !$acc end serial + + !$acc serial if(.true.) + !$acc end serial + + !ERROR: At most one IF clause can appear on the SERIAL directive + !$acc serial if(.true.) if(ifCondition) + !$acc end serial + + !$acc serial if(ifCondition) + !$acc end serial + + !$acc serial self + !$acc end serial + + !$acc serial self(.true.) + !$acc end serial + + !$acc serial self(ifCondition) + !$acc end serial + + !$acc serial loop reduction(+: reduction_r) + do i = 1, N + reduction_r = a(i) + i + end do + + !$acc serial loop reduction(*: reduction_r) + do i = 1, N + reduction_r = reduction_r * (a(i) + i) + end do + + !$acc serial loop reduction(min: reduction_r) + do i = 1, N + reduction_r = min(reduction_r, a(i) * i) + end do + + !$acc serial loop reduction(max: reduction_r) + do i = 1, N + reduction_r = max(reduction_r, a(i) * i) + end do + + !$acc serial loop reduction(iand: b) + do i = 1, N + b = iand(b, c(i)) + end do + + !$acc serial loop reduction(ior: b) + do i = 1, N + b = ior(b, c(i)) + end do + + !$acc serial loop reduction(ieor: b) + do i = 1, N + b = ieor(b, c(i)) + end do + + !$acc serial loop reduction(.and.: reduction_l) + do i = 1, N + reduction_l = d(i) .and. e(i) + end do + + !$acc serial loop reduction(.or.: reduction_l) + do i = 1, N + reduction_l = d(i) .or. e(i) + end do + + !$acc serial loop reduction(.eqv.: reduction_l) + do i = 1, N + reduction_l = d(i) .eqv. e(i) + end do + + !$acc serial loop reduction(.neqv.: reduction_l) + do i = 1, N + reduction_l = d(i) .neqv. e(i) + end do + + !$acc serial reduction(.neqv.: reduction_l) + !$acc loop reduction(.neqv.: reduction_l) + do i = 1, N + reduction_l = d(i) .neqv. e(i) + end do + !$acc end serial + + !$acc serial copy(aa) copyin(bb) copyout(cc) + !$acc end serial + + !$acc serial copy(aa, bb) copyout(zero: cc) + !$acc end serial + + !$acc serial present(aa, bb) create(cc) + !$acc end serial + + !$acc serial copyin(readonly: aa, bb) create(zero: cc) + !$acc end serial + + !$acc serial deviceptr(aa, bb) no_create(cc) + !$acc end serial + + !$acc serial attach(aa, bb, cc) + !$acc end serial + + !$acc serial firstprivate(bb, cc) + !$acc end serial + + !$acc serial private(aa) + !$acc end serial + + !$acc serial default(none) + !$acc end serial + + !$acc serial default(present) + !$acc end serial + + !ERROR: At most one DEFAULT clause can appear on the SERIAL directive + !$acc serial default(present) default(none) + !$acc end serial + + !$acc serial device_type(*) async wait + !$acc end serial + !$acc serial device_type(*) async do i = 1, N a(i) = 3.14 diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -341,6 +341,8 @@ // 2.5.2 def ACC_Serial : Directive<"serial"> { + // Spec line 950-951: clause is as for the parallel construct except that the + // num_gangs, num_workers, and vector_length clauses are not permitted. let allowedClauses = [ VersionedClause, VersionedClause, @@ -349,10 +351,10 @@ VersionedClause, VersionedClause, VersionedClause, - VersionedClause, VersionedClause, VersionedClause, VersionedClause, + VersionedClause, VersionedClause ]; let allowedOnceClauses = [