Skip to content

Commit

Permalink
[flang] Separate keyword from clauses in provenance of construct dire…
Browse files Browse the repository at this point in the history
…ctives

Original-commit: flang-compiler/f18@9994d23
Reviewed-on: flang-compiler/f18#569
  • Loading branch information
klausler committed Jul 15, 2019
1 parent ef59f7a commit 3d8b3dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
16 changes: 6 additions & 10 deletions flang/lib/parser/openmp-grammar.h
Expand Up @@ -42,10 +42,6 @@ namespace Fortran::parser {
constexpr auto startOmpLine = skipStuffBeforeStatement >> "!$OMP "_sptok;
constexpr auto endOmpLine = space >> endOfLine;

template<typename A> constexpr decltype(auto) OmpConstructDirective(A keyword) {
return sourced(keyword >> Parser<OmpClauseList>{}) / endOmpLine;
}

template<typename A> constexpr decltype(auto) verbatim(A x) {
return sourced(construct<Verbatim>(x));
}
Expand Down Expand Up @@ -470,8 +466,8 @@ TYPE_PARSER(construct<OpenMPStandaloneConstruct>(
TYPE_PARSER(startOmpLine >> "END"_tok >>
construct<OmpEndSingle>("SINGLE" >> Parser<OmpClauseList>{}) / endOmpLine)

TYPE_PARSER(construct<OpenMPSingleConstruct>(
OmpConstructDirective("SINGLE"_tok), block, Parser<OmpEndSingle>{}))
TYPE_PARSER(construct<OpenMPSingleConstruct>(verbatim("SINGLE"_tok),
Parser<OmpClauseList>{} / endOmpLine, block, Parser<OmpEndSingle>{}))

// OMP WORKSHARE
TYPE_PARSER(construct<OpenMPWorkshareConstruct>(
Expand All @@ -491,8 +487,8 @@ TYPE_PARSER(startOmpLine >> "END SECTIONS"_tok >>
maybe("NOWAIT" >> construct<OmpNowait>()) / endOmpLine))

// OMP SECTIONS
TYPE_PARSER(construct<OpenMPSectionsConstruct>(
OmpConstructDirective("SECTIONS"_tok), block, Parser<OmpEndSections>{}))
TYPE_PARSER(construct<OpenMPSectionsConstruct>(verbatim("SECTIONS"_tok),
Parser<OmpClauseList>{} / endOmpLine, block, Parser<OmpEndSections>{}))

// OMP END PARALLEL SECTIONS [NOWAIT]
TYPE_PARSER(startOmpLine >> "END PARALLEL SECTIONS"_tok >>
Expand All @@ -501,8 +497,8 @@ TYPE_PARSER(startOmpLine >> "END PARALLEL SECTIONS"_tok >>

// OMP PARALLEL SECTIONS
TYPE_PARSER(construct<OpenMPParallelSectionsConstruct>(
OmpConstructDirective("PARALLEL SECTIONS"_tok), block,
Parser<OmpEndParallelSections>{}))
verbatim("PARALLEL SECTIONS"_tok), Parser<OmpClauseList>{} / endOmpLine,
block, Parser<OmpEndParallelSections>{}))

TYPE_PARSER(construct<OmpSection>(verbatim("SECTION"_tok) / endOmpLine))

Expand Down
6 changes: 3 additions & 3 deletions flang/lib/parser/parse-tree.h
Expand Up @@ -3475,12 +3475,12 @@ WRAPPER_CLASS(OmpSection, Verbatim);

struct OpenMPSectionsConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPSectionsConstruct);
std::tuple<OmpClauseList, Block, OmpEndSections> t;
std::tuple<Verbatim, OmpClauseList, Block, OmpEndSections> t;
};

struct OpenMPParallelSectionsConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPParallelSectionsConstruct);
std::tuple<OmpClauseList, Block, OmpEndParallelSections> t;
std::tuple<Verbatim, OmpClauseList, Block, OmpEndParallelSections> t;
};

// WORKSHARE
Expand All @@ -3493,7 +3493,7 @@ struct OpenMPWorkshareConstruct {
WRAPPER_CLASS(OmpEndSingle, OmpClauseList);
struct OpenMPSingleConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPSingleConstruct);
std::tuple<OmpClauseList, Block, OmpEndSingle> t;
std::tuple<Verbatim, OmpClauseList, Block, OmpEndSingle> t;
};

// OpenMP directive beginning or ending a block
Expand Down

0 comments on commit 3d8b3dd

Please sign in to comment.