[flang-commits] [flang] [Flang][OpenMP] Issue error if reduction clause has proc-pointer (PR #88999)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Tue Apr 16 15:54:53 PDT 2024
https://github.com/kiranchandramohan created https://github.com/llvm/llvm-project/pull/88999
OpenMP 5.2: Section 5.5.5: A procedure pointer must not appear in a reduction clause.
Fixes #87915
>From 964f31f7a4cbac7d53bfbe084005ffcbb01eed90 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Tue, 16 Apr 2024 21:30:02 +0000
Subject: [PATCH] [Flang][OpenMP] Issue error if reduction clause has
proc-pointer
Fixes #87915
---
flang/lib/Semantics/check-omp-structure.cpp | 12 ++++++++++++
flang/test/Semantics/OpenMP/reduction12.f90 | 16 ++++++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 flang/test/Semantics/OpenMP/reduction12.f90
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index e85d8d1f7ab533..ec853de4b5ca74 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2285,7 +2285,19 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Reduction &x) {
if (CheckReductionOperators(x)) {
CheckReductionTypeList(x);
}
+
+ SymbolSourceMap symbols;
+ const auto &ompObjectList{std::get<parser::OmpObjectList>(x.v.t)};
+ 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());
+ }
+ }
}
+
bool OmpStructureChecker::CheckReductionOperators(
const parser::OmpClause::Reduction &x) {
diff --git a/flang/test/Semantics/OpenMP/reduction12.f90 b/flang/test/Semantics/OpenMP/reduction12.f90
new file mode 100644
index 00000000000000..f896ca4aa60b67
--- /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
More information about the flang-commits
mailing list