Skip to content

Commit

Permalink
[flang] More Cray pointee checks (#78624)
Browse files Browse the repository at this point in the history
Cray pointees may not appear in COMMON blocks or EQUIVALENCE groups.

Fixes llvm-test-suite/Fortran/gfortran/regression/cray_pointers_4.f90.
  • Loading branch information
klausler committed Jan 25, 2024
1 parent 7d27272 commit b788d62
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ void CheckHelper::CheckCommonBlock(const Symbol &symbol) {
if (symbol.attrs().test(Attr::BIND_C)) {
CheckBindC(symbol);
}
for (MutableSymbolRef ref : symbol.get<CommonBlockDetails>().objects()) {
if (ref->test(Symbol::Flag::CrayPointee)) {
messages_.Say(ref->name(),
"Cray pointee '%s' may not be a member of a COMMON block"_err_en_US,
ref->name());
}
}
}

// C859, C860
Expand Down Expand Up @@ -2509,6 +2516,13 @@ void CheckHelper::CheckEquivalenceSet(const EquivalenceSet &set) {
}
}
// TODO: Move C8106 (&al.) checks here from resolve-names-utils.cpp
for (const EquivalenceObject &object : set) {
if (object.symbol.test(Symbol::Flag::CrayPointee)) {
messages_.Say(object.symbol.name(),
"Cray pointee '%s' may not be a member of an EQUIVALENCE group"_err_en_US,
object.symbol.name());
}
}
}

void CheckHelper::CheckBlockData(const Scope &scope) {
Expand Down
8 changes: 8 additions & 0 deletions flang/test/Semantics/declarations08.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
pointer(p,x)
!ERROR: Cray pointee 'y' may not be a member of an EQUIVALENCE group
pointer(p,y)
!ERROR: Cray pointee 'x' may not be a member of a COMMON block
common x
equivalence(y,z)
end

0 comments on commit b788d62

Please sign in to comment.