Skip to content

[Flang][OpenMP] Issue error if reduction clause has proc-pointer #88999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
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