Skip to content

Commit d006f32

Browse files
raghavendhraDanielCChen
authored andcommitted
[Flang] [Semantics] [OpenMP] Fix semantic check to not report error for compound OMP TARGET directives. (llvm#112059)
For test program like this variable array is mentioned in both shared clause and map clause. For OMP TARGET compound directives like this where we have OMP TARGET TEAMS, map clause applies to TARGET directive and SHARED clause applies to TEAMS directive. So both SHARED and MAP clauses can co-exist. > program test > implicit none > integer :: array(10,10),i,j > !$omp target teams shared(array) map(tofrom:array) > do i=1,10 > !$omp parallel do > do j=1,10 > array(j,i)=i+j > end do > end do > !$omp end target teams > print *, array > end program test > > Before this PR we were checking for exclusivity for all target directives set which is now relaxed to exclusivity check not being applied to compound directives which can accept SHARED clause.
1 parent f908c74 commit d006f32

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,10 +2418,16 @@ void OmpAttributeVisitor::ResolveOmpObject(
24182418
Symbol::Flag::OmpLastPrivate, Symbol::Flag::OmpShared,
24192419
Symbol::Flag::OmpLinear};
24202420

2421-
for (Symbol::Flag ompFlag1 : dataMappingAttributeFlags) {
2422-
for (Symbol::Flag ompFlag2 : dataSharingAttributeFlags) {
2423-
checkExclusivelists(
2424-
hostAssocSym, ompFlag1, symbol, ompFlag2);
2421+
// For OMP TARGET TEAMS directive some sharing attribute
2422+
// flags and mapping attribute flags can co-exist.
2423+
if (!(llvm::omp::allTeamsSet.test(GetContext().directive) ||
2424+
llvm::omp::allParallelSet.test(
2425+
GetContext().directive))) {
2426+
for (Symbol::Flag ompFlag1 : dataMappingAttributeFlags) {
2427+
for (Symbol::Flag ompFlag2 : dataSharingAttributeFlags) {
2428+
checkExclusivelists(
2429+
hostAssocSym, ompFlag1, symbol, ompFlag2);
2430+
}
24252431
}
24262432
}
24272433
}

0 commit comments

Comments
 (0)