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 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 VMIs; 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@+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; +} 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 ]; } +def OMP_Nothing : Directive<"nothing"> {} def OMP_TargetData : Directive<"target data"> { let allowedClauses = [ VersionedClause,