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 {
477477int Component::Corank () const {
478478 if (int corank{symbol_->Corank ()}; corank > 0 ) {
479479 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 ();
480484 }
481- return base ().Corank ();
482485}
483486
484487int NamedEntity::Corank () const {
@@ -489,7 +492,14 @@ int NamedEntity::Corank() const {
489492 u_);
490493}
491494
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+ }
493503
494504int DataRef::Corank () const {
495505 return common::visit (common::visitors{
Original file line number Diff line number Diff line change @@ -48,3 +48,25 @@ function func2()
4848 ! ERROR: Local variable 'local' without the SAVE or ALLOCATABLE attribute may not have a coarray potential subobject component '%comp'
4949 type (t) :: local
5050end
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