[flang-commits] [flang] [flang][OpenMP] Tread POINTER variables as valid variable list items (PR #111722)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Wed Oct 9 10:25:04 PDT 2024
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/111722
Follow-up to 418920b3fbdefec5b56ee2b9db96884d0ada7329, which started diagnosing the legality of objects in OpenMP clauses (and caused some test failures).
>From efbd6c678fab2ce8747acaa009d10e6368fc36ce Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 9 Oct 2024 12:15:46 -0500
Subject: [PATCH] [flang][OpenMP] Tread POINTER variables as valid variable
list items
Follow-up to 418920b3fbdefec5b56ee2b9db96884d0ada7329, which started
diagnosing the legality of objects in OpenMP clauses (and caused some
test failures).
---
flang/lib/Semantics/check-omp-structure.cpp | 10 +++++++---
flang/lib/Semantics/check-omp-structure.h | 1 +
flang/test/Semantics/OpenMP/shared-pointer.f90 | 13 +++++++++++++
3 files changed, 21 insertions(+), 3 deletions(-)
create mode 100644 flang/test/Semantics/OpenMP/shared-pointer.f90
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index cf90c92bbf3c4d..a54fa14730321b 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -200,8 +200,12 @@ bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
return CheckAllowed(clause);
}
+bool OmpStructureChecker::IsVariableListItem(const Symbol &sym) {
+ return evaluate::IsVariable(sym) || sym.attrs().test(Attr::POINTER);
+}
+
bool OmpStructureChecker::IsExtendedListItem(const Symbol &sym) {
- return evaluate::IsVariable(sym) || sym.IsSubprogram();
+ return IsVariableListItem(sym) || sym.IsSubprogram();
}
bool OmpStructureChecker::IsCloselyNestedRegion(const OmpDirectiveSet &set) {
@@ -2351,7 +2355,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) {
SymbolSourceMap symbols;
GetSymbolsInObjectList(*objList, symbols);
for (const auto &[sym, source] : symbols) {
- if (!evaluate::IsVariable(sym)) {
+ if (!IsVariableListItem(*sym)) {
deferredNonVariables_.insert({sym, source});
}
}
@@ -3428,7 +3432,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::To &x) {
SymbolSourceMap symbols;
GetSymbolsInObjectList(objList, symbols);
for (const auto &[sym, source] : symbols) {
- if (!evaluate::IsVariable(*sym)) {
+ if (!IsVariableListItem(*sym)) {
context_.SayWithDecl(
*sym, source, "'%s' must be a variable"_err_en_US, sym->name());
}
diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h
index e6863b53ecfdef..a8e60b411e1846 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -141,6 +141,7 @@ class OmpStructureChecker
private:
bool CheckAllowedClause(llvmOmpClause clause);
+ bool IsVariableListItem(const Symbol &sym);
bool IsExtendedListItem(const Symbol &sym);
void CheckMultipleOccurrence(semantics::UnorderedSymbolSet &listVars,
const std::list<parser::Name> &nameList, const parser::CharBlock &item,
diff --git a/flang/test/Semantics/OpenMP/shared-pointer.f90 b/flang/test/Semantics/OpenMP/shared-pointer.f90
new file mode 100644
index 00000000000000..6826086d02a54b
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/shared-pointer.f90
@@ -0,0 +1,13 @@
+!RUN: %flang_fc1 -fopenmp -emit-fir -o - %s | FileCheck %s
+!RUN: bbc -fopenmp -emit-fir -o - %s | FileCheck %s
+
+!Allow POINTER variables in OpenMP SHARED clause. Check that this
+!code compiles.
+
+!CHECK-LABEL: func.func @_QPfoo
+subroutine foo()
+ procedure(), pointer :: pf
+ !$omp parallel shared(pf)
+ !$omp end parallel
+end
+
More information about the flang-commits
mailing list