From 8a7a7a46d09ccd9eabc535bd34a35cb4c2731132 Mon Sep 17 00:00:00 2001 From: Raghu Maddhipatla <7686592+raghavendhra@users.noreply.github.com> Date: Mon, 14 Oct 2024 08:39:25 -0500 Subject: [PATCH] [Flang] [Semantics] [OpenMP] Fix semantic check to not report error for compound OMP TARGET directives. (#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. --- flang/lib/Semantics/resolve-directives.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index 8eb40058b437b..186b58bcc52c3 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -2418,10 +2418,16 @@ void OmpAttributeVisitor::ResolveOmpObject( Symbol::Flag::OmpLastPrivate, Symbol::Flag::OmpShared, Symbol::Flag::OmpLinear}; - for (Symbol::Flag ompFlag1 : dataMappingAttributeFlags) { - for (Symbol::Flag ompFlag2 : dataSharingAttributeFlags) { - checkExclusivelists( - hostAssocSym, ompFlag1, symbol, ompFlag2); + // For OMP TARGET TEAMS directive some sharing attribute + // flags and mapping attribute flags can co-exist. + if (!(llvm::omp::allTeamsSet.test(GetContext().directive) || + llvm::omp::allParallelSet.test( + GetContext().directive))) { + for (Symbol::Flag ompFlag1 : dataMappingAttributeFlags) { + for (Symbol::Flag ompFlag2 : dataSharingAttributeFlags) { + checkExclusivelists( + hostAssocSym, ompFlag1, symbol, ompFlag2); + } } } }