[flang-commits] [flang] 3fa20ba - [Flang][OpenMP 4.5] Add semantic check for OpenMP default clause
Vinay M via flang-commits
flang-commits at lists.llvm.org
Tue Oct 27 09:39:40 PDT 2020
Author: Yashaswini Hegde
Date: 2020-10-27T12:38:47-04:00
New Revision: 3fa20baf009d72b0c78fdaf5be758400d5ba8918
URL: https://github.com/llvm/llvm-project/commit/3fa20baf009d72b0c78fdaf5be758400d5ba8918
DIFF: https://github.com/llvm/llvm-project/commit/3fa20baf009d72b0c78fdaf5be758400d5ba8918.diff
LOG: [Flang][OpenMP 4.5] Add semantic check for OpenMP default clause
Added:
flang/test/Semantics/omp-default.f90
flang/test/Semantics/omp-default02.f90
Modified:
llvm/include/llvm/Frontend/OpenMP/OMP.td
Removed:
################################################################################
diff --git a/flang/test/Semantics/omp-default.f90 b/flang/test/Semantics/omp-default.f90
new file mode 100644
index 000000000000..c5770f887f3a
--- /dev/null
+++ b/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
diff --git a/flang/test/Semantics/omp-default02.f90 b/flang/test/Semantics/omp-default02.f90
new file mode 100644
index 000000000000..be72098c35c2
--- /dev/null
+++ b/flang/test/Semantics/omp-default02.f90
@@ -0,0 +1,57 @@
+!RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! OpenMP Version 4.5
+! 2.15.3.1 default Clause - a positive test case.
+
+!DEF: /omp_default MainProgram
+program omp_default
+ !DEF: /omp_default/a ObjectEntity INTEGER(4)
+ !DEF: /omp_default/b ObjectEntity INTEGER(4)
+ !DEF: /omp_default/c ObjectEntity INTEGER(4)
+ !DEF: /omp_default/i ObjectEntity INTEGER(4)
+ !DEF: /omp_default/k ObjectEntity INTEGER(4)
+ integer a(10), b(10), c(10), i, k
+!$omp parallel default(shared)
+ !DEF: /omp_default/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
+ do i=1,10
+ !REF: /omp_default/c
+ !REF: /omp_default/Block1/i
+ !REF: /omp_default/a
+ !REF: /omp_default/b
+ !REF: /omp_default/k
+ c(i) = a(i)+b(i)+k
+ end do
+!$omp end parallel
+!$omp task default(shared)
+ !DEF: /omp_default/Block2/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
+ do i=1,10
+ !REF: /omp_default/c
+ !REF: /omp_default/Block2/i
+ !REF: /omp_default/a
+ !REF: /omp_default/b
+ !REF: /omp_default/k
+ c(i) = a(i)+b(i)+k
+ end do
+!$omp end task
+!$omp taskloop default(shared)
+ !DEF: /omp_default/Block3/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
+ do i=1,10
+ !REF: /omp_default/c
+ !REF: /omp_default/Block3/i
+ !REF: /omp_default/a
+ !REF: /omp_default/b
+ !REF: /omp_default/k
+ c(i) = a(i)+b(i)+k
+ end do
+!$omp end taskloop
+!$omp teams default(shared)
+ !REF: /omp_default/i
+ do i=1,10
+ !REF: /omp_default/c
+ !REF: /omp_default/i
+ !REF: /omp_default/a
+ !REF: /omp_default/b
+ !REF: /omp_default/k
+ c(i) = a(i)+b(i)+k
+ end do
+!$omp end teams
+end program omp_default
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index 7727827835e0..1be90cafe37c 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -298,7 +298,6 @@ def OMPC_Notinbranch : Clause<"notinbranch"> {}
def OMP_ThreadPrivate : Directive<"threadprivate"> {}
def OMP_Parallel : Directive<"parallel"> {
let allowedClauses = [
- VersionedClause<OMPC_Default>,
VersionedClause<OMPC_Private>,
VersionedClause<OMPC_FirstPrivate>,
VersionedClause<OMPC_Shared>,
@@ -307,6 +306,7 @@ def OMP_Parallel : Directive<"parallel"> {
VersionedClause<OMPC_Allocate>
];
let allowedOnceClauses = [
+ VersionedClause<OMPC_Default>,
VersionedClause<OMPC_If>,
VersionedClause<OMPC_NumThreads>,
VersionedClause<OMPC_ProcBind>,
@@ -314,7 +314,6 @@ def OMP_Parallel : Directive<"parallel"> {
}
def OMP_Task : Directive<"task"> {
let allowedClauses = [
- VersionedClause<OMPC_Default>,
VersionedClause<OMPC_Private>,
VersionedClause<OMPC_FirstPrivate>,
VersionedClause<OMPC_Shared>,
@@ -327,6 +326,7 @@ def OMP_Task : Directive<"task"> {
VersionedClause<OMPC_Affinity, 50>
];
let allowedOnceClauses = [
+ VersionedClause<OMPC_Default>,
VersionedClause<OMPC_If>,
VersionedClause<OMPC_Final>,
VersionedClause<OMPC_Priority>
@@ -808,7 +808,6 @@ def OMP_TaskLoop : Directive<"taskloop"> {
VersionedClause<OMPC_Private>,
VersionedClause<OMPC_FirstPrivate>,
VersionedClause<OMPC_LastPrivate>,
- VersionedClause<OMPC_Default>,
VersionedClause<OMPC_Untied>,
VersionedClause<OMPC_Mergeable>,
VersionedClause<OMPC_NoGroup>,
@@ -817,6 +816,7 @@ def OMP_TaskLoop : Directive<"taskloop"> {
VersionedClause<OMPC_Allocate>
];
let allowedOnceClauses = [
+ VersionedClause<OMPC_Default>,
VersionedClause<OMPC_If>,
VersionedClause<OMPC_Collapse>,
VersionedClause<OMPC_Final>,
More information about the flang-commits
mailing list