From: Kelvin Li Date: Tue, 5 Feb 2019 16:43:00 +0000 (+0000) Subject: [OPENMP] issue error messages for multiple teams contructs in a target construct X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c2557c8ff429945c39226b599e5179fa53902ec;p=clang [OPENMP] issue error messages for multiple teams contructs in a target construct The fix is to issue error messages if there are more than one teams construct inside a target constructs. #pragma omp target { #pragma omp teams { ... } #pragma omp teams { ... } } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353186 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 5ee5eb0b6b..fe7e18b32f 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -7067,7 +7067,9 @@ StmtResult Sema::ActOnOpenMPTargetDirective(ArrayRef Clauses, auto I = CS->body_begin(); while (I != CS->body_end()) { const auto *OED = dyn_cast(*I); - if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind())) { + if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind()) || + OMPTeamsFound) { + OMPTeamsFound = false; break; } diff --git a/test/OpenMP/nesting_of_regions.cpp b/test/OpenMP/nesting_of_regions.cpp index 0955ee2155..fc9230c687 100644 --- a/test/OpenMP/nesting_of_regions.cpp +++ b/test/OpenMP/nesting_of_regions.cpp @@ -4078,6 +4078,13 @@ void foo() { #pragma omp teams ++a; } +#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}} + { +#pragma omp teams // expected-note {{directive outside teams construct here}} + ++a; +#pragma omp teams // expected-note {{nested teams construct here}} + ++a; + } #pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}} { ++a; // expected-note {{statement outside teams construct here}} @@ -12691,6 +12698,13 @@ void foo() { #pragma omp teams ++a; } +#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}} + { +#pragma omp teams // expected-note {{directive outside teams construct here}} + ++a; +#pragma omp teams // expected-note {{nested teams construct here}} + ++a; + } #pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}} { ++a; // expected-note {{statement outside teams construct here}}