[PATCH] D123286: [Clang][OpenMP] Support for omp nothing

Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 22:00:16 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca27f3e3b26e: [Clang][OpenMP] Support for omp nothing (authored by koops, committed by Chi-Chun, Chen <chichunchen844 at gmail.com>).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123286/new/

https://reviews.llvm.org/D123286

Files:
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/nothing_messages.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td


Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -629,6 +629,7 @@
     VersionedClause<OMPC_AtomicDefaultMemOrder>
   ];
 }
+def OMP_Nothing : Directive<"nothing"> {}
 def OMP_TargetData : Directive<"target data"> {
   let allowedClauses = [
     VersionedClause<OMPC_UseDevicePtr>,
Index: clang/test/OpenMP/nothing_messages.cpp
===================================================================
--- /dev/null
+++ clang/test/OpenMP/nothing_messages.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -verify=expected -fopenmp -ferror-limit 100 %s -Wuninitialized
+
+int mixed() {
+  int x = 0;
+  int d = 4;
+
+#pragma omp nothing
+  x=d;
+
+  if(!x) {
+#pragma omp nothing
+    x=d;
+  }
+
+// expected-error at +2 {{#pragma omp nothing' cannot be an immediate substatement}}
+  if(!x)
+#pragma omp nothing
+    x=d;
+
+// expected-warning at +2 {{extra tokens at the end of '#pragma omp nothing' are ignored}}
+  if(!x) {
+#pragma omp nothing seq_cst
+    x=d;
+  }
+
+  return 0;
+}
Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -2488,6 +2488,16 @@
   bool HasAssociatedStatement = true;
 
   switch (DKind) {
+  case OMPD_nothing:
+    if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
+        ParsedStmtContext())
+      Diag(Tok, diag::err_omp_immediate_directive)
+        << getOpenMPDirectiveName(DKind) << 0;
+    ConsumeToken();
+    skipUntilPragmaOpenMPEnd(DKind);
+    if (Tok.is(tok::annot_pragma_openmp_end))
+      ConsumeAnnotationToken();
+    break;
   case OMPD_metadirective: {
     ConsumeToken();
     SmallVector<VariantMatchInfo, 4> VMIs;
Index: clang/lib/Basic/OpenMPKinds.cpp
===================================================================
--- clang/lib/Basic/OpenMPKinds.cpp
+++ clang/lib/Basic/OpenMPKinds.cpp
@@ -730,6 +730,9 @@
   case OMPD_teams_loop:
     CaptureRegions.push_back(OMPD_teams);
     break;
+  case OMPD_nothing:
+    CaptureRegions.push_back(OMPD_nothing);
+    break;
   case OMPD_loop:
     // TODO: 'loop' may require different capture regions depending on the bind
     // clause or the parent directive when there is no bind clause. Use


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123286.431881.patch
Type: text/x-patch
Size: 2398 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220525/c97a4ea0/attachment.bin>


More information about the cfe-commits mailing list