Skip to content

Commit b788d62

Browse files
authored
[flang] More Cray pointee checks (llvm#78624)
Cray pointees may not appear in COMMON blocks or EQUIVALENCE groups. Fixes llvm-test-suite/Fortran/gfortran/regression/cray_pointers_4.f90.
1 parent 7d27272 commit b788d62

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,13 @@ void CheckHelper::CheckCommonBlock(const Symbol &symbol) {
455455
if (symbol.attrs().test(Attr::BIND_C)) {
456456
CheckBindC(symbol);
457457
}
458+
for (MutableSymbolRef ref : symbol.get<CommonBlockDetails>().objects()) {
459+
if (ref->test(Symbol::Flag::CrayPointee)) {
460+
messages_.Say(ref->name(),
461+
"Cray pointee '%s' may not be a member of a COMMON block"_err_en_US,
462+
ref->name());
463+
}
464+
}
458465
}
459466

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

25142528
void CheckHelper::CheckBlockData(const Scope &scope) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
2+
pointer(p,x)
3+
!ERROR: Cray pointee 'y' may not be a member of an EQUIVALENCE group
4+
pointer(p,y)
5+
!ERROR: Cray pointee 'x' may not be a member of a COMMON block
6+
common x
7+
equivalence(y,z)
8+
end

0 commit comments

Comments
 (0)