]> granicus.if.org Git - clang/commitdiff
[OPENMP] issue error messages for multiple teams contructs in a target construct
authorKelvin Li <kkwli0@gmail.com>
Tue, 5 Feb 2019 16:43:00 +0000 (16:43 +0000)
committerKelvin Li <kkwli0@gmail.com>
Tue, 5 Feb 2019 16:43:00 +0000 (16:43 +0000)
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

lib/Sema/SemaOpenMP.cpp
test/OpenMP/nesting_of_regions.cpp

index 5ee5eb0b6bf3c27c2580a6ec57220c2b7c2ab8c3..fe7e18b32fe8e8357ee5aa7acba03cf4e849a799 100644 (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;
         }
index 0955ee215569ee75d7096f0439339eeb4b95c21b..fc9230c6870ca0fa49e2ad17b0e95b4d169d9dc6 100644 (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}}