[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
This commit is contained in:
Kelvin Li 2019-02-05 16:43:00 +00:00
parent a3ec627a1c
commit 620ba6035e
2 changed files with 17 additions and 1 deletions

View File

@ -7067,7 +7067,9 @@ StmtResult Sema::ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses,
auto I = CS->body_begin();
while (I != CS->body_end()) {
const auto *OED = dyn_cast<OMPExecutableDirective>(*I);
if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind())) {
if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind()) ||
OMPTeamsFound) {
OMPTeamsFound = false;
break;
}

View File

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