diff --git a/flang/lib/Parser/openacc-parsers.cpp b/flang/lib/Parser/openacc-parsers.cpp --- a/flang/lib/Parser/openacc-parsers.cpp +++ b/flang/lib/Parser/openacc-parsers.cpp @@ -98,8 +98,13 @@ parenthesized(construct( Parser{} / ":", Parser{})))) || + // SELF clause is either a simple optional condition for compute construct + // or a synonym of the HOST clause for the update directive 2.14.4 holding + // an object list. "SELF" >> construct(construct( maybe(parenthesized(scalarLogicalExpr)))) || + construct( + construct(parenthesized(Parser{}))) || "SEQ" >> construct(construct()) || "TILE" >> construct(construct( parenthesized(Parser{}))) || 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 @@ -31,7 +31,7 @@ !ERROR: At least one clause is required on the DECLARE directive !$acc declare - real(8), dimension(N) :: a + real(8), dimension(N) :: a, f, g, h !$acc init !$acc init if(.TRUE.) @@ -83,6 +83,8 @@ !ERROR: Unmatched PARALLEL directive !$acc end parallel + !$acc update self(a, f) host(g) device(h) + !$acc update device(i) device_type(*) async !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the UPDATE directive @@ -108,6 +110,21 @@ a(i) = 3.14 end do + !$acc parallel loop self + do i = 1, N + a(i) = 3.14 + end do + + !$acc parallel loop self(.true.) + do i = 1, N + a(i) = 3.14 + end do + + !$acc parallel loop self(ifCondition) + do i = 1, N + a(i) = 3.14 + end do + !$acc parallel loop tile(2, 2) do i = 1, N do j = 1, N