re PR fortran/55297 ([OOP] type-bound operator clashes with abstract interface)
authorJanus Weil <janus@gcc.gnu.org>
Fri, 16 Nov 2012 17:02:02 +0000 (18:02 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Fri, 16 Nov 2012 17:02:02 +0000 (18:02 +0100)
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-16  Janus Weil  <janus@gcc.gnu.org>

PR fortran/55297
* gfortran.dg/typebound_operator_18.f90: New.

From-SVN: r193568

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/typebound_operator_18.f90 [new file with mode: 0644]

index 74ea42aefec212337425aab40f61a02874d8a0bc..439eae5719a90c4a9e3584774b300ddff2c070dd 100644 (file)
@@ -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.
index e39a137fd4f5d778dfbdcfe48731b65c05927717..53d695cd4566a1b104503e9c1966180506598e98 100644 (file)
@@ -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,
index d93adcc3497775a8ad206a34a6c87048ca5675ce..7606bace75d279287691b112fd375d8d28aad9c7 100644 (file)
@@ -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 (file)
index 0000000..d5ac9e9
--- /dev/null
@@ -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" } }