[PATCH] D90185: [flang][openacc] Fix ambiguity in the self clause parsing

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 27 18:10:10 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG990222931ba2: [flang][openacc] Fix ambiguity in the self clause parsing (authored by clementval).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90185/new/

https://reviews.llvm.org/D90185

Files:
  flang/lib/Parser/openacc-parsers.cpp
  flang/test/Semantics/acc-clause-validity.f90


Index: flang/test/Semantics/acc-clause-validity.f90
===================================================================
--- flang/test/Semantics/acc-clause-validity.f90
+++ 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
Index: flang/lib/Parser/openacc-parsers.cpp
===================================================================
--- flang/lib/Parser/openacc-parsers.cpp
+++ flang/lib/Parser/openacc-parsers.cpp
@@ -98,8 +98,13 @@
                        parenthesized(construct<AccObjectListWithReduction>(
                            Parser<AccReductionOperator>{} / ":",
                            Parser<AccObjectList>{})))) ||
+    // 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<AccClause>(construct<AccClause::Self>(
                   maybe(parenthesized(scalarLogicalExpr)))) ||
+    construct<AccClause>(
+        construct<AccClause::Host>(parenthesized(Parser<AccObjectList>{}))) ||
     "SEQ" >> construct<AccClause>(construct<AccClause::Seq>()) ||
     "TILE" >> construct<AccClause>(construct<AccClause::Tile>(
                   parenthesized(Parser<AccTileExprList>{}))) ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90185.301155.patch
Type: text/x-patch
Size: 2079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201028/2efade85/attachment.bin>


More information about the llvm-commits mailing list