[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
This commit is contained in:
Kelvin Li 2016-06-27 19:15:43 +00:00
parent 428b3e6edf
commit 3834dcebdd
2 changed files with 9 additions and 0 deletions

View File

@ -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);

View File

@ -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