File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,15 @@ void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
335335 EnterDirectiveNest (SIMDNest);
336336 }
337337
338+ if (CurrentDirectiveIsNested () &&
339+ llvm::omp::topTeamsSet.test (GetContext ().directive ) &&
340+ GetContextParent ().directive == llvm::omp::Directive::OMPD_target &&
341+ !GetDirectiveNest (TargetBlockOnlyTeams)) {
342+ context_.Say (GetContextParent ().directiveSource ,
343+ " TARGET construct with nested TEAMS region contains statements or "
344+ " directives outside of the TEAMS construct" _err_en_US);
345+ }
346+
338347 // Combined target loop constructs are target device constructs. Keep track of
339348 // whether any such construct has been visited to later check that REQUIRES
340349 // directives for target-related options don't appear after them.
Original file line number Diff line number Diff line change @@ -5217,6 +5217,13 @@ bool OmpStructureChecker::CheckTargetBlockOnlyTeams(
52175217 if (dirId == llvm::omp::Directive::OMPD_teams) {
52185218 nestedTeams = true ;
52195219 }
5220+ } else if (const auto *ompLoopConstruct{
5221+ std::get_if<parser::OpenMPLoopConstruct>(
5222+ &ompConstruct->u )}) {
5223+ llvm::omp::Directive dirId{ompLoopConstruct->BeginDir ().DirId ()};
5224+ if (llvm::omp::topTeamsSet.test (dirId)) {
5225+ nestedTeams = true ;
5226+ }
52205227 }
52215228 }
52225229
Original file line number Diff line number Diff line change 1+ ! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2+
3+ program main
4+ implicit none
5+ integer , parameter :: n = 100
6+ integer , parameter :: expected = n+2
7+ integer :: i
8+ integer :: counter
9+
10+ counter = 0
11+ ! ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct
12+ ! $omp target map(tofrom:counter)
13+ counter = counter+1
14+ ! $omp teams distribute reduction(+:counter)
15+ do i= 1 , n
16+ counter = counter+1
17+ end do
18+ counter = counter+1
19+ ! $omp end target
20+ end program
You can’t perform that action at this time.
0 commit comments