[Flang] [OpenMP] Refine parser restrictions for OMP TARGET UPDATE clauses.
authorRaghu Maddhipatla <Raghu.Maddhipatla@amd.com>
Thu, 12 Jan 2023 06:32:06 +0000 (00:32 -0600)
committerRaghu Maddhipatla <Raghu.Maddhipatla@amd.com>
Tue, 17 Jan 2023 14:43:28 +0000 (08:43 -0600)
In Parser, move some clauses of OMP TARGET UPDATE to allowedOnceClauses so that restrictions will be imposed.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D141567

flang/test/Semantics/OpenMP/omp-device-constructs.f90
llvm/include/llvm/Frontend/OpenMP/OMP.td

index cbd3775..51f0070 100644 (file)
@@ -162,6 +162,14 @@ program main
   !ERROR: Only the FROM, RELEASE, DELETE map types are permitted for MAP clauses on the TARGET EXIT DATA directive
   !$omp target exit data map(to:a)
 
+  !$omp target update if(.true.) device(1) to(a) from(b) depend(inout:c) nowait
+
+  !ERROR: At most one IF clause can appear on the TARGET UPDATE directive
+  !$omp target update to(a) if(.true.) if(.false.)
+
+  !ERROR: At most one DEVICE clause can appear on the TARGET UPDATE directive
+  !$omp target update device(0) device(1) from(b)
+
   !$omp target
   !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
   !$omp distribute
index 3713761..0b87b6e 100644 (file)
@@ -798,13 +798,15 @@ def OMP_TargetParallelDo : Directive<"target parallel do"> {
 }
 def OMP_TargetUpdate : Directive<"target update"> {
   let allowedClauses = [
-    VersionedClause<OMPC_If>,
-    VersionedClause<OMPC_Device>,
     VersionedClause<OMPC_To>,
     VersionedClause<OMPC_From>,
-    VersionedClause<OMPC_NoWait>,
     VersionedClause<OMPC_Depend>
   ];
+  let allowedOnceClauses = [
+    VersionedClause<OMPC_Device>,
+    VersionedClause<OMPC_If>,
+    VersionedClause<OMPC_NoWait>
+  ];
 }
 def OMP_ParallelFor : Directive<"parallel for"> {
   let allowedClauses = [