Skip to content

Commit 40fae67

Browse files
authored
[Flang][OpenMP] Fix to construct-names inside OpenMP construct with default(none) (llvm#82479)
When a do loop with a construct-name is used inside OpenMP construct with default(none), an incorrect error will be raised as below. ``` program cn_and_default implicit none integer :: i !$omp parallel default(none) loop: do i = 1, 10 end do loop !$omp end parallel end program ``` > The DEFAULT(NONE) clause requires that 'loop' must be listed in a data-sharing attribute clause This patch fixes this by adding a condition to check and skip processing construct-names.
1 parent b1080e1 commit 40fae67

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,12 @@ void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) {
19821982
void OmpAttributeVisitor::Post(const parser::Name &name) {
19831983
auto *symbol{name.symbol};
19841984
if (symbol && !dirContext_.empty() && GetContext().withinConstruct) {
1985+
// Exclude construct-names
1986+
if (auto *details{symbol->detailsIf<semantics::MiscDetails>()}) {
1987+
if (details->kind() == semantics::MiscDetails::Kind::ConstructName) {
1988+
return;
1989+
}
1990+
}
19851991
if (!symbol->owner().IsDerivedType() && !IsProcedure(*symbol) &&
19861992
!IsObjectWithDSA(*symbol) && !IsNamedConstant(*symbol)) {
19871993
// TODO: create a separate function to go through the rules for

flang/test/Semantics/OpenMP/default-none.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,11 @@ subroutine sb3(x)
3939
print *, x
4040
end subroutine
4141
end subroutine
42+
43+
!construct-name inside default(none)
44+
subroutine sb4
45+
!$omp parallel default(none)
46+
loop: do i = 1, 10
47+
end do loop
48+
!$omp end parallel
49+
end subroutine

0 commit comments

Comments
 (0)