From 620ba6035ee74ac897e40d6629fe794984e0e5f7 Mon Sep 17 00:00:00 2001 From: Kelvin Li Date: Tue, 5 Feb 2019 16:43:00 +0000 Subject: [PATCH] [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 { ... } } llvm-svn: 353186 --- clang/lib/Sema/SemaOpenMP.cpp | 4 +++- clang/test/OpenMP/nesting_of_regions.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 5ee5eb0..fe7e18b 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/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/clang/test/OpenMP/nesting_of_regions.cpp b/clang/test/OpenMP/nesting_of_regions.cpp index 0955ee2..fc9230c 100644 --- a/clang/test/OpenMP/nesting_of_regions.cpp +++ b/clang/test/OpenMP/nesting_of_regions.cpp @@ -4080,6 +4080,13 @@ void foo() { } #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}} #pragma omp teams // expected-note {{nested teams construct here}} ++a; @@ -12693,6 +12700,13 @@ void foo() { } #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}} #pragma omp teams // expected-note {{nested teams construct here}} ++a; -- 2.7.4