From: Janus Weil Date: Sat, 4 Aug 2018 15:37:23 +0000 (+0200) Subject: re PR fortran/45521 ([F08] GENERIC resolution with ALLOCATABLE/POINTER and PROCEDURE) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d50cd259bec418ea0f4e3903f578301982e2d183;p=gcc.git re PR fortran/45521 ([F08] GENERIC resolution with ALLOCATABLE/POINTER and PROCEDURE) 2018-08-04 Janus Weil PR fortran/45521 * interface.c (gfc_compare_interfaces): Apply additional distinguishability criteria of F08 to operator interfaces. 2018-08-04 Janus Weil PR fortran/45521 * gfortran.dg/interface_assignment_6.f90: New test case. From-SVN: r263308 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9454102afdb..ced9c9146f2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-08-04 Janus Weil + + PR fortran/45521 + * interface.c (gfc_compare_interfaces): Apply additional + distinguishability criteria of F08 to operator interfaces. + 2018-07-31 Andre Vieira Revert 'AsyncI/O patch committed' diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 9da654e65d5..32aae0eda55 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1776,7 +1776,7 @@ gfc_compare_interfaces (gfc_symbol *s1, gfc_symbol *s2, const char *name2, } else { - /* Only check type and rank. */ + /* Operators: Only check type and rank of arguments. */ if (!compare_type (f2->sym, f1->sym)) { if (errmsg != NULL) @@ -1794,6 +1794,15 @@ gfc_compare_interfaces (gfc_symbol *s1, gfc_symbol *s2, const char *name2, symbol_rank (f2->sym)); return false; } + if ((gfc_option.allow_std & GFC_STD_F2008) + && (compare_ptr_alloc(f1->sym, f2->sym) + || compare_ptr_alloc(f2->sym, f1->sym))) + { + if (errmsg != NULL) + snprintf (errmsg, err_len, "Mismatching POINTER/ALLOCATABLE " + "attribute in argument '%s' ", f1->sym->name); + return false; + } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 551400cb0d4..278ea3d98bf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ + +2018-08-04 Janus Weil + + PR fortran/45521 + * gfortran.dg/interface_assignment_6.f90: New test case. + 2018-08-04 Uros Bizjak PR testsuite/86153 diff --git a/gcc/testsuite/gfortran.dg/interface_assignment_6.f90 b/gcc/testsuite/gfortran.dg/interface_assignment_6.f90 new file mode 100644 index 00000000000..81171b47f39 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_assignment_6.f90 @@ -0,0 +1,30 @@ +! { dg-do compile } +! +! PR 45521: [F08] GENERIC resolution with ALLOCATABLE/POINTER and PROCEDURE +! +! Contributed by Janus Weil + +module inteface_assignment_6 + + type :: t + end type + + ! this was rejected as ambiguous, but is valid in F08 + interface assignment(=) + procedure testAlloc + procedure testPtr + end interface + +contains + + subroutine testAlloc(obj, val) + type(t), allocatable, intent(out) :: obj + integer, intent(in) :: val + end subroutine + + subroutine testPtr(obj, val) + type(t), pointer, intent(out) :: obj + integer, intent(in) :: val + end subroutine + +end