diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index 4b6d083671bc9..a826f0181e580 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -1982,6 +1982,12 @@ void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) { void OmpAttributeVisitor::Post(const parser::Name &name) { auto *symbol{name.symbol}; if (symbol && !dirContext_.empty() && GetContext().withinConstruct) { + // Exclude construct-names + if (auto *details{symbol->detailsIf()}) { + if (details->kind() == semantics::MiscDetails::Kind::ConstructName) { + return; + } + } if (!symbol->owner().IsDerivedType() && !IsProcedure(*symbol) && !IsObjectWithDSA(*symbol) && !IsNamedConstant(*symbol)) { // TODO: create a separate function to go through the rules for diff --git a/flang/test/Semantics/OpenMP/default-none.f90 b/flang/test/Semantics/OpenMP/default-none.f90 index d027f46f00584..11ba878ea7794 100644 --- a/flang/test/Semantics/OpenMP/default-none.f90 +++ b/flang/test/Semantics/OpenMP/default-none.f90 @@ -39,3 +39,11 @@ subroutine sb3(x) print *, x end subroutine end subroutine + +!construct-name inside default(none) +subroutine sb4 + !$omp parallel default(none) + loop: do i = 1, 10 + end do loop + !$omp end parallel +end subroutine