@@ -1569,6 +1569,8 @@ void AccVisitor::Post(const parser::OpenACCCombinedConstruct &x) { PopScope(); }
15691569class OmpVisitor : public virtual DeclarationVisitor {
15701570public:
15711571 void AddOmpSourceRange (const parser::CharBlock &);
1572+ void PushScopeWithSource (
1573+ Scope::Kind kind, parser::CharBlock source, Symbol *symbol = nullptr );
15721574
15731575 static bool NeedsScope (const parser::OmpBlockConstruct &);
15741576 static bool NeedsScope (const parser::OmpClause &);
@@ -1592,8 +1594,8 @@ class OmpVisitor : public virtual DeclarationVisitor {
15921594 Post (static_cast <const parser::OmpDirectiveSpecification &>(x));
15931595 }
15941596
1595- bool Pre (const parser::OpenMPLoopConstruct &) {
1596- PushScope (Scope::Kind::OtherConstruct, nullptr );
1597+ bool Pre (const parser::OpenMPLoopConstruct &x ) {
1598+ PushScopeWithSource (Scope::Kind::OtherConstruct, x. source );
15971599 return true ;
15981600 }
15991601 void Post (const parser::OpenMPLoopConstruct &) { PopScope (); }
@@ -1637,8 +1639,8 @@ class OmpVisitor : public virtual DeclarationVisitor {
16371639 }
16381640 bool Pre (const parser::OmpMapClause &);
16391641
1640- bool Pre (const parser::OpenMPSectionsConstruct &) {
1641- PushScope (Scope::Kind::OtherConstruct, nullptr );
1642+ bool Pre (const parser::OpenMPSectionsConstruct &x ) {
1643+ PushScopeWithSource (Scope::Kind::OtherConstruct, x. source );
16421644 return true ;
16431645 }
16441646 void Post (const parser::OpenMPSectionsConstruct &) { PopScope (); }
@@ -1744,7 +1746,7 @@ class OmpVisitor : public virtual DeclarationVisitor {
17441746 }
17451747 bool Pre (const parser::OmpClause &x) {
17461748 if (NeedsScope (x)) {
1747- PushScope (Scope::Kind::OtherClause, nullptr );
1749+ PushScopeWithSource (Scope::Kind::OtherClause, x. source );
17481750 }
17491751 return true ;
17501752 }
@@ -1813,9 +1815,15 @@ void OmpVisitor::AddOmpSourceRange(const parser::CharBlock &source) {
18131815 currScope ().AddSourceRange (source);
18141816}
18151817
1818+ void OmpVisitor::PushScopeWithSource (
1819+ Scope::Kind kind, parser::CharBlock source, Symbol *symbol) {
1820+ PushScope (kind, symbol);
1821+ currScope ().AddSourceRange (source);
1822+ }
1823+
18161824bool OmpVisitor::Pre (const parser::OmpBlockConstruct &x) {
18171825 if (NeedsScope (x)) {
1818- PushScope (Scope::Kind::OtherConstruct, nullptr );
1826+ PushScopeWithSource (Scope::Kind::OtherConstruct, x. source );
18191827 }
18201828 return true ;
18211829}
0 commit comments