diff options
author | Kiran Chandramohan <kiran.chandramohan@arm.com> | 2024-04-19 12:47:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-19 12:47:31 +0100 |
commit | b3c72bcbf2eb7963ef0ac3da519107aba151f77f (patch) | |
tree | 6cec47257957e50535e52de8e25f6061454d81d7 | |
parent | df411fbac60825d07090ce17391db7606d8400f1 (diff) | |
download | llvm-b3c72bcbf2eb7963ef0ac3da519107aba151f77f.zip llvm-b3c72bcbf2eb7963ef0ac3da519107aba151f77f.tar.gz llvm-b3c72bcbf2eb7963ef0ac3da519107aba151f77f.tar.bz2 |
[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
-rw-r--r-- | flang/lib/Semantics/check-omp-structure.cpp | 11 | ||||
-rw-r--r-- | flang/test/Semantics/OpenMP/reduction12.f90 | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index bafa242..56653aa 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -2286,6 +2286,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Reduction &x) { CheckReductionTypeList(x); } } + bool OmpStructureChecker::CheckReductionOperators( const parser::OmpClause::Reduction &x) { @@ -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( diff --git a/flang/test/Semantics/OpenMP/reduction12.f90 b/flang/test/Semantics/OpenMP/reduction12.f90 new file mode 100644 index 0000000..f896ca4 --- /dev/null +++ b/flang/test/Semantics/OpenMP/reduction12.f90 @@ -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 |