@@ -1480,12 +1480,10 @@ class OmpVisitor : public virtual DeclarationVisitor {
1480
1480
static bool NeedsScope (const parser::OmpClause &);
1481
1481
1482
1482
bool Pre (const parser::OmpMetadirectiveDirective &x) { //
1483
- metaDirective_ = &x;
1484
1483
++metaLevel_;
1485
1484
return true ;
1486
1485
}
1487
1486
void Post (const parser::OmpMetadirectiveDirective &) { //
1488
- metaDirective_ = nullptr ;
1489
1487
--metaLevel_;
1490
1488
}
1491
1489
@@ -1583,7 +1581,8 @@ class OmpVisitor : public virtual DeclarationVisitor {
1583
1581
AddOmpSourceRange (x.source );
1584
1582
ProcessReductionSpecifier (
1585
1583
std::get<Indirection<parser::OmpReductionSpecifier>>(x.t ).value (),
1586
- std::get<std::optional<parser::OmpClauseList>>(x.t ), x);
1584
+ std::get<std::optional<parser::OmpClauseList>>(x.t ),
1585
+ declaratives_.back ());
1587
1586
return false ;
1588
1587
}
1589
1588
bool Pre (const parser::OmpMapClause &);
@@ -1692,9 +1691,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
1692
1691
// can implicitly declare variables instead of only using the
1693
1692
// ones already declared in the Fortran sources.
1694
1693
SkipImplicitTyping (true );
1694
+ declaratives_.push_back (&x);
1695
1695
return true ;
1696
1696
}
1697
1697
void Post (const parser::OpenMPDeclarativeConstruct &) {
1698
+ declaratives_.pop_back ();
1698
1699
SkipImplicitTyping (false );
1699
1700
messageHandler ().set_currStmtSource (std::nullopt );
1700
1701
}
@@ -1736,15 +1737,14 @@ class OmpVisitor : public virtual DeclarationVisitor {
1736
1737
private:
1737
1738
void ProcessMapperSpecifier (const parser::OmpMapperSpecifier &spec,
1738
1739
const parser::OmpClauseList &clauses);
1739
- template <typename T>
1740
1740
void ProcessReductionSpecifier (const parser::OmpReductionSpecifier &spec,
1741
1741
const std::optional<parser::OmpClauseList> &clauses,
1742
- const T & wholeConstruct);
1742
+ const parser::OpenMPDeclarativeConstruct * wholeConstruct);
1743
1743
1744
1744
void ResolveCriticalName (const parser::OmpArgument &arg);
1745
1745
1746
1746
int metaLevel_{0 };
1747
- const parser::OmpMetadirectiveDirective *metaDirective_{ nullptr } ;
1747
+ std::vector< const parser::OpenMPDeclarativeConstruct *> declaratives_ ;
1748
1748
};
1749
1749
1750
1750
bool OmpVisitor::NeedsScope (const parser::OmpBlockConstruct &x) {
@@ -1869,11 +1869,10 @@ std::string MangleDefinedOperator(const parser::CharBlock &name) {
1869
1869
return " op" + name.ToString ();
1870
1870
}
1871
1871
1872
- template <typename T>
1873
1872
void OmpVisitor::ProcessReductionSpecifier (
1874
1873
const parser::OmpReductionSpecifier &spec,
1875
1874
const std::optional<parser::OmpClauseList> &clauses,
1876
- const T &wholeOmpConstruct ) {
1875
+ const parser::OpenMPDeclarativeConstruct *construct ) {
1877
1876
const parser::Name *name{nullptr };
1878
1877
parser::CharBlock mangledName;
1879
1878
UserReductionDetails reductionDetailsTemp;
@@ -1960,7 +1959,7 @@ void OmpVisitor::ProcessReductionSpecifier(
1960
1959
PopScope ();
1961
1960
}
1962
1961
1963
- reductionDetails->AddDecl (&wholeOmpConstruct );
1962
+ reductionDetails->AddDecl (construct );
1964
1963
1965
1964
if (!symbol) {
1966
1965
symbol = &MakeSymbol (mangledName, Attrs{}, std::move (*reductionDetails));
@@ -2025,8 +2024,7 @@ bool OmpVisitor::Pre(const parser::OmpDirectiveSpecification &x) {
2025
2024
if (maybeArgs && maybeClauses) {
2026
2025
const parser::OmpArgument &first{maybeArgs->v .front ()};
2027
2026
if (auto *spec{std::get_if<parser::OmpReductionSpecifier>(&first.u )}) {
2028
- CHECK (metaDirective_);
2029
- ProcessReductionSpecifier (*spec, maybeClauses, *metaDirective_);
2027
+ ProcessReductionSpecifier (*spec, maybeClauses, declaratives_.back ());
2030
2028
}
2031
2029
}
2032
2030
break ;
0 commit comments