diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp index 8315864bcb718..8f0c5ccb79f29 100644 --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -455,6 +455,13 @@ void CheckHelper::CheckCommonBlock(const Symbol &symbol) { if (symbol.attrs().test(Attr::BIND_C)) { CheckBindC(symbol); } + for (MutableSymbolRef ref : symbol.get().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 @@ -2514,6 +2521,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) { diff --git a/flang/test/Semantics/declarations08.f90 b/flang/test/Semantics/declarations08.f90 new file mode 100644 index 0000000000000..bd14131b33c28 --- /dev/null +++ b/flang/test/Semantics/declarations08.f90 @@ -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