Index: flang/lib/Semantics/check-omp-structure.cpp =================================================================== --- flang/lib/Semantics/check-omp-structure.cpp +++ flang/lib/Semantics/check-omp-structure.cpp @@ -127,7 +127,7 @@ // 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 Index: flang/test/Semantics/omp-clause-validity01.f90 =================================================================== --- flang/test/Semantics/omp-clause-validity01.f90 +++ 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 |