Skip to content

Commit b3c72bc

Browse files
[Flang][OpenMP] Issue error if reduction clause has proc-pointer (#88999)
OpenMP 5.2: Section 5.5.5: A procedure pointer must not appear in a reduction clause. Fixes #87915
1 parent df411fb commit b3c72bc

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Reduction &x) {
22862286
CheckReductionTypeList(x);
22872287
}
22882288
}
2289+
22892290
bool OmpStructureChecker::CheckReductionOperators(
22902291
const parser::OmpClause::Reduction &x) {
22912292

@@ -2356,6 +2357,16 @@ void OmpStructureChecker::CheckReductionTypeList(
23562357
if (llvm::omp::nestedReduceWorkshareAllowedSet.test(GetContext().directive)) {
23572358
CheckSharedBindingInOuterContext(ompObjectList);
23582359
}
2360+
2361+
SymbolSourceMap symbols;
2362+
GetSymbolsInObjectList(ompObjectList, symbols);
2363+
for (auto &[symbol, source] : symbols) {
2364+
if (IsProcedurePointer(*symbol)) {
2365+
context_.Say(source,
2366+
"A procedure pointer '%s' must not appear in a REDUCTION clause."_err_en_US,
2367+
symbol->name());
2368+
}
2369+
}
23592370
}
23602371

23612372
void OmpStructureChecker::CheckIntentInPointerAndDefinable(
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2+
3+
! OpenMP 5.2: Section 5.5.5 : A procedure pointer must not appear in a
4+
! reduction clause.
5+
6+
procedure(foo), pointer :: ptr
7+
integer :: i
8+
ptr => foo
9+
!ERROR: A procedure pointer 'ptr' must not appear in a REDUCTION clause.
10+
!$omp do reduction (+ : ptr)
11+
do i = 1, 10
12+
end do
13+
contains
14+
subroutine foo
15+
end subroutine
16+
end

0 commit comments

Comments
 (0)