diff options
Diffstat (limited to 'gcc/fortran/interface.c')
-rw-r--r-- | gcc/fortran/interface.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 6ae36c2fb6a..cf83557be55 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -872,7 +872,8 @@ count_types_test (gfc_formal_arglist *f1, gfc_formal_arglist *f2) /* Find other nonoptional arguments of the same type/rank. */ for (j = i + 1; j < n1; j++) if ((arg[j].sym == NULL || !arg[j].sym->attr.optional) - && compare_type_rank_if (arg[i].sym, arg[j].sym)) + && (compare_type_rank_if (arg[i].sym, arg[j].sym) + || compare_type_rank_if (arg[j].sym, arg[i].sym))) arg[j].flag = k; k++; @@ -897,7 +898,8 @@ count_types_test (gfc_formal_arglist *f1, gfc_formal_arglist *f2) ac2 = 0; for (f = f2; f; f = f->next) - if (compare_type_rank_if (arg[i].sym, f->sym)) + if (compare_type_rank_if (arg[i].sym, f->sym) + || compare_type_rank_if (f->sym, arg[i].sym)) ac2++; if (ac1 > ac2) @@ -948,7 +950,8 @@ generic_correspondence (gfc_formal_arglist *f1, gfc_formal_arglist *f2) if (f1->sym->attr.optional) goto next; - if (f2 != NULL && compare_type_rank (f1->sym, f2->sym)) + if (f2 != NULL && (compare_type_rank (f1->sym, f2->sym) + || compare_type_rank (f2->sym, f1->sym))) goto next; /* Now search for a disambiguating keyword argument starting at @@ -1375,7 +1378,8 @@ compare_allocatable (gfc_symbol *formal, gfc_expr *actual) { symbol_attribute attr; - if (formal->attr.allocatable) + if (formal->attr.allocatable + || (formal->ts.type == BT_CLASS && CLASS_DATA (formal)->attr.allocatable)) { attr = gfc_expr_attr (actual); if (!attr.allocatable) @@ -1519,6 +1523,28 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual, gfc_typename (&formal->ts)); return 0; } + + /* F2003, 12.5.2.5. */ + if (formal->ts.type == BT_CLASS + && (CLASS_DATA (formal)->attr.class_pointer + || CLASS_DATA (formal)->attr.allocatable)) + { + if (actual->ts.type != BT_CLASS) + { + if (where) + gfc_error ("Actual argument to '%s' at %L must be polymorphic", + formal->name, &actual->where); + return 0; + } + if (CLASS_DATA (actual)->ts.u.derived + != CLASS_DATA (formal)->ts.u.derived) + { + if (where) + gfc_error ("Actual argument to '%s' at %L must have the same " + "declared type", formal->name, &actual->where); + return 0; + } + } if (formal->attr.codimension) { |