Skip to content

[Flang][OpenMP] Avoid default none errors for seq loop indices in par… #76258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,11 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
if (Symbol * found{currScope().FindSymbol(name.source)}) {
if (symbol != found) {
name.symbol = found; // adjust the symbol within region
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone) {
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
// Exclude indices of sequential loops that are privatised in
// the scope of the parallel region, and not in this scope.
// TODO: check whether this should be caught in IsObjectWithDSA
!symbol->test(Symbol::Flag::OmpPrivate)) {
context_.Say(name.source,
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
"a data-sharing attribute clause"_err_en_US,
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Semantics/OpenMP/resolve05.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ subroutine default_none()
!$omp end parallel
end subroutine default_none

! Test that indices of sequential loops are privatised and hence do not error
! for DEFAULT(NONE)
subroutine default_none_seq_loop
integer :: i

!$omp parallel do default(none)
do i = 1, 10
do j = 1, 20
enddo
enddo
end subroutine

program mm
call default_none()
call default_none_seq_loop()
!TODO: private, firstprivate, shared
end