The attached patch is utterly trivial. The only useful attribute
that FooPrivate possesses  to detect that it has been declared is
'subroutine'. This was missed in the attribute test in
resolve.cc(was_declared). Adding it fixes the problem and regtests on
FC42/x86_64.

OK for mainline and some judicious backporting in a while?

Paul

PS It came up automatically on bugzilla, while I was messing with
PR1211482. This latter also fixed pr82753.

Attachment: Change.Logs
Description: Binary data

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 68aaee84687..6b01b8f7c20 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -1630,7 +1630,7 @@ was_declared (gfc_symbol *sym)
   if (a.allocatable || a.dimension || a.dummy || a.external || a.intrinsic
       || a.optional || a.pointer || a.save || a.target || a.volatile_
       || a.value || a.access != ACCESS_UNKNOWN || a.intent != INTENT_UNKNOWN
-      || a.asynchronous || a.codimension)
+      || a.asynchronous || a.codimension || a.subroutine)
     return 1;
 
   return 0;
diff --git a/gcc/testsuite/gfortran.dg/pr89092.f90 b/gcc/testsuite/gfortran.dg/pr89092.f90
new file mode 100644
index 00000000000..21649940657
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr89092.f90
@@ -0,0 +1,49 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+module AModule
+   implicit none
+   private
+   public Foo
+
+   interface Foo
+      module procedure FooPrivate
+   end interface
+contains
+   subroutine FooPrivate(x)
+      integer :: x
+
+      write(*,*) 'Foo(integer)'
+   end subroutine
+end module
+module BModule
+   implicit none
+   private
+
+   type, public :: BType
+   contains
+      procedure :: Foo
+   end type
+contains
+   subroutine Foo(self)
+      class(BType) :: self
+
+      write(*,*) 'Foo(BType)'
+   end subroutine
+end module
+program iface_tbp_test
+   use AModule
+   implicit none
+
+   call test()
+
+contains
+   subroutine test()
+      use BModule
+
+      type(BType) :: y
+
+      call y%Foo()
+      call Foo(1)
+   end subroutine
+end program
+! { dg-final { scan-tree-dump-times "foo \\(&class.2\\)" 1 "original" } }

Reply via email to