} else if (const auto *intrinsic{call.proc().GetSpecificIntrinsic()}) {
if (intrinsic->name == "shape" || intrinsic->name == "lbound" ||
intrinsic->name == "ubound") {
- // These are the array-valued cases for LBOUND and UBOUND (no DIM=).
- const auto *expr{call.arguments().front().value().UnwrapExpr()};
- CHECK(expr);
- return Shape{MaybeExtentExpr{ExtentExpr{expr->Rank()}}};
+ // For LBOUND/UBOUND, these are the array-valued cases (no DIM=)
+ if (!call.arguments().empty() && call.arguments().front()) {
+ return Shape{
+ MaybeExtentExpr{ExtentExpr{call.arguments().front()->Rank()}}};
+ }
} else if (intrinsic->name == "all" || intrinsic->name == "any" ||
intrinsic->name == "count" || intrinsic->name == "iall" ||
intrinsic->name == "iany" || intrinsic->name == "iparity" ||
messages.Say(
"Assumed-type '%s' may be associated only with an assumed-type %s"_err_en_US,
assumed.name(), dummyName);
- } else {
- const auto *details{assumed.detailsIf<ObjectEntityDetails>()};
- if (!(IsAssumedShape(assumed) ||
- (details && details->IsAssumedRank()))) {
- messages.Say( // C711
- "Assumed-type '%s' must be either assumed shape or assumed rank to be associated with assumed-type %s"_err_en_US,
- assumed.name(), dummyName);
- }
+ } else if (object.type.attrs().test(evaluate::characteristics::
+ TypeAndShape::Attr::AssumedRank) &&
+ !IsAssumedShape(assumed) &&
+ !evaluate::IsAssumedRank(assumed)) {
+ messages.Say( // C711
+ "Assumed-type '%s' must be either assumed shape or assumed rank to be associated with assumed rank %s"_err_en_US,
+ assumed.name(), dummyName);
}
}
},
! RUN: %python %S/test_errors.py %s %flang_fc1
-! C711 An assumed-type actual argument that corresponds to an assumed-rank
+! C711 An assumed-type actual argument that corresponds to an assumed-rank
! dummy argument shall be assumed-shape or assumed-rank.
subroutine s(arg1, arg2, arg3)
type(*), dimension(..) :: arg1 ! assumed rank
call inner(arg1) ! OK, assumed rank
call inner(arg2) ! OK, assumed shape
- !ERROR: Assumed-type 'arg3' must be either assumed shape or assumed rank to be associated with assumed-type dummy argument 'dummy='
+ !ERROR: Assumed-type 'arg3' must be either assumed shape or assumed rank to be associated with assumed rank dummy argument 'dummy='
call inner(arg3)
contains