return std::nullopt;
}
std::optional<CoarrayRef> operator()(const CoarrayRef &x) const { return x; }
+ template<typename A>
+ std::optional<CoarrayRef> operator()(const Expr<A> &expr) const {
+ return std::visit(*this, expr.u);
+ }
std::optional<CoarrayRef> operator()(const DataRef &dataRef) const {
return std::visit(*this, dataRef.u);
}
return std::nullopt;
}
}
+ std::optional<CoarrayRef> operator()(const ProcedureDesignator &des) const {
+ if (const auto *component{
+ std::get_if<common::CopyableIndirection<Component>>(&des.u)}) {
+ return (*this)(component->value());
+ } else {
+ return std::nullopt;
+ }
+ }
std::optional<CoarrayRef> operator()(const Component &component) const {
return (*this)(component.base());
}
if (auto dataRef{ExtractDataRef(x)}) {
return ExtractCoindexedObjectHelper{}(*dataRef);
} else {
- return std::nullopt;
+ return ExtractCoindexedObjectHelper{}(x);
}
}
if (lhs && rhs) {
CheckForPureContext(
*lhs, *rhs, std::get<parser::Expr>(stmt.t).source, true /* => */);
+ const Symbol *pointer{GetLastSymbol(lhs)};
+ if (pointer && pointer->has<ProcEntityDetails>() &&
+ evaluate::ExtractCoarrayRef(*lhs)) {
+ context_.Say( // C1027
+ "Procedure pointer may not be a coindexed object"_err_en_US);
+ }
}
// TODO continue here, using CheckPointerAssignment()
}
--- /dev/null
+module m
+ interface
+ subroutine s(i)
+ integer i
+ end
+ end interface
+ type :: t
+ procedure(s), pointer, nopass :: p
+ end type
+contains
+ ! C1027
+ subroutine s1
+ type(t), allocatable :: a(:)
+ type(t), allocatable :: b[:]
+ a(1)%p => s
+ !ERROR: Procedure pointer may not be a coindexed object
+ b[1]%p => s
+ end
+end