File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -477,8 +477,11 @@ int BaseObject::Corank() const {
477
477
int Component::Corank () const {
478
478
if (int corank{symbol_->Corank ()}; corank > 0 ) {
479
479
return corank;
480
+ } else if (semantics::IsAllocatableOrObjectPointer (&*symbol_)) {
481
+ return 0 ; // coarray subobjects ca%a or ca%p are not coarrays
482
+ } else {
483
+ return base ().Corank ();
480
484
}
481
- return base ().Corank ();
482
485
}
483
486
484
487
int NamedEntity::Corank () const {
@@ -489,7 +492,14 @@ int NamedEntity::Corank() const {
489
492
u_);
490
493
}
491
494
492
- int ArrayRef::Corank () const { return base ().Corank (); }
495
+ int ArrayRef::Corank () const {
496
+ for (const Subscript &subs : subscript_) {
497
+ if (!std::holds_alternative<Triplet>(subs.u ) && subs.Rank () > 0 ) {
498
+ return 0 ; // vector-valued subscript - subobject is not a coarray
499
+ }
500
+ }
501
+ return base ().Corank ();
502
+ }
493
503
494
504
int DataRef::Corank () const {
495
505
return common::visit (common::visitors{
Original file line number Diff line number Diff line change @@ -48,3 +48,25 @@ function func2()
48
48
! ERROR: Local variable 'local' without the SAVE or ALLOCATABLE attribute may not have a coarray potential subobject component '%comp'
49
49
type (t) :: local
50
50
end
51
+
52
+ module m3
53
+ type t
54
+ real , allocatable :: a(:)
55
+ real , pointer :: p(:)
56
+ real arr(2 )
57
+ end type
58
+ contains
59
+ subroutine sub (ca )
60
+ real , intent (in ) :: ca(:)[* ]
61
+ end
62
+ subroutine test (cat )
63
+ type (t), intent (in ) :: cat[* ]
64
+ call sub(cat% arr(1 :2 )) ! ok
65
+ ! ERROR: Actual argument associated with coarray dummy argument 'ca=' must be a coarray
66
+ call sub(cat% arr([1 ]))
67
+ ! ERROR: Actual argument associated with coarray dummy argument 'ca=' must be a coarray
68
+ call sub(cat% a)
69
+ ! ERROR: Actual argument associated with coarray dummy argument 'ca=' must be a coarray
70
+ call sub(cat% p)
71
+ end
72
+ end
You can’t perform that action at this time.
0 commit comments