Skip to content
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
9 changes: 7 additions & 2 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3070,8 +3070,13 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
// place for the types specified.
if (Symbol * found{currScope().FindSymbol(name.source)}) {
// If the variable has declare target applied to it (enter or link) it
// is exempt from defaultmap(none) restrictions
if (!symbol->GetUltimate().test(Symbol::Flag::OmpDeclareTarget)) {
// is exempt from defaultmap(none) restrictions.
// We also exempt procedures and named constants from defaultmap(none)
// checking.
if (!symbol->GetUltimate().test(Symbol::Flag::OmpDeclareTarget) &&
!(IsProcedure(*symbol) &&
!semantics::IsProcedurePointer(*symbol)) &&
!IsNamedConstant(*symbol)) {
auto &dMap = GetContext().defaultMap;
for (auto defaults : dMap) {
if (defaults.second ==
Expand Down
37 changes: 37 additions & 0 deletions flang/test/Semantics/OpenMP/defaultmap-clause-none.f90
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,40 @@ subroutine defaultmap_aggregate_none
end do
!$omp end target
end subroutine defaultmap_aggregate_none

! Verify we do not catch null in defaultmap(none)
subroutine defaultmap_builtin_none
implicit none
integer, pointer :: ptr(:)

!$omp target defaultmap(none) map(ptr)
!CHECK-NOT: The DEFAULTMAP(NONE) clause requires that 'null' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause
ptr => null()
!$omp end target
end subroutine defaultmap_builtin_none

module pro
implicit none
contains

function test_procedure() result(ret)
integer :: ret
ret = 1
end function test_procedure

! Verify we do not catch a function symbol in defaultmap(none)
! but do catch procedure pointers
subroutine defaultmap_func_and_procedure_pointer()
implicit none
procedure(test_procedure), pointer :: f1
integer :: i

f1 => test_procedure

!$omp target defaultmap(none) map(i)
!ERROR: The DEFAULTMAP(NONE) clause requires that 'f1' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause
i = f1()
i = test_procedure()
!$omp end target
end subroutine defaultmap_func_and_procedure_pointer
end module
Loading