[PATCH] D123286: Patch for : omp nothing
Sunil K via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 00:40:11 PDT 2022
koops created this revision.
koops added reviewers: dreachem, soumitra, cchen, jdoerfert.
Herald added a project: All.
koops requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.
Patch to support "#pragma omp nothing"
Repository:
rG LLVM Github Monorepo
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: 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: llvm/include/llvm/Frontend/OpenMP/OMP.td
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -602,6 +602,7 @@
VersionedClause<OMPC_AtomicDefaultMemOrder>
];
}
+def OMP_Nothing : Directive<"nothing"> {}
def OMP_TargetData : Directive<"target data"> {
let allowedClauses = [
VersionedClause<OMPC_UseDevicePtr>,
Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -2488,6 +2488,17 @@
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
@@ -714,6 +714,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.421109.patch
Type: text/x-patch
Size: 2409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220407/5a67a606/attachment.bin>
More information about the llvm-commits
mailing list