Skip to content

Commit d602f93

Browse files
authored
[flang][OpenMP] Treat POINTER variables as valid variable list items (#111722)
Follow-up to 418920b, which started diagnosing the legality of objects in OpenMP clauses (and caused some test failures).
1 parent e073717 commit d602f93

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,12 @@ bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
200200
return CheckAllowed(clause);
201201
}
202202

203+
bool OmpStructureChecker::IsVariableListItem(const Symbol &sym) {
204+
return evaluate::IsVariable(sym) || sym.attrs().test(Attr::POINTER);
205+
}
206+
203207
bool OmpStructureChecker::IsExtendedListItem(const Symbol &sym) {
204-
return evaluate::IsVariable(sym) || sym.IsSubprogram();
208+
return IsVariableListItem(sym) || sym.IsSubprogram();
205209
}
206210

207211
bool OmpStructureChecker::IsCloselyNestedRegion(const OmpDirectiveSet &set) {
@@ -2351,7 +2355,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) {
23512355
SymbolSourceMap symbols;
23522356
GetSymbolsInObjectList(*objList, symbols);
23532357
for (const auto &[sym, source] : symbols) {
2354-
if (!evaluate::IsVariable(sym)) {
2358+
if (!IsVariableListItem(*sym)) {
23552359
deferredNonVariables_.insert({sym, source});
23562360
}
23572361
}
@@ -3428,7 +3432,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::To &x) {
34283432
SymbolSourceMap symbols;
34293433
GetSymbolsInObjectList(objList, symbols);
34303434
for (const auto &[sym, source] : symbols) {
3431-
if (!evaluate::IsVariable(*sym)) {
3435+
if (!IsVariableListItem(*sym)) {
34323436
context_.SayWithDecl(
34333437
*sym, source, "'%s' must be a variable"_err_en_US, sym->name());
34343438
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class OmpStructureChecker
141141

142142
private:
143143
bool CheckAllowedClause(llvmOmpClause clause);
144+
bool IsVariableListItem(const Symbol &sym);
144145
bool IsExtendedListItem(const Symbol &sym);
145146
void CheckMultipleOccurrence(semantics::UnorderedSymbolSet &listVars,
146147
const std::list<parser::Name> &nameList, const parser::CharBlock &item,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
!RUN: %flang_fc1 -fopenmp -emit-fir -o - %s | FileCheck %s
2+
!RUN: bbc -fopenmp -emit-fir -o - %s | FileCheck %s
3+
4+
!Allow POINTER variables in OpenMP SHARED clause. Check that this
5+
!code compiles.
6+
7+
!CHECK-LABEL: func.func @_QPfoo
8+
subroutine foo()
9+
procedure(), pointer :: pf
10+
!$omp parallel shared(pf)
11+
!$omp end parallel
12+
end
13+

0 commit comments

Comments
 (0)