[PATCH] D89861: [Flang][OpenMP 4.5] Add semantic check for OpenMP default clause

Yashaswini Hegde via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 05:35:51 PDT 2020


yhegde updated this revision to Diff 300251.
yhegde added a comment.

Semantic check for OpenMP 4.5 - 2.15.3.1 default clause

Test case:
combined test case - omp-default.f90


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89861

Files:
  flang/test/Semantics/omp-default.f90
  llvm/include/llvm/Frontend/OpenMP/OMP.td


Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -297,7 +297,6 @@
 def OMP_ThreadPrivate : Directive<"threadprivate"> {}
 def OMP_Parallel : Directive<"parallel"> {
   let allowedClauses = [
-    VersionedClause<OMPC_Default>,
     VersionedClause<OMPC_Private>,
     VersionedClause<OMPC_FirstPrivate>,
     VersionedClause<OMPC_Shared>,
@@ -306,6 +305,7 @@
     VersionedClause<OMPC_Allocate>
   ];
   let allowedOnceClauses = [
+    VersionedClause<OMPC_Default>,
     VersionedClause<OMPC_If>,
     VersionedClause<OMPC_NumThreads>,
     VersionedClause<OMPC_ProcBind>,
@@ -313,7 +313,6 @@
 }
 def OMP_Task : Directive<"task"> {
   let allowedClauses = [
-    VersionedClause<OMPC_Default>,
     VersionedClause<OMPC_Private>,
     VersionedClause<OMPC_FirstPrivate>,
     VersionedClause<OMPC_Shared>,
@@ -326,6 +325,7 @@
     VersionedClause<OMPC_Affinity, 50>
   ];
   let allowedOnceClauses = [
+    VersionedClause<OMPC_Default>,
     VersionedClause<OMPC_If>,
     VersionedClause<OMPC_Final>,
     VersionedClause<OMPC_Priority>
@@ -807,7 +807,6 @@
     VersionedClause<OMPC_Private>,
     VersionedClause<OMPC_FirstPrivate>,
     VersionedClause<OMPC_LastPrivate>,
-    VersionedClause<OMPC_Default>,
     VersionedClause<OMPC_Untied>,
     VersionedClause<OMPC_Mergeable>,
     VersionedClause<OMPC_NoGroup>,
@@ -816,6 +815,7 @@
     VersionedClause<OMPC_Allocate>
   ];
   let allowedOnceClauses = [
+    VersionedClause<OMPC_Default>,
     VersionedClause<OMPC_If>,
     VersionedClause<OMPC_Collapse>,
     VersionedClause<OMPC_Final>,
Index: flang/test/Semantics/omp-default.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/omp-default.f90
@@ -0,0 +1,34 @@
+!RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! OpenMP Version 4.5
+! 2.15.3.1 default Clause
+program omp_default
+  integer :: a(10), b(10), c(10),i,k
+  !ERROR: At most one DEFAULT clause can appear on the PARALLEL directive
+  !$omp parallel default(shared), default(private)
+  do i = 1, 10
+    c(i) = a(i) + b(i) + k
+  end do
+  !$omp end parallel
+
+  !ERROR: At most one DEFAULT clause can appear on the TASK directive
+  !$omp task default(shared), default(none),shared(a,b,c,k,i)
+  do i = 1, 10
+    c(i) = a(i) + b(i) + k
+  end do
+  !$omp end task
+
+  !ERROR: At most one DEFAULT clause can appear on the TASKLOOP directive
+  !$omp taskloop default(shared), default(private)
+  do i = 1, 10
+    c(i) = a(i) + b(i) + k
+  end do
+  !$omp end taskloop
+
+  !ERROR: At most one DEFAULT clause can appear on the TEAMS directive
+  !$omp teams default(shared), default(none),shared(i,a,b,k,c)
+  do i = 1, 10
+    c(i) = a(i) + b(i) + k
+  end do
+  !$omp end teams
+
+end program omp_default


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89861.300251.patch
Type: text/x-patch
Size: 2903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201023/5d7abfc5/attachment.bin>


More information about the llvm-commits mailing list