Skip to content
Closed
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
11 changes: 9 additions & 2 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,8 +1542,15 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
}
if (beginDir.v == llvm::omp::Directive::OMPD_master)
IssueNonConformanceWarning(beginDir.v, beginDir.source);
ClearDataSharingAttributeObjects();
ClearPrivateDataSharingAttributeObjects();

// The omp_taskgroup directive doesn't have its own data-sharing clauses.
// It inherits data-sharing attributes from the surrounding context.
// Therefore, don't clear the data-sharing attributes if it's an omp taskgroup
if (beginDir.v != llvm::omp::Directive::OMPD_taskgroup) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only for taskgroup? Are there other constructs like this?

Copy link
Contributor Author

@kaviya2510 kaviya2510 Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments.
yes, This is only for taskgroup.
All other construct which uses allocate clause other than taskgroup and allocators accepts datasharing attribute clauses as per Openmp 5.2 standard.
This case is already handled in allocators directive and this issue is only observed with allocate cause of taskgroup construct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kiranchandramohan,
Hope you have read my comments. Please do let me know if it needs any further changes.

ClearDataSharingAttributeObjects();
ClearPrivateDataSharingAttributeObjects();
}

ClearAllocateNames();
return true;
}
Expand Down
12 changes: 12 additions & 0 deletions flang/test/Semantics/OpenMP/omp_taskgroup_allocate.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
! RUN: %flang_fc1 -fopenmp -fopenmp-version=50 -fsyntax-only %s

! Verify that a list item with a private data-sharing clause used in the 'allocate' clause of 'taskgroup'
! causes no semantic errors.

subroutine omp_allocate_taskgroup
integer :: x
!$omp parallel private(x)
!$omp taskgroup allocate(x)
!$omp end taskgroup
!$omp end parallel
end subroutine