This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] PR fortran/37588: GENERIC resolution broken for array arguments


Hi,

this fixes PR fortran/37588 by adding a missing call to resolve the actual arglist before comparing it against the formal ones of the specific procedures in finding a matching one for generic type-bound procedures.

Because this was missing, all expressions did have their expr->rank set to 0 before and this caused the problem in the PR that GENERIC type-bound procedures with array arguments would never be resolved to the correct specific ones.

Currently regression testing on GNU/Linux-x86-32. Ok to commit (for trunk only, of course) if no regressions?

Daniel

--
Done:     Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go:    Hea-Kni-Mon-Pri-Ran-Rog-Tou
2008-09-22  Daniel Kraft  <d@domob.eu>

	PR fortran/37588
	* resolve.c (resolve_typebound_generic_call): Resolve actual arglist
	before checking against formal.

2008-09-22  Daniel Kraft  <d@domob.eu>

	PR fortran/37588
	* gfortran.dg/typebound_generic_4.f03: New test.
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 140527)
+++ gcc/fortran/resolve.c	(working copy)
@@ -4501,6 +4501,8 @@ resolve_typebound_generic_call (gfc_expr
 
 	      args = update_arglist_pass (args, po, g->specific->pass_arg_num);
 	    }
+	  resolve_actual_arglist (args, target->attr.proc,
+				  is_external_proc (target) && !target->formal);
 
 	  /* Check if this arglist matches the formal.  */
 	  matches = gfc_compare_actual_formal (&args, target->formal, 1,
Index: gcc/testsuite/gfortran.dg/typebound_generic_4.f03
===================================================================
--- gcc/testsuite/gfortran.dg/typebound_generic_4.f03	(revision 0)
+++ gcc/testsuite/gfortran.dg/typebound_generic_4.f03	(revision 0)
@@ -0,0 +1,57 @@
+! { dg-do run }
+
+! FIXME: Remove -w once the TYPE/CLASS issue is resolved
+! { dg-options "-w" }
+
+! PR fortran/37588
+! This test used to not resolve the GENERIC binding.
+
+! Contributed by Salvatore Filippone <sfilippone@uniroma2.it>
+
+module bar_mod
+
+  type foo
+    integer :: i
+    
+  contains
+    procedure, pass(a) :: foo_v => foo_v_inner    
+    procedure, pass(a) :: foo_m => foo_m_inner    
+    generic, public    :: foo => foo_v, foo_m
+  end type foo
+  
+  private foo_v_inner, foo_m_inner
+
+contains
+  
+  subroutine foo_v_inner(x,a)
+    real :: x(:)
+    type(foo) :: a
+    
+    a%i = int(x(1))
+    WRITE (*,*) "Vector"
+  end subroutine foo_v_inner
+  
+  subroutine foo_m_inner(x,a)
+    real :: x(:,:)
+    type(foo) :: a
+    
+    a%i = int(x(1,1))
+    WRITE (*,*) "Matrix"
+  end subroutine foo_m_inner
+end module bar_mod
+
+program foobar
+  use bar_mod
+  type(foo) :: dat
+  real :: x1(10), x2(10,10)
+
+  x1=1
+  x2=2
+ 
+  call dat%foo(x1)
+  call dat%foo(x2)
+
+end program foobar
+
+! { dg-output "Vector.*Matrix" }
+! { dg-final { cleanup-modules "bar_mod" } }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]