Skip to content

Commit 8abc9f2

Browse files
Update as per review comments
1 parent b08326e commit 8abc9f2

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

flang/include/flang/Parser/parse-tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4648,7 +4648,7 @@ struct OpenMPDeclareReductionConstruct {
46484648
TUPLE_CLASS_BOILERPLATE(OpenMPDeclareReductionConstruct);
46494649
CharBlock source;
46504650
std::tuple<Verbatim, common::Indirection<OmpReductionSpecifier>,
4651-
OmpClauseList>
4651+
std::optional<OmpClauseList>>
46524652
t;
46534653
};
46544654

flang/lib/Lower/OpenMP/Clauses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ using Inbranch = tomp::clause::InbranchT<TypeTy, IdTy, ExprTy>;
231231
using Inclusive = tomp::clause::InclusiveT<TypeTy, IdTy, ExprTy>;
232232
using Indirect = tomp::clause::IndirectT<TypeTy, IdTy, ExprTy>;
233233
using Init = tomp::clause::InitT<TypeTy, IdTy, ExprTy>;
234-
using Initializer = tomp::clause::InitT<TypeTy, IdTy, ExprTy>;
234+
using Initializer = tomp::clause::InitializerT<TypeTy, IdTy, ExprTy>;
235235
using InReduction = tomp::clause::InReductionT<TypeTy, IdTy, ExprTy>;
236236
using IsDevicePtr = tomp::clause::IsDevicePtrT<TypeTy, IdTy, ExprTy>;
237237
using Lastprivate = tomp::clause::LastprivateT<TypeTy, IdTy, ExprTy>;

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ TYPE_PARSER(construct<OmpInitializerClause>(
11881188
TYPE_PARSER(sourced(construct<OpenMPDeclareReductionConstruct>(
11891189
verbatim("DECLARE REDUCTION"_tok),
11901190
"(" >> indirect(Parser<OmpReductionSpecifier>{}) / ")",
1191-
Parser<OmpClauseList>{})))
1191+
maybe(Parser<OmpClauseList>{}))))
11921192

11931193
// declare-target with list
11941194
TYPE_PARSER(sourced(construct<OmpDeclareTargetWithList>(

flang/lib/Parser/unparse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2716,7 +2716,7 @@ class UnparseVisitor {
27162716
Put("(");
27172717
Walk(std::get<common::Indirection<OmpReductionSpecifier>>(x.t));
27182718
Put(")");
2719-
Walk(std::get<OmpClauseList>(x.t));
2719+
Walk(std::get<std::optional<OmpClauseList>>(x.t));
27202720
Put("\n");
27212721
EndOpenMP();
27222722
}

flang/lib/Semantics/resolve-names.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,11 +1496,9 @@ class OmpVisitor : public virtual DeclarationVisitor {
14961496

14971497
bool Pre(const parser::OpenMPDeclareReductionConstruct &x) {
14981498
AddOmpSourceRange(x.source);
1499-
parser::OmpClauseList emptyList{std::list<parser::OmpClause>{}};
15001499
ProcessReductionSpecifier(
15011500
std::get<Indirection<parser::OmpReductionSpecifier>>(x.t).value(),
1502-
emptyList);
1503-
Walk(std::get<parser::OmpClauseList>(x.t));
1501+
std::get<std::optional<parser::OmpClauseList>>(x.t));
15041502
return false;
15051503
}
15061504
bool Pre(const parser::OmpMapClause &);
@@ -1657,7 +1655,7 @@ class OmpVisitor : public virtual DeclarationVisitor {
16571655
void ProcessMapperSpecifier(const parser::OmpMapperSpecifier &spec,
16581656
const parser::OmpClauseList &clauses);
16591657
void ProcessReductionSpecifier(const parser::OmpReductionSpecifier &spec,
1660-
const parser::OmpClauseList &clauses);
1658+
const std::optional<parser::OmpClauseList> &clauses);
16611659
};
16621660

16631661
bool OmpVisitor::NeedsScope(const parser::OpenMPBlockConstruct &x) {
@@ -1752,7 +1750,7 @@ void OmpVisitor::ProcessMapperSpecifier(const parser::OmpMapperSpecifier &spec,
17521750

17531751
void OmpVisitor::ProcessReductionSpecifier(
17541752
const parser::OmpReductionSpecifier &spec,
1755-
const parser::OmpClauseList &clauses) {
1753+
const std::optional<parser::OmpClauseList> &clauses) {
17561754
const auto &id{std::get<parser::OmpReductionIdentifier>(spec.t)};
17571755
if (auto procDes{std::get_if<parser::ProcedureDesignator>(&id.u)}) {
17581756
if (auto *name{std::get_if<parser::Name>(&procDes->u)}) {
@@ -1794,7 +1792,7 @@ bool OmpVisitor::Pre(const parser::OmpDirectiveSpecification &x) {
17941792
if (maybeArgs && maybeClauses) {
17951793
const parser::OmpArgument &first{maybeArgs->front()};
17961794
if (auto *spec{std::get_if<parser::OmpReductionSpecifier>(&first.u)}) {
1797-
ProcessReductionSpecifier(*spec, *maybeClauses);
1795+
ProcessReductionSpecifier(*spec, maybeClauses);
17981796
}
17991797
}
18001798
break;

0 commit comments

Comments
 (0)