Unverified Commit d2e7a15d authored by Valentin Clement (バレンタイン クレメン)'s avatar Valentin Clement (バレンタイン クレメン) Committed by GitHub
Browse files

[flang][openacc] Warn about misplaced end loop directive and ignore it (#69512)

Instead of raising an error for a misplaced `end loop directive`, just
warn about it and ignore it. This directive is an extension and is
optional.
parent 21e1b13f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -568,6 +568,7 @@ public:
  NODE(parser, OpenACCCombinedConstruct)
  NODE(parser, OpenACCConstruct)
  NODE(parser, OpenACCDeclarativeConstruct)
  NODE(parser, OpenACCEndConstruct)
  NODE(parser, OpenACCLoopConstruct)
  NODE(parser, OpenACCRoutineConstruct)
  NODE(parser, OpenACCStandaloneDeclarativeConstruct)
+6 −1
Original line number Diff line number Diff line
@@ -4257,6 +4257,11 @@ struct OpenACCLoopConstruct {
      t;
};

struct OpenACCEndConstruct {
  WRAPPER_CLASS_BOILERPLATE(OpenACCEndConstruct, llvm::acc::Directive);
  CharBlock source;
};

struct OpenACCStandaloneConstruct {
  TUPLE_CLASS_BOILERPLATE(OpenACCStandaloneConstruct);
  CharBlock source;
@@ -4267,7 +4272,7 @@ struct OpenACCConstruct {
  UNION_CLASS_BOILERPLATE(OpenACCConstruct);
  std::variant<OpenACCBlockConstruct, OpenACCCombinedConstruct,
      OpenACCLoopConstruct, OpenACCStandaloneConstruct, OpenACCCacheConstruct,
      OpenACCWaitConstruct, OpenACCAtomicConstruct>
      OpenACCWaitConstruct, OpenACCAtomicConstruct, OpenACCEndConstruct>
      u;
};

+3 −0
Original line number Diff line number Diff line
@@ -3358,6 +3358,9 @@ void Fortran::lower::genOpenACCConstruct(
          [&](const Fortran::parser::OpenACCAtomicConstruct &atomicConstruct) {
            genACC(converter, eval, atomicConstruct);
          },
          [&](const Fortran::parser::OpenACCEndConstruct &) {
            // No op
          },
      },
      accConstruct.u);
}
+5 −1
Original line number Diff line number Diff line
@@ -235,6 +235,9 @@ TYPE_PARSER(startAccLine >>
            sourced(construct<OpenACCDeclarativeConstruct>(
                Parser<OpenACCRoutineConstruct>{})))))

TYPE_PARSER(sourced(construct<OpenACCEndConstruct>(
    "END"_tok >> "LOOP"_tok >> pure(llvm::acc::Directive::ACCD_loop))))

// OpenACC constructs
TYPE_CONTEXT_PARSER("OpenACC construct"_en_US,
    startAccLine >>
@@ -246,7 +249,8 @@ TYPE_CONTEXT_PARSER("OpenACC construct"_en_US,
                    Parser<OpenACCStandaloneConstruct>{}),
                construct<OpenACCConstruct>(Parser<OpenACCCacheConstruct>{}),
                construct<OpenACCConstruct>(Parser<OpenACCWaitConstruct>{}),
                construct<OpenACCConstruct>(Parser<OpenACCAtomicConstruct>{}))))
                construct<OpenACCConstruct>(Parser<OpenACCAtomicConstruct>{}),
                construct<OpenACCConstruct>(Parser<OpenACCEndConstruct>{}))))

TYPE_PARSER(startAccLine >>
    sourced(construct<AccEndCombinedDirective>(sourced("END"_tok >>
+4 −0
Original line number Diff line number Diff line
@@ -673,6 +673,10 @@ void AccStructureChecker::Enter(const parser::AccClause::If &x) {
      GetContext().clauseSource, "Must have LOGICAL or INTEGER type"_err_en_US);
}

void AccStructureChecker::Enter(const parser::OpenACCEndConstruct &x) {
  context_.Say(x.source, "Misplaced OpenACC end directive"_warn_en_US);
}

void AccStructureChecker::Enter(const parser::Module &) {
  declareSymbols.clear();
}
Loading