[PATCH] D21617: [OpenMP] Diagnose missing cases of statements between target and teams directives

David S via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 22 14:45:06 PDT 2016


davidsh updated this revision to Diff 61612.

http://reviews.llvm.org/D21617

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

Index: test/OpenMP/nesting_of_regions.cpp
===================================================================
--- test/OpenMP/nesting_of_regions.cpp
+++ test/OpenMP/nesting_of_regions.cpp
@@ -2867,6 +2867,12 @@
 #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
Index: lib/Sema/SemaOpenMP.cpp
===================================================================
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6380,6 +6380,10 @@
       }
       assert(I != CS->body_end() && "Not found statement");
       S = *I;
+    } else {
+      auto *OED = dyn_cast<OMPExecutableDirective>(S);
+      if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind()))
+        OMPTeamsFound = false;
     }
     if (!OMPTeamsFound) {
       Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21617.61612.patch
Type: text/x-patch
Size: 1183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160622/63878d7f/attachment.bin>


More information about the cfe-commits mailing list