File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,15 @@ void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
262262 EnterDirectiveNest (SIMDNest);
263263 }
264264
265+ if (CurrentDirectiveIsNested () &&
266+ llvm::omp::allTeamsSet.test (GetContext ().directive ) &&
267+ GetContextParent ().directive == llvm::omp::Directive::OMPD_target &&
268+ !GetDirectiveNest (TargetBlockOnlyTeams)) {
269+ context_.Say (GetContextParent ().directiveSource ,
270+ " TARGET construct with nested TEAMS region contains statements or "
271+ " directives outside of the TEAMS construct" _err_en_US);
272+ }
273+
265274 // Combined target loop constructs are target device constructs. Keep track of
266275 // whether any such construct has been visited to later check that REQUIRES
267276 // directives for target-related options don't appear after them.
Original file line number Diff line number Diff line change @@ -5215,6 +5215,13 @@ bool OmpStructureChecker::CheckTargetBlockOnlyTeams(
52155215 if (dirId == llvm::omp::Directive::OMPD_teams) {
52165216 nestedTeams = true ;
52175217 }
5218+ } else if (const auto *ompLoopConstruct{
5219+ std::get_if<parser::OpenMPLoopConstruct>(
5220+ &ompConstruct->u )}) {
5221+ llvm::omp::Directive dirId{ompLoopConstruct->BeginDir ().DirId ()};
5222+ if (llvm::omp::allTeamsSet.test (dirId)) {
5223+ nestedTeams = true ;
5224+ }
52185225 }
52195226 }
52205227
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+
21+ print ' ("Result: "I0)' , counter
22+ end program
You can’t perform that action at this time.
0 commit comments