On Monday 18 July 2011 21:37:24 Tobias Burnus wrote: > As the coarray status is nontrivial to check, I have created a function > for that - and I use it now for the interface checking. There are more > cases, where the wrong check is used, leading to accepts-invalid and > rejects-valid issues; however, I would like to track them later.
Two minor suggestions: > diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c > index b8eb555..67ac2e5 100644 > --- a/gcc/fortran/expr.c > +++ b/gcc/fortran/expr.c > @@ -4154,6 +4154,74 @@ gfc_is_coindexed (gfc_expr *e) > } > > > +/* Coarrays are variables with a corank but not being coindexed. However, also > + the following is a coarray: A subobject of a coarray is a coarray if it does > + not have any cosubscripts, vector subscripts, allocatable component > + selection, or pointer component selection. (F2008, 2.4.7) */ > + > +bool > +gfc_is_coarray (gfc_expr *e) > +{ > + gfc_ref *ref; > + gfc_symbol *sym; > + gfc_component *comp; > + bool coindexed; > + bool coarray; > + int i; > + > + if (e->expr_type != EXPR_VARIABLE > + && e->expr_type != EXPR_FUNCTION) > + return false; This should not change anything, but I think EXPR_FUNCTION can be discarded because of C523: A coarray shall be a component or a variable that is not a function result. > diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c > index dcf6c4e..fa23de7 100644 > --- a/gcc/fortran/interface.c > +++ b/gcc/fortran/interface.c > @@ -1557,41 +1557,21 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual, [...] > + if (formal->attr.codimension && formal->attr.allocatable) > + { > + gfc_ref *last = NULL; > > for (ref = actual->ref; ref; ref = ref->next) > - { > - if (ref->type == REF_ARRAY && ref->u.ar.as->corank > - && ref->u.ar.type != AR_FULL && ref->u.ar.dimen != 0) > - { > - if (where) > - gfc_error ("Actual argument to '%s' at %L must be a coarray " > - "and thus shall not have an array designator", > - formal->name, &ref->u.ar.where); > - return 0; > - } > - if (ref->type == REF_COMPONENT) > - last = ref; > - } > + if (ref->type == REF_COMPONENT) > + last = ref; > > /* F2008, 12.5.2.6. */ > if (formal->attr.allocatable && This formal->attr.allocatable condition is now superfluous. Now about your request: > I would be happy if someone could carefully read the function in expr.c > - and confirm that the second test case ("dg-error" line) is indeed > invalid. I think it is invalid because one has an array element of a > coarray, which is a coarray but which is not simply contiguous. I don't understand what is your concern here; the standard seems pretty clear: 12.5.2.8 (f2008): If the dummy argument is an array coarray that has the CONTIGUOUS attribute or is not of assumed shape, the corresponding actual argument shall be simply contiguous. Thus, invalid indeed. > Thus, if possible cross check that it is indeed not simply contiguous. 6.5.4 (f2008): A section-subscript-list specifies a simply contiguous section if and only if it does not have a vector subscript and • all but the last subscript-triplet is a colon, • the last subscript-triplet does not have a stride, and • _no subscript-triplet is preceded by a section-subscript that is a_ _subscript._ It's not simply contiguous indeed. Wasn't it obvious anyway or did I miss something? So, to sum up, if one sticks to fortran 2008, the test is clearly invalid and... > Build and regtested on x86-64-linux. > OK for the trunk? ... the patch is ok with the two minor changes suggested above. Mikael