diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2016-10-07 18:18:03 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2016-10-07 18:18:03 +0000 |
commit | bd845c14b7aa666b5f7d453fa928551506df0ffa (patch) | |
tree | 89b197f22a5f631bf1248ad5e44a5a7f0aed7d66 /gcc/fortran/interface.c | |
parent | 296002c6a1354f1520f32b9cd1b4c61c6ab186ef (diff) | |
download | gcc-bd845c14b7aa666b5f7d453fa928551506df0ffa.zip gcc-bd845c14b7aa666b5f7d453fa928551506df0ffa.tar.gz gcc-bd845c14b7aa666b5f7d453fa928551506df0ffa.tar.bz2 |
re PR fortran/77406 (ICE in generic_correspondence, at fortran/interface.c:1123)
2016-10-07 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77406
* interface.c (gfc_compare_interfaces): Fix detection of ambiguous
interface involving alternate return.
(check_interface1): Improve error message and loci.
2016-10-07 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77406
* gfortran.dg/pr77406.f90: New test.
* gfortran.dg/assumed_type_3.f90: Update error messages.
* gfortran.dg/defined_operators_1.f90: Ditto.
* gfortran.dg/generic_26.f90: Ditto.
* gfortran.dg/generic_7.f90: Ditto.
* gfortran.dg/gomp/udr5.f90: Ditto.
* gfortran.dg/gomp/udr7.f90: Ditto.
* gfortran.dg/interface_1.f90: Ditto.
* gfortran.dg/interface_37.f90: Ditto.
* gfortran.dg/interface_5.f90: Ditto.
* gfortran.dg/interface_6.f90: Ditto.
* gfortran.dg/interface_7.f90
* gfortran.dg/no_arg_check_3.f90
* gfortran.dg/operator_5.f90
* gfortran.dg/proc_ptr_comp_20.f90: Ditto.
From-SVN: r240870
Diffstat (limited to 'gcc/fortran/interface.c')
-rw-r--r-- | gcc/fortran/interface.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index e7f1878..2a9af0f 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1689,14 +1689,23 @@ gfc_compare_interfaces (gfc_symbol *s1, gfc_symbol *s2, const char *name2, f1 = gfc_sym_get_dummy_args (s1); f2 = gfc_sym_get_dummy_args (s2); + /* Special case: No arguments. */ if (f1 == NULL && f2 == NULL) - return 1; /* Special case: No arguments. */ + return 1; if (generic_flag) { if (count_types_test (f1, f2, p1, p2) || count_types_test (f2, f1, p2, p1)) return 0; + + /* Special case: alternate returns. If both f1->sym and f2->sym are + NULL, then the leading formal arguments are alternate returns. + The previous conditional should catch argument lists with + different number of argument. */ + if (f1 && f1->sym == NULL && f2 && f2->sym == NULL) + return 1; + if (generic_correspondence (f1, f2, p1, p2) || generic_correspondence (f2, f1, p2, p1)) return 0; @@ -1864,13 +1873,15 @@ check_interface1 (gfc_interface *p, gfc_interface *q0, generic_flag, 0, NULL, 0, NULL, NULL)) { if (referenced) - gfc_error ("Ambiguous interfaces %qs and %qs in %s at %L", - p->sym->name, q->sym->name, interface_name, - &p->where); + gfc_error ("Ambiguous interfaces in %s for %qs at %L " + "and %qs at %L", interface_name, + q->sym->name, &q->sym->declared_at, + p->sym->name, &p->sym->declared_at); else if (!p->sym->attr.use_assoc && q->sym->attr.use_assoc) - gfc_warning (0, "Ambiguous interfaces %qs and %qs in %s at %L", - p->sym->name, q->sym->name, interface_name, - &p->where); + gfc_warning (0, "Ambiguous interfaces in %s for %qs at %L " + "and %qs at %L", interface_name, + q->sym->name, &q->sym->declared_at, + p->sym->name, &p->sym->declared_at); else gfc_warning (0, "Although not referenced, %qs has ambiguous " "interfaces at %L", interface_name, &p->where); |