summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKelvin Li <kkwli0@gmail.com>2016-06-27 19:15:43 +0000
committerKelvin Li <kkwli0@gmail.com>2016-06-27 19:15:43 +0000
commit3834dcebdda091d0b49ce75ac352dfa7973dcd83 (patch)
tree50ed8c7f06d00e20d0c2d429b0e79a68fc2a3feb
parent428b3e6edfc74aa21ece92d94229122a841fa7d3 (diff)
downloadbcm5719-llvm-3834dcebdda091d0b49ce75ac352dfa7973dcd83.tar.gz
bcm5719-llvm-3834dcebdda091d0b49ce75ac352dfa7973dcd83.zip
[OpenMP] Diagnose missing cases of statements between target and teams directives
Clang fails to diagnose cases such as #pragma omp target while(0) { #pragma omp teams {} } A patch by David Sheinkman. llvm-svn: 273908
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp3
-rw-r--r--clang/test/OpenMP/nesting_of_regions.cpp6
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 772b3765e59..21ccfd04789 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6537,6 +6537,9 @@ StmtResult Sema::ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses,
}
assert(I != CS->body_end() && "Not found statement");
S = *I;
+ } else {
+ auto *OED = dyn_cast<OMPExecutableDirective>(S);
+ OMPTeamsFound = OED && isOpenMPTeamsDirective(OED->getDirectiveKind());
}
if (!OMPTeamsFound) {
Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);
diff --git a/clang/test/OpenMP/nesting_of_regions.cpp b/clang/test/OpenMP/nesting_of_regions.cpp
index 8d884a2e614..38012e85961 100644
--- a/clang/test/OpenMP/nesting_of_regions.cpp
+++ b/clang/test/OpenMP/nesting_of_regions.cpp
@@ -2960,6 +2960,12 @@ void foo() {
#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}}
+ {
+ while (0) // expected-note {{statement outside teams construct here}}
+#pragma omp teams // expected-note {{nested teams construct here}}
+ ++a;
+ }
#pragma omp target
{
#pragma omp taskloop
OpenPOWER on IntegriCloud