@@ -464,22 +464,27 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
464
464
: nullptr };
465
465
int actualRank{actualType.Rank ()};
466
466
bool actualIsPointer{evaluate::IsObjectPointer (actual)};
467
+ bool actualIsAssumedRank{evaluate::IsAssumedRank (actual)};
467
468
if (dummy.type .attrs ().test (
468
469
characteristics::TypeAndShape::Attr::AssumedShape)) {
469
470
// 15.5.2.4(16)
470
- if (actualRank == 0 ) {
471
+ if (actualIsAssumedRank) {
472
+ messages.Say (
473
+ " Assumed-rank actual argument may not be associated with assumed-shape %s" _err_en_US,
474
+ dummyName);
475
+ } else if (actualRank == 0 ) {
471
476
messages.Say (
472
477
" Scalar actual argument may not be associated with assumed-shape %s" _err_en_US,
473
478
dummyName);
474
- }
475
- if (actualIsAssumedSize && actualLastSymbol) {
479
+ } else if (actualIsAssumedSize && actualLastSymbol) {
476
480
evaluate::SayWithDeclaration (messages, *actualLastSymbol,
477
481
" Assumed-size array may not be associated with assumed-shape %s" _err_en_US,
478
482
dummyName);
479
483
}
480
484
} else if (dummyRank > 0 ) {
481
485
bool basicError{false };
482
- if (actualRank == 0 && !dummyIsAllocatableOrPointer) {
486
+ if (actualRank == 0 && !actualIsAssumedRank &&
487
+ !dummyIsAllocatableOrPointer) {
483
488
// Actual is scalar, dummy is an array. F'2023 15.5.2.5p14
484
489
if (actualIsCoindexed) {
485
490
basicError = true ;
@@ -532,7 +537,7 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
532
537
characteristics::DummyDataObject::Attr::DeducedFromActual)) {
533
538
if (auto dummySize{evaluate::ToInt64 (evaluate::Fold (foldingContext,
534
539
evaluate::GetSize (evaluate::Shape{dummy.type .shape ()})))}) {
535
- if (actualRank == 0 ) {
540
+ if (actualRank == 0 && !actualIsAssumedRank ) {
536
541
if (evaluate::IsArrayElement (actual)) {
537
542
// Actual argument is a scalar array element
538
543
evaluate::DesignatorFolder folder{
@@ -569,7 +574,7 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
569
574
}
570
575
}
571
576
}
572
- } else { // actualRank > 0
577
+ } else { // actualRank > 0 || actualIsAssumedRank
573
578
if (auto actualSize{evaluate::ToInt64 (evaluate::Fold (foldingContext,
574
579
evaluate::GetSize (evaluate::Shape (actualType.shape ()))))};
575
580
actualSize && *actualSize < *dummySize) {
@@ -645,7 +650,7 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
645
650
" Coindexed ASYNCHRONOUS or VOLATILE actual argument may not be associated with %s with ASYNCHRONOUS or VOLATILE attributes unless VALUE" _err_en_US,
646
651
dummyName);
647
652
}
648
- if (actualRank > 0 && !actualIsContiguous) {
653
+ if (( actualRank > 0 || actualIsAssumedRank) && !actualIsContiguous) {
649
654
if (dummyIsContiguous ||
650
655
!(dummyIsAssumedShape || dummyIsAssumedRank ||
651
656
(actualIsPointer && dummyIsPointer))) { // C1539 & C1540
0 commit comments