@@ -89,13 +89,11 @@ class AllocationCheckerHelper {
89
89
const int allocateCoarraySpecRank_{0 };
90
90
const parser::Name &name_{parser::GetLastName (allocateObject_)};
91
91
// no USE or host association
92
- const Symbol *original_ {
92
+ const Symbol *ultimate_ {
93
93
name_.symbol ? &name_.symbol ->GetUltimate () : nullptr };
94
- // no USE, host, or construct association
95
- const Symbol *symbol_{original_ ? &ResolveAssociations (*original_) : nullptr };
96
- const DeclTypeSpec *type_{symbol_ ? symbol_->GetType () : nullptr };
97
- const int rank_{original_ ? original_->Rank () : 0 };
98
- const int corank_{symbol_ ? symbol_->Corank () : 0 };
94
+ const DeclTypeSpec *type_{ultimate_ ? ultimate_->GetType () : nullptr };
95
+ const int rank_{ultimate_ ? ultimate_->Rank () : 0 };
96
+ const int corank_{ultimate_ ? ultimate_->Corank () : 0 };
99
97
bool hasDeferredTypeParameter_{false };
100
98
bool isUnlimitedPolymorphic_{false };
101
99
bool isAbstract_{false };
@@ -448,11 +446,11 @@ static bool HaveCompatibleLengths(
448
446
}
449
447
450
448
bool AllocationCheckerHelper::RunChecks (SemanticsContext &context) {
451
- if (!symbol_ ) {
449
+ if (!ultimate_ ) {
452
450
CHECK (context.AnyFatalError ());
453
451
return false ;
454
452
}
455
- if (!IsVariableName (*symbol_ )) { // C932 pre-requisite
453
+ if (!IsVariableName (*ultimate_ )) { // C932 pre-requisite
456
454
context.Say (name_.source ,
457
455
" Name in ALLOCATE statement must be a variable name" _err_en_US);
458
456
return false ;
@@ -465,7 +463,7 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
465
463
return false ;
466
464
}
467
465
GatherAllocationBasicInfo ();
468
- if (!IsAllocatableOrPointer (*symbol_ )) { // C932
466
+ if (!IsAllocatableOrObjectPointer (ultimate_ )) { // C932
469
467
context.Say (name_.source ,
470
468
" Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute" _err_en_US);
471
469
return false ;
@@ -537,11 +535,16 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
537
535
}
538
536
}
539
537
// Shape related checks
540
- if (symbol_ && evaluate::IsAssumedRank (*symbol_ )) {
538
+ if (ultimate_ && evaluate::IsAssumedRank (*ultimate_ )) {
541
539
context.Say (name_.source ,
542
540
" An assumed-rank object may not appear in an ALLOCATE statement" _err_en_US);
543
541
return false ;
544
542
}
543
+ if (ultimate_ && IsAssumedSizeArray (*ultimate_) && context.AnyFatalError ()) {
544
+ // An assumed-size dummy array or RANK(*) case of SELECT RANK will have
545
+ // already been diagnosed; don't pile on.
546
+ return false ;
547
+ }
545
548
if (rank_ > 0 ) {
546
549
if (!hasAllocateShapeSpecList ()) {
547
550
// C939
@@ -568,7 +571,7 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
568
571
.Say (name_.source ,
569
572
" The number of shape specifications, when they appear, must match the rank of allocatable object" _err_en_US)
570
573
.Attach (
571
- original_ ->name (), " Declared here with rank %d" _en_US, rank_);
574
+ ultimate_ ->name (), " Declared here with rank %d" _en_US, rank_);
572
575
return false ;
573
576
}
574
577
}
@@ -587,7 +590,7 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
587
590
" If SOURCE appears, the related expression must be scalar or have the same rank as each allocatable object in ALLOCATE" _err_en_US)
588
591
.Attach (allocateInfo_.sourceExprLoc .value (),
589
592
" SOURCE expression has rank %d" _en_US, allocateInfo_.sourceExprRank )
590
- .Attach (symbol_ ->name (),
593
+ .Attach (ultimate_ ->name (),
591
594
" Allocatable object declared here with rank %d" _en_US, rank_);
592
595
return false ;
593
596
}
@@ -611,11 +614,11 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
611
614
612
615
bool AllocationCheckerHelper::RunCoarrayRelatedChecks (
613
616
SemanticsContext &context) const {
614
- if (!symbol_ ) {
617
+ if (!ultimate_ ) {
615
618
CHECK (context.AnyFatalError ());
616
619
return false ;
617
620
}
618
- if (evaluate::IsCoarray (*symbol_ )) {
621
+ if (evaluate::IsCoarray (*ultimate_ )) {
619
622
if (allocateInfo_.gotTypeSpec ) {
620
623
// C938
621
624
if (const DerivedTypeSpec *
@@ -665,8 +668,8 @@ bool AllocationCheckerHelper::RunCoarrayRelatedChecks(
665
668
context
666
669
.Say (name_.source ,
667
670
" Corank of coarray specification in ALLOCATE must match corank of alloctable coarray" _err_en_US)
668
- .Attach (
669
- symbol_-> name (), " Declared here with corank %d " _en_US, corank_);
671
+ .Attach (ultimate_-> name (), " Declared here with corank %d " _en_US,
672
+ corank_);
670
673
return false ;
671
674
}
672
675
}
0 commit comments