]> gcc.gnu.org Git - gcc.git/commitdiff
re PR fortran/42144 ([OOP] deferred TBPs do not work)
authorJanus Weil <janus@gcc.gnu.org>
Thu, 17 Dec 2009 09:28:25 +0000 (10:28 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Thu, 17 Dec 2009 09:28:25 +0000 (10:28 +0100)
gcc/fortran/
2009-12-17 Janus Weil  <janus@gcc.gnu.org>

PR fortran/42144
* trans-expr.c (select_class_proc): Skip abstract base types.

gcc/testsuite/
2009-12-17  Janus Weil  <janus@gcc.gnu.org>

PR fortran/42144
* gfortran.dg/dynamic_dispatch_6.f03: New test.

From-SVN: r155305

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/dynamic_dispatch_6.f03 [new file with mode: 0644]

index 1d34ae8b96b55d8a02f220d9f9692430f4f2fa47..f65bcd0c718c5ce3de81e6603d252486542db18b 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-17 Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/42144
+       * trans-expr.c (select_class_proc): Skip abstract base types.
+
 2009-12-16  Kazu Hirata  <kazu@codesourcery.com>
 
        * gfc-internals.texi, gfortran.texi, invoke.texi: Fix typos.
index acca306a2ffc333cd3c3273c512c976020f1ca54..b0c19c9627cc675fa11b31a4508aa8e024514423 100644 (file)
@@ -1556,6 +1556,10 @@ select_class_proc (gfc_se *se, gfc_class_esym_list *elist,
       if (elist->derived == NULL)
        goto free_elist;
 
+      /* Skip abstract base types.  */
+      if (elist->derived->attr.abstract)
+       goto free_elist;
+
       /* Run through the chain picking up all the cases that call the
         same procedure.  */
       tmp_elist = elist;
index f162037a99d779b68488de55d43bd4da5d9a5d68..77bd4ee13341990f34fe8a31c28992cf1acbc289 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-17  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/42144
+       * gfortran.dg/dynamic_dispatch_6.f03: New test.
+
 2009-12-17  Shujing Zhao  <pearly.zhao@oracle.com>
 
        * g++.old-deja/g++.mike/net31.C: Make expected dg-error strings
diff --git a/gcc/testsuite/gfortran.dg/dynamic_dispatch_6.f03 b/gcc/testsuite/gfortran.dg/dynamic_dispatch_6.f03
new file mode 100644 (file)
index 0000000..e2d880e
--- /dev/null
@@ -0,0 +1,69 @@
+! { dg-do run }
+!
+! PR 42144: [OOP] deferred TBPs do not work
+!
+! Contributed by Damian Rouson <damian@rouson.net>
+
+module field_module
+  implicit none
+  private
+  public :: field
+  type ,abstract :: field 
+  end type
+end module
+
+module periodic_5th_order_module
+  use field_module ,only : field
+  implicit none
+  type ,extends(field) :: periodic_5th_order
+  end type
+end module
+
+module field_factory_module
+  implicit none
+  private
+  public :: field_factory
+  type, abstract :: field_factory 
+  contains 
+    procedure(create_interface), deferred :: create 
+  end type 
+  abstract interface 
+    function create_interface(this) 
+      use field_module ,only : field
+      import :: field_factory
+      class(field_factory), intent(in) :: this 
+      class(field) ,pointer :: create_interface
+    end function
+  end interface 
+end module
+
+module periodic_5th_factory_module
+  use field_factory_module , only : field_factory
+  implicit none
+  private
+  public :: periodic_5th_factory
+  type, extends(field_factory) :: periodic_5th_factory 
+  contains 
+    procedure :: create=>new_periodic_5th_order
+  end type 
+contains
+  function new_periodic_5th_order(this) 
+    use field_module ,only : field
+    use periodic_5th_order_module ,only : periodic_5th_order
+    class(periodic_5th_factory), intent(in) :: this
+    class(field) ,pointer :: new_periodic_5th_order
+  end function
+end module
+
+program main 
+  use field_module ,only : field 
+  use field_factory_module ,only : field_factory
+  use periodic_5th_factory_module ,only : periodic_5th_factory
+  implicit none 
+  class(field) ,pointer :: u
+  class(field_factory), allocatable :: field_creator 
+  allocate (periodic_5th_factory ::  field_creator) 
+  u => field_creator%create() 
+end program
+
+! { dg-final { cleanup-modules "field_module periodic_5th_order_module field_factory_module periodic_5th_factory_module" } }
This page took 0.108067 seconds and 5 git commands to generate.