diff options
author | harishch4 <harishcse44@gmail.com> | 2024-02-21 17:44:54 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-21 17:44:54 +0530 |
commit | 40fae67a50e08e6b5b5300210021218e404d63a7 (patch) | |
tree | 435aadc0a30dbb34204a73e7b8c6f007c29a7e3e /flang | |
parent | b1080e187e91576ac6d44087f072583e101f0f51 (diff) | |
download | llvm-40fae67a50e08e6b5b5300210021218e404d63a7.zip llvm-40fae67a50e08e6b5b5300210021218e404d63a7.tar.gz llvm-40fae67a50e08e6b5b5300210021218e404d63a7.tar.bz2 |
[Flang][OpenMP] Fix to construct-names inside OpenMP construct with default(none) (#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.
Diffstat (limited to 'flang')
-rw-r--r-- | flang/lib/Semantics/resolve-directives.cpp | 6 | ||||
-rw-r--r-- | flang/test/Semantics/OpenMP/default-none.f90 | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index 4b6d083..a826f01 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<semantics::MiscDetails>()}) { + 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 d027f46..11ba878 100644 --- a/flang/test/Semantics/OpenMP/default-none.f90 +++ b/flang/test/Semantics/OpenMP/default-none.f90 @@ -39,3 +39,11 @@ contains 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 |