Skip to content

Commit

Permalink
[Flang][OpenMP] Issue error if reduction clause has proc-pointer (#88999
Browse files Browse the repository at this point in the history
)

OpenMP 5.2: Section 5.5.5: A procedure pointer must not appear in a
reduction clause.

Fixes #87915
  • Loading branch information
kiranchandramohan authored Apr 19, 2024
1 parent df411fb commit b3c72bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Reduction &x) {
CheckReductionTypeList(x);
}
}

bool OmpStructureChecker::CheckReductionOperators(
const parser::OmpClause::Reduction &x) {

Expand Down Expand Up @@ -2356,6 +2357,16 @@ void OmpStructureChecker::CheckReductionTypeList(
if (llvm::omp::nestedReduceWorkshareAllowedSet.test(GetContext().directive)) {
CheckSharedBindingInOuterContext(ompObjectList);
}

SymbolSourceMap symbols;
GetSymbolsInObjectList(ompObjectList, symbols);
for (auto &[symbol, source] : symbols) {
if (IsProcedurePointer(*symbol)) {
context_.Say(source,
"A procedure pointer '%s' must not appear in a REDUCTION clause."_err_en_US,
symbol->name());
}
}
}

void OmpStructureChecker::CheckIntentInPointerAndDefinable(
Expand Down
16 changes: 16 additions & 0 deletions flang/test/Semantics/OpenMP/reduction12.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp

! OpenMP 5.2: Section 5.5.5 : A procedure pointer must not appear in a
! reduction clause.

procedure(foo), pointer :: ptr
integer :: i
ptr => foo
!ERROR: A procedure pointer 'ptr' must not appear in a REDUCTION clause.
!$omp do reduction (+ : ptr)
do i = 1, 10
end do
contains
subroutine foo
end subroutine
end

0 comments on commit b3c72bc

Please sign in to comment.