diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 74ea42aefec212337425aab40f61a02874d8a0bc..439eae5719a90c4a9e3584774b300ddff2c070dd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-11-16 Janus Weil <janus@gcc.gnu.org> + + PR fortran/55297 + * resolve.c (resolve_typebound_intrinsic_op): Only add typebound + operators to the operator list in the namespace of the derived type. + 2012-11-12 Jan Hubicka <jh@suse.cz> * f95-lang.c (ATTR_NOTHROW_LEAF_MALLOC_LIST): New macro. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index e39a137fd4f5d778dfbdcfe48731b65c05927717..53d695cd4566a1b104503e9c1966180506598e98 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11540,7 +11540,7 @@ resolve_typebound_intrinsic_op (gfc_symbol* derived, gfc_intrinsic_op op, /* Add target to non-typebound operator list. */ if (!target->specific->deferred && !derived->attr.use_assoc - && p->access != ACCESS_PRIVATE) + && p->access != ACCESS_PRIVATE && derived->ns == gfc_current_ns) { gfc_interface *head, *intr; if (gfc_check_new_interface (derived->ns->op[op], target_proc, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d93adcc3497775a8ad206a34a6c87048ca5675ce..7606bace75d279287691b112fd375d8d28aad9c7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-11-16 Janus Weil <janus@gcc.gnu.org> + + PR fortran/55297 + * gfortran.dg/typebound_operator_18.f90: New. + 2012-11-16 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/55330 diff --git a/gcc/testsuite/gfortran.dg/typebound_operator_18.f90 b/gcc/testsuite/gfortran.dg/typebound_operator_18.f90 new file mode 100644 index 0000000000000000000000000000000000000000..d5ac9e97533ad4f523ee0f8dce82c0b0930732e3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_operator_18.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! +! PR 55297: [4.8 Regression] [OOP] type-bound operator clashes with abstract interface +! +! Contributed by Damian Rouson <damian@rouson.net> + +module athlete_module + type athlete + contains + procedure :: negative + generic :: operator(-) => negative + end type + abstract interface + integer function sum_interface(this) + import athlete + class(athlete) this + end function + end interface +contains + integer function negative(this) + class(athlete) ,intent(in) :: this + end function +end module + +! { dg-final { cleanup-modules "athlete_module" } }