@@ -535,7 +535,8 @@ class DoContext {
535535 if (const SomeExpr * expr{GetExpr (context_, scalarExpression)}) {
536536 if (!ExprHasTypeCategory (*expr, TypeCategory::Integer)) {
537537 // No warnings or errors for type INTEGER
538- const parser::CharBlock &loc{scalarExpression.thing .value ().source };
538+ parser::CharBlock loc{
539+ parser::UnwrapRef<parser::Expr>(scalarExpression).source };
539540 CheckDoControl (loc, ExprHasTypeCategory (*expr, TypeCategory::Real));
540541 }
541542 }
@@ -552,7 +553,7 @@ class DoContext {
552553 CheckDoExpression (*bounds.step );
553554 if (IsZero (*bounds.step )) {
554555 context_.Warn (common::UsageWarning::ZeroDoStep,
555- bounds.step -> thing . value ( ).source ,
556+ parser::UnwrapRef<parser::Expr>( bounds.step ).source ,
556557 " DO step expression should not be zero" _warn_en_US);
557558 }
558559 }
@@ -615,7 +616,7 @@ class DoContext {
615616 // C1121 - procedures in mask must be pure
616617 void CheckMaskIsPure (const parser::ScalarLogicalExpr &mask) const {
617618 UnorderedSymbolSet references{
618- GatherSymbolsFromExpression (mask. thing . thing . value ( ))};
619+ GatherSymbolsFromExpression (parser::UnwrapRef<parser::Expr>(mask ))};
619620 for (const Symbol &ref : OrderBySourcePosition (references)) {
620621 if (IsProcedure (ref) && !IsPureProcedure (ref)) {
621622 context_.SayWithDecl (ref, parser::Unwrap<parser::Expr>(mask)->source ,
@@ -639,32 +640,33 @@ class DoContext {
639640 }
640641
641642 void HasNoReferences (const UnorderedSymbolSet &indexNames,
642- const parser::ScalarIntExpr &expr ) const {
643- CheckNoCollisions ( GatherSymbolsFromExpression ( expr. thing . thing . value ()),
644- indexNames,
643+ const parser::ScalarIntExpr &scalarIntExpr ) const {
644+ const auto & expr{parser::UnwrapRef<parser::Expr>(scalarIntExpr)};
645+ CheckNoCollisions ( GatherSymbolsFromExpression (expr), indexNames,
645646 " %s limit expression may not reference index variable '%s'" _err_en_US,
646- expr.thing . thing . value (). source );
647+ expr.source );
647648 }
648649
649650 // C1129, names in local locality-specs can't be in mask expressions
650651 void CheckMaskDoesNotReferenceLocal (const parser::ScalarLogicalExpr &mask,
651652 const UnorderedSymbolSet &localVars) const {
652- CheckNoCollisions ( GatherSymbolsFromExpression ( mask. thing . thing . value ()),
653- localVars,
653+ const auto &expr{parser::UnwrapRef<parser::Expr>( mask)};
654+ CheckNoCollisions ( GatherSymbolsFromExpression (expr), localVars,
654655 " %s mask expression references variable '%s'"
655656 " in LOCAL locality-spec" _err_en_US,
656- mask. thing . thing . value () .source );
657+ expr .source );
657658 }
658659
659660 // C1129, names in local locality-specs can't be in limit or step
660661 // expressions
661- void CheckExprDoesNotReferenceLocal (const parser::ScalarIntExpr &expr,
662+ void CheckExprDoesNotReferenceLocal (
663+ const parser::ScalarIntExpr &scalarIntExpr,
662664 const UnorderedSymbolSet &localVars) const {
663- CheckNoCollisions ( GatherSymbolsFromExpression ( expr. thing . thing . value ()),
664- localVars,
665+ const auto & expr{parser::UnwrapRef<parser::Expr>(scalarIntExpr)};
666+ CheckNoCollisions ( GatherSymbolsFromExpression (expr), localVars,
665667 " %s expression references variable '%s'"
666668 " in LOCAL locality-spec" _err_en_US,
667- expr.thing . thing . value (). source );
669+ expr.source );
668670 }
669671
670672 // C1130, DEFAULT(NONE) locality requires names to be in locality-specs to
@@ -772,7 +774,7 @@ class DoContext {
772774 HasNoReferences (indexNames, std::get<2 >(control.t ));
773775 if (const auto &intExpr{
774776 std::get<std::optional<parser::ScalarIntExpr>>(control.t )}) {
775- const parser::Expr &expr{intExpr-> thing . thing . value ( )};
777+ const auto &expr{parser::UnwrapRef<parser::Expr>(intExpr )};
776778 CheckNoCollisions (GatherSymbolsFromExpression (expr), indexNames,
777779 " %s step expression may not reference index variable '%s'" _err_en_US,
778780 expr.source );
@@ -840,7 +842,7 @@ class DoContext {
840842 }
841843 void CheckForImpureCall (const parser::ScalarIntExpr &x,
842844 std::optional<IndexVarKind> nesting) const {
843- const auto &parsedExpr{x. thing . thing . value ( )};
845+ const auto &parsedExpr{parser::UnwrapRef<parser::Expr>(x )};
844846 auto oldLocation{context_.location ()};
845847 context_.set_location (parsedExpr.source );
846848 if (const auto &typedExpr{parsedExpr.typedExpr }) {
@@ -1124,7 +1126,8 @@ void DoForallChecker::Leave(const parser::ConnectSpec &connectSpec) {
11241126 const auto *newunit{
11251127 std::get_if<parser::ConnectSpec::Newunit>(&connectSpec.u )};
11261128 if (newunit) {
1127- context_.CheckIndexVarRedefine (newunit->v .thing .thing );
1129+ context_.CheckIndexVarRedefine (
1130+ parser::UnwrapRef<parser::Variable>(newunit));
11281131 }
11291132}
11301133
@@ -1166,14 +1169,14 @@ void DoForallChecker::Leave(const parser::InquireSpec &inquireSpec) {
11661169 const auto *intVar{std::get_if<parser::InquireSpec::IntVar>(&inquireSpec.u )};
11671170 if (intVar) {
11681171 const auto &scalar{std::get<parser::ScalarIntVariable>(intVar->t )};
1169- context_.CheckIndexVarRedefine (scalar. thing . thing );
1172+ context_.CheckIndexVarRedefine (parser::UnwrapRef<parser::Variable>( scalar) );
11701173 }
11711174}
11721175
11731176void DoForallChecker::Leave (const parser::IoControlSpec &ioControlSpec) {
11741177 const auto *size{std::get_if<parser::IoControlSpec::Size>(&ioControlSpec.u )};
11751178 if (size) {
1176- context_.CheckIndexVarRedefine (size-> v . thing . thing );
1179+ context_.CheckIndexVarRedefine (parser::UnwrapRef<parser::Variable>(size) );
11771180 }
11781181}
11791182
@@ -1190,16 +1193,19 @@ static void CheckIoImpliedDoIndex(
11901193
11911194void DoForallChecker::Leave (const parser::OutputImpliedDo &outputImpliedDo) {
11921195 CheckIoImpliedDoIndex (context_,
1193- std::get<parser::IoImpliedDoControl>(outputImpliedDo.t ).name .thing .thing );
1196+ parser::UnwrapRef<parser::Name>(
1197+ std::get<parser::IoImpliedDoControl>(outputImpliedDo.t ).name ));
11941198}
11951199
11961200void DoForallChecker::Leave (const parser::InputImpliedDo &inputImpliedDo) {
11971201 CheckIoImpliedDoIndex (context_,
1198- std::get<parser::IoImpliedDoControl>(inputImpliedDo.t ).name .thing .thing );
1202+ parser::UnwrapRef<parser::Name>(
1203+ std::get<parser::IoImpliedDoControl>(inputImpliedDo.t ).name ));
11991204}
12001205
12011206void DoForallChecker::Leave (const parser::StatVariable &statVariable) {
1202- context_.CheckIndexVarRedefine (statVariable.v .thing .thing );
1207+ context_.CheckIndexVarRedefine (
1208+ parser::UnwrapRef<parser::Variable>(statVariable));
12031209}
12041210
12051211} // namespace Fortran::semantics
0 commit comments