[flang-commits] [flang] 3291041 - [Flang][OpenMP] Fix issue in only a single nowait clause can appear on a sections directive.
Sameeran joshi via flang-commits
flang-commits at lists.llvm.org
Wed Oct 14 03:53:26 PDT 2020
Author: sameeran joshi
Date: 2020-10-14T16:22:57+05:30
New Revision: 3291041641febf73ba98f074a946fe92331de90b
URL: https://github.com/llvm/llvm-project/commit/3291041641febf73ba98f074a946fe92331de90b
DIFF: https://github.com/llvm/llvm-project/commit/3291041641febf73ba98f074a946fe92331de90b.diff
LOG: [Flang][OpenMP] Fix issue in only a single nowait clause can appear on a sections directive.
The OpenMP 5.0 standard restricts nowait clause to appear only once on sections
directive.
See OpenMP 5.0
- 2.8.1
- point 3 in restrictions.
Added a test with fix.
Reviewed By: DavidTruby
Differential Revision: https://reviews.llvm.org/D88556
Added:
Modified:
flang/lib/Semantics/check-omp-structure.cpp
flang/test/Semantics/omp-clause-validity01.f90
flang/test/Semantics/omp-sections01.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index c07f43eeed52..9140cfe74e3b 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -127,7 +127,7 @@ void OmpStructureChecker::Enter(const parser::OmpEndSectionsDirective &x) {
// 2.7.2 end-sections -> END SECTIONS [nowait-clause]
case llvm::omp::Directive::OMPD_sections:
SetContextDirectiveEnum(llvm::omp::Directive::OMPD_end_sections);
- SetContextAllowed(OmpClauseSet{llvm::omp::Clause::OMPC_nowait});
+ SetContextAllowedOnce(OmpClauseSet{llvm::omp::Clause::OMPC_nowait});
break;
default:
// no clauses are allowed
diff --git a/flang/test/Semantics/omp-clause-validity01.f90 b/flang/test/Semantics/omp-clause-validity01.f90
index 07f55733c8dc..358c9fc56549 100644
--- a/flang/test/Semantics/omp-clause-validity01.f90
+++ b/flang/test/Semantics/omp-clause-validity01.f90
@@ -261,6 +261,17 @@
d = 2
!ERROR: NUM_THREADS clause is not allowed on the END SECTIONS directive
!$omp end sections num_threads(4)
+
+ !$omp parallel
+ !$omp sections
+ b = 1
+ !$omp section
+ c = 1
+ d = 2
+ !ERROR: At most one NOWAIT clause can appear on the END SECTIONS directive
+ !$omp end sections nowait nowait
+ !$omp end parallel
+
!$omp end parallel
! 2.11.2 parallel-sections-clause -> parallel-clause |
diff --git a/flang/test/Semantics/omp-sections01.f90 b/flang/test/Semantics/omp-sections01.f90
index 7bf9d0ae0161..aa96ca0ebdc7 100644
--- a/flang/test/Semantics/omp-sections01.f90
+++ b/flang/test/Semantics/omp-sections01.f90
@@ -1,5 +1,4 @@
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
-! XFAIL: *
! OpenMP Version 4.5
! 2.7.2 sections Construct
@@ -10,7 +9,7 @@ program omp_sections
!$omp sections
!$omp section
print *, "omp section"
- !ERROR: Only a single nowait clause can appear on a sections directive.
+ !ERROR: At most one NOWAIT clause can appear on the END SECTIONS directive
!$omp end sections nowait nowait
end program omp_sections
More information about the flang-commits
mailing list