[PATCH] D91944: OpenMP 5.0 metadirective

Chi Chun Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 2 11:04:01 PDT 2021


cchen added a comment.

I'm guessing the tests were not pass on buildbot but passed on the author's side is due to the assertion was disabled on the author's side.
Here is the patch for avoiding all the assertion errors and I'm able to get all the metadirective tests passed (and no regression for the existing omp tests) with this change:

  diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
  index 5ac6dd0fb55a..3313efe524f3 100644
  --- a/clang/lib/Parse/ParseOpenMP.cpp
  +++ b/clang/lib/Parse/ParseOpenMP.cpp
  @@ -2277,8 +2277,10 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
   ///
   StmtResult
   Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
  -  assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
     static bool ReadDirectiveWithinMetadirective = false;
  +  if (!ReadDirectiveWithinMetadirective)
  +    assert(Tok.isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp) &&
  +           "Not an OpenMP directive!");
     ParsingOpenMPDirectiveRAII DirScope(*this);
     ParenBraceBracketBalancer BalancerRAIIObj(*this);
     SmallVector<OMPClause *, 5> Clauses;
  @@ -2288,7 +2290,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
     unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
                           Scope::CompoundStmtScope | Scope::OpenMPDirectiveScope;
     if (!ReadDirectiveWithinMetadirective)
  -      ConsumeAnnotationToken();
  +    ConsumeAnnotationToken();
     SourceLocation Loc = Tok.getLocation(), EndLoc;
     OpenMPDirectiveKind DKind = parseOpenMPDirectiveKind(*this);
     if (ReadDirectiveWithinMetadirective && DKind == OMPD_unknown) {
  @@ -2331,6 +2333,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
           parseOMPContextSelectors(Loc, TI);
           if (TI.Sets.size() == 0) {
             Diag(Tok, diag::err_omp_expected_context_selector) << "when clause";
  +          TPA.Commit();
             return Directive;
           }
  
  @@ -2339,6 +2342,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
             ConsumeAnyToken();
           else {
             Diag(Tok, diag::err_omp_expected_colon) << "when clause";
  +          TPA.Commit();
             return Directive;
           }
         }
  @@ -2352,6 +2356,8 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
           if (Tok.is(tok::annot_pragma_openmp_end)) {
             Diag(Tok, diag::err_omp_expected_punc)
                 << getOpenMPClauseName(CKind) << 0;
  +          T.skipToEnd();
  +          TPA.Commit();
             return Directive;
           }
           ConsumeAnyToken();
  @@ -2627,7 +2633,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
         // ends with a ')'.
         if (ReadDirectiveWithinMetadirective && Tok.is(tok::r_paren)) {
           while (Tok.isNot(tok::annot_pragma_openmp_end))
  -          ConsumeToken();
  +          ConsumeAnyToken();
           break;
         }
         bool HasImplicitClause = false;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944



More information about the llvm-commits mailing list