Commit 0ce0e6e8 by Janus Weil

re PR fortran/86116 (Ambiguous generic interface not recognised)

2018-08-14  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/86116
	* interface.c (compare_type): Remove a CLASS/TYPE check.
	(compare_type_characteristics): New function that behaves like the old
	'compare_type'.
	(gfc_check_dummy_characteristics, gfc_check_result_characteristics):
	Call 'compare_type_characteristics' instead of 'compare_type'.

2018-08-14  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/86116
	* gfortran.dg/generic_34.f90: New test case.

From-SVN: r263540
parent b8b5398c
2018-08-14 Janus Weil <janus@gcc.gnu.org>
PR fortran/86116
* interface.c (compare_type): Remove a CLASS/TYPE check.
(compare_type_characteristics): New function that behaves like the old
'compare_type'.
(gfc_check_dummy_characteristics, gfc_check_result_characteristics):
Call 'compare_type_characteristics' instead of 'compare_type'.
2018-08-12 Paul Thomas <pault@gcc.gnu.org> 2018-08-12 Paul Thomas <pault@gcc.gnu.org>
PR fortran/66679 PR fortran/66679
......
...@@ -735,13 +735,20 @@ compare_type (gfc_symbol *s1, gfc_symbol *s2) ...@@ -735,13 +735,20 @@ compare_type (gfc_symbol *s1, gfc_symbol *s2)
if (s2->attr.ext_attr & (1 << EXT_ATTR_NO_ARG_CHECK)) if (s2->attr.ext_attr & (1 << EXT_ATTR_NO_ARG_CHECK))
return true; return true;
return gfc_compare_types (&s1->ts, &s2->ts) || s2->ts.type == BT_ASSUMED;
}
static bool
compare_type_characteristics (gfc_symbol *s1, gfc_symbol *s2)
{
/* TYPE and CLASS of the same declared type are type compatible, /* TYPE and CLASS of the same declared type are type compatible,
but have different characteristics. */ but have different characteristics. */
if ((s1->ts.type == BT_CLASS && s2->ts.type == BT_DERIVED) if ((s1->ts.type == BT_CLASS && s2->ts.type == BT_DERIVED)
|| (s1->ts.type == BT_DERIVED && s2->ts.type == BT_CLASS)) || (s1->ts.type == BT_DERIVED && s2->ts.type == BT_CLASS))
return false; return false;
return gfc_compare_types (&s1->ts, &s2->ts) || s2->ts.type == BT_ASSUMED; return compare_type (s1, s2);
} }
...@@ -1309,7 +1316,8 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2, ...@@ -1309,7 +1316,8 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2,
/* Check type and rank. */ /* Check type and rank. */
if (type_must_agree) if (type_must_agree)
{ {
if (!compare_type (s1, s2) || !compare_type (s2, s1)) if (!compare_type_characteristics (s1, s2)
|| !compare_type_characteristics (s2, s1))
{ {
snprintf (errmsg, err_len, "Type mismatch in argument '%s' (%s/%s)", snprintf (errmsg, err_len, "Type mismatch in argument '%s' (%s/%s)",
s1->name, gfc_typename (&s1->ts), gfc_typename (&s2->ts)); s1->name, gfc_typename (&s1->ts), gfc_typename (&s2->ts));
...@@ -1528,7 +1536,7 @@ gfc_check_result_characteristics (gfc_symbol *s1, gfc_symbol *s2, ...@@ -1528,7 +1536,7 @@ gfc_check_result_characteristics (gfc_symbol *s1, gfc_symbol *s2,
return true; return true;
/* Check type and rank. */ /* Check type and rank. */
if (!compare_type (r1, r2)) if (!compare_type_characteristics (r1, r2))
{ {
snprintf (errmsg, err_len, "Type mismatch in function result (%s/%s)", snprintf (errmsg, err_len, "Type mismatch in function result (%s/%s)",
gfc_typename (&r1->ts), gfc_typename (&r2->ts)); gfc_typename (&r1->ts), gfc_typename (&r2->ts));
......
2018-08-14 Janus Weil <janus@gcc.gnu.org>
PR fortran/86116
* gfortran.dg/generic_34.f90: New test case.
2018-08-13 Marek Polacek <polacek@redhat.com> 2018-08-13 Marek Polacek <polacek@redhat.com>
PR c++/57891 PR c++/57891
......
! { dg-do compile }
!
! PR 86116: [6/7/8/9 Regression] Ambiguous generic interface not recognised
!
! Contributed by martin <mscfd@gmx.net>
module mod
type :: t
end type t
interface sub
module procedure s1
module procedure s2
end interface
contains
subroutine s1(x) ! { dg-error "Ambiguous interfaces in generic interface" }
type(t) :: x
end subroutine
subroutine s2(x) ! { dg-error "Ambiguous interfaces in generic interface" }
class(*), allocatable :: x
end subroutine
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment