@@ -384,6 +384,9 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
384
384
bool Pre (const parser::OpenMPSectionsConstruct &);
385
385
void Post (const parser::OpenMPSectionsConstruct &) { PopContext (); }
386
386
387
+ bool Pre (const parser::OpenMPSectionConstruct &);
388
+ void Post (const parser::OpenMPSectionConstruct &) { PopContext (); }
389
+
387
390
bool Pre (const parser::OpenMPCriticalConstruct &critical);
388
391
void Post (const parser::OpenMPCriticalConstruct &) { PopContext (); }
389
392
@@ -2003,6 +2006,12 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPSectionsConstruct &x) {
2003
2006
return true ;
2004
2007
}
2005
2008
2009
+ bool OmpAttributeVisitor::Pre (const parser::OpenMPSectionConstruct &x) {
2010
+ PushContext (x.source , llvm::omp::Directive::OMPD_section);
2011
+ GetContext ().withinConstruct = true ;
2012
+ return true ;
2013
+ }
2014
+
2006
2015
bool OmpAttributeVisitor::Pre (const parser::OpenMPCriticalConstruct &x) {
2007
2016
const auto &beginCriticalDir{std::get<parser::OmpCriticalDirective>(x.t )};
2008
2017
const auto &endCriticalDir{std::get<parser::OmpEndCriticalDirective>(x.t )};
@@ -3024,8 +3033,13 @@ void OmpAttributeVisitor::CheckLabelContext(const parser::CharBlock source,
3024
3033
const parser::CharBlock target, std::optional<DirContext> sourceContext,
3025
3034
std::optional<DirContext> targetContext) {
3026
3035
auto dirContextsSame = [](DirContext &lhs, DirContext &rhs) -> bool {
3027
- // Sometimes nested constructs share a scope but are different contexts
3028
- return (lhs.scope == rhs.scope ) && (lhs.directive == rhs.directive );
3036
+ // Sometimes nested constructs share a scope but are different contexts.
3037
+ // The directiveSource comparison is for OmpSection. Sections do not have
3038
+ // their own scopes and two different sections both have the same directive.
3039
+ // Their source however is different. This string comparison is unfortunate
3040
+ // but should only happen for GOTOs inside of SECTION.
3041
+ return (lhs.scope == rhs.scope ) && (lhs.directive == rhs.directive ) &&
3042
+ (lhs.directiveSource == rhs.directiveSource );
3029
3043
};
3030
3044
unsigned version{context_.langOptions ().OpenMPVersion };
3031
3045
if (targetContext &&
0 commit comments