>> OK from my side (given Mikael's comments), provided you spell resolve.c with >> two e :-) > > Thanks, guys. Committed as r177545 (including your comments).
Ok, with the 'trivial' parts out of the way, the remainder of my previously proposed patch becomes rather compact (see attachment). Thomas' ongoing criticism is that rejecting all nonzero return values of 'gfc_dep_compare_expr' will reject too much (i.e. cases where we can not prove that the expressions are equal, but they may still be). My feeling is that only throwing a warning for a result of '-2' is too weak, because the majority of cases will have that result (just think 'len=3' vs. 'len=n'). Instead I could offer to try to extend the return values of 'gfc_dep_compare_expr' to distinguish between the following cases (which right now would both result in '-2'): a) We can not determine the relationship between both expressions, but we know they are different for certain input values. (This case would include e.g. different expr_type) b) We cannot make any statement. Is this the way to go? Or are there any other proposals for resolving this argument? Cheers, Janus
Index: gcc/fortran/interface.c =================================================================== --- gcc/fortran/interface.c (revision 177545) +++ gcc/fortran/interface.c (working copy) @@ -3556,15 +3556,25 @@ gfc_check_typebound_override (gfc_symtree* proc, g } /* FIXME: Do more comprehensive checking (including, for instance, the - rank and array-shape). */ + array-shape). */ gcc_assert (proc_target->result && old_target->result); - if (!gfc_compare_types (&proc_target->result->ts, - &old_target->result->ts)) + if (!compare_type_rank (proc_target->result, old_target->result)) { gfc_error ("'%s' at %L and the overridden FUNCTION should have" - " matching result types", proc->name, &where); + " matching result types and ranks", proc->name, &where); return FAILURE; } + + /* Check string length. */ + if (proc_target->result->ts.type == BT_CHARACTER + && proc_target->result->ts.u.cl && old_target->result->ts.u.cl + && gfc_dep_compare_expr (proc_target->result->ts.u.cl->length, + old_target->result->ts.u.cl->length) != 0) + { + gfc_error ("Character length mismatch between '%s' at '%L' " + "and overridden FUNCTION", proc->name, &where); + return FAILURE; + } } /* If the overridden binding is PUBLIC, the overriding one must not be Index: gcc/fortran/dependency.c =================================================================== --- gcc/fortran/dependency.c (revision 177545) +++ gcc/fortran/dependency.c (working copy) @@ -123,8 +123,18 @@ are_identical_variables (gfc_expr *e1, gfc_expr *e { gfc_ref *r1, *r2; - if (e1->symtree->n.sym != e2->symtree->n.sym) - return false; + if (e1->symtree->n.sym->attr.dummy && e2->symtree->n.sym->attr.dummy) + { + /* Dummy arguments: Only check for equal names. */ + if (e1->symtree->n.sym->name != e2->symtree->n.sym->name) + return false; + } + else + { + /* Check for equal symbols. */ + if (e1->symtree->n.sym != e2->symtree->n.sym) + return false; + } /* Volatile variables should never compare equal to themselves. */