aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorDaniel Kraft <d@domob.eu>2008-09-23 16:26:47 +0200
committerDaniel Kraft <domob@gcc.gnu.org>2008-09-23 16:26:47 +0200
commitf0ac18b79931a074b5bc88e0b64ea8ef84e40941 (patch)
treec7feacbab392296b48eedf075c4af711194f8b63 /gcc/testsuite
parentf0580031a7919f8e1401db1c2e6515e1682eaaa7 (diff)
downloadgcc-f0ac18b79931a074b5bc88e0b64ea8ef84e40941.zip
gcc-f0ac18b79931a074b5bc88e0b64ea8ef84e40941.tar.gz
gcc-f0ac18b79931a074b5bc88e0b64ea8ef84e40941.tar.bz2
re PR fortran/37588 (GENERIC type-bound procedure is not resolved)
2008-09-23 Daniel Kraft <d@domob.eu> PR fortran/37588 * gfortran.h (gfc_compare_actual_formal): Removed, made private. (gfc_arglist_matches_symbol): New method. * interface.c (compare_actual_formal): Made static. (gfc_procedure_use): Use new name of compare_actual_formal. (gfc_arglist_matches_symbol): New method. (gfc_search_interface): Moved code partially to new gfc_arglist_matches_symbol. * resolve.c (resolve_typebound_generic_call): Resolve actual arglist before checking against formal and use new gfc_arglist_matches_symbol for checking. (resolve_compcall): Set type-spec of generated expression. 2008-09-23 Daniel Kraft <d@domob.eu> PR fortran/37588 * gfortran.dg/typebound_generic_4.f03: New test. * gfortran.dg/typebound_generic_5.f03: New test. From-SVN: r140594
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/typebound_generic_4.f0357
-rw-r--r--gcc/testsuite/gfortran.dg/typebound_generic_5.f0355
3 files changed, 118 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 715ffef..e3215bd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-23 Daniel Kraft <d@domob.eu>
+
+ PR fortran/37588
+ * gfortran.dg/typebound_generic_4.f03: New test.
+ * gfortran.dg/typebound_generic_5.f03: New test.
+
2008-09-23 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/pragma-init-fini.c: Use dg-warning in lieu of dg-error.
diff --git a/gcc/testsuite/gfortran.dg/typebound_generic_4.f03 b/gcc/testsuite/gfortran.dg/typebound_generic_4.f03
new file mode 100644
index 0000000..edd62be
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/typebound_generic_4.f03
@@ -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" } }
diff --git a/gcc/testsuite/gfortran.dg/typebound_generic_5.f03 b/gcc/testsuite/gfortran.dg/typebound_generic_5.f03
new file mode 100644
index 0000000..3fd94b1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/typebound_generic_5.f03
@@ -0,0 +1,55 @@
+! { dg-do run }
+
+! Check that generic bindings targetting ELEMENTAL procedures work.
+
+MODULE m
+ IMPLICIT NONE
+
+ TYPE :: t
+ CONTAINS
+ PROCEDURE, NOPASS :: double
+ PROCEDURE, NOPASS :: double_here
+ GENERIC :: double_it => double
+ GENERIC :: double_inplace => double_here
+ END TYPE t
+
+CONTAINS
+
+ ELEMENTAL INTEGER FUNCTION double (val)
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: val
+ double = 2 * val
+ END FUNCTION double
+
+ ELEMENTAL SUBROUTINE double_here (val)
+ IMPLICIT NONE
+ INTEGER, INTENT(INOUT) :: val
+ val = 2 * val
+ END SUBROUTINE double_here
+
+END MODULE m
+
+PROGRAM main
+ USE m
+ IMPLICIT NONE
+
+ TYPE(t) :: obj
+ INTEGER :: arr(42), arr2(42), arr3(42), arr4(42)
+ INTEGER :: i
+
+ arr = (/ (i, i = 1, 42) /)
+
+ arr2 = obj%double (arr)
+ arr3 = obj%double_it (arr)
+
+ arr4 = arr
+ CALL obj%double_inplace (arr4)
+
+ IF (ANY (arr2 /= 2 * arr) .OR. &
+ ANY (arr3 /= 2 * arr) .OR. &
+ ANY (arr4 /= 2 * arr)) THEN
+ CALL abort ()
+ END IF
+END PROGRAM main
+
+! { dg-final { cleanup-modules "m" } }