diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp --- a/clang/lib/Basic/OpenMPKinds.cpp +++ b/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 diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/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 VMIs; diff --git a/clang/test/OpenMP/nothing_messages.cpp b/clang/test/OpenMP/nothing_messages.cpp new file mode 100644 --- /dev/null +++ b/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@+2 {{#pragma omp nothing' cannot be an immediate substatement}} + if(!x) +#pragma omp nothing + x=d; + +// expected-warning@+2 {{extra tokens at the end of '#pragma omp nothing' are ignored}} + if(!x) { +#pragma omp nothing seq_cst + x=d; + } + + return 0; +} diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -629,6 +629,7 @@ VersionedClause ]; } +def OMP_Nothing : Directive<"nothing"> {} def OMP_TargetData : Directive<"target data"> { let allowedClauses = [ VersionedClause,