Skip to content

Commit c4c9d21

Browse files
committed
[Flang][OpenMP] Fixed semantic error when list item with a private data-sharing clause used in 'allocate' clause of 'taskgroup' construct
1 parent 5cfc6bc commit c4c9d21

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,15 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
15421542
}
15431543
if (beginDir.v == llvm::omp::Directive::OMPD_master)
15441544
IssueNonConformanceWarning(beginDir.v, beginDir.source);
1545-
ClearDataSharingAttributeObjects();
1546-
ClearPrivateDataSharingAttributeObjects();
1545+
1546+
// The omp_taskgroup directive doesn't have its own data-sharing clauses.
1547+
// It inherits data-sharing attributes from the surrounding context.
1548+
// Therefore, don't clear the data-sharing attributes if it's an omp taskgroup
1549+
if (beginDir.v != llvm::omp::Directive::OMPD_taskgroup) {
1550+
ClearDataSharingAttributeObjects();
1551+
ClearPrivateDataSharingAttributeObjects();
1552+
}
1553+
15471554
ClearAllocateNames();
15481555
return true;
15491556
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
! RUN: %flang_fc1 -fopenmp -fsyntax-only %s
2+
3+
! Verify that a list item with a private data-sharing clause used in the 'allocate' clause of 'taskgroup'
4+
! causes no semantic errors.
5+
6+
subroutine omp_allocate_taskgroup
7+
integer :: x
8+
!$omp parallel private(x)
9+
!$omp taskgroup allocate(x)
10+
!$omp end taskgroup
11+
!$omp end parallel
12+
end subroutine

0 commit comments

Comments
 (0)