summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/dynamic_dispatch_7.f03
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/dynamic_dispatch_7.f03
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/dynamic_dispatch_7.f03')
-rw-r--r--gcc/testsuite/gfortran.dg/dynamic_dispatch_7.f0361
1 files changed, 61 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/dynamic_dispatch_7.f03 b/gcc/testsuite/gfortran.dg/dynamic_dispatch_7.f03
new file mode 100644
index 000000000..3cd051047
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dynamic_dispatch_7.f03
@@ -0,0 +1,61 @@
+! { dg-do run }
+! Test the fix for PR43291, which was a regression that caused
+! incorrect type mismatch errors at line 46. In the course of
+! fixing the PR, it was noted that the dynamic dispatch of the
+! final typebound call was not occurring - hence the dg-do run.
+!
+! Contributed by Janus Weil <janus@gcc.gnu.org>
+!
+module m1
+ type :: t1
+ contains
+ procedure :: sizeof
+ end type
+contains
+ integer function sizeof(a)
+ class(t1) :: a
+ sizeof = 1
+ end function sizeof
+end module
+
+module m2
+ use m1
+ type, extends(t1) :: t2
+ contains
+ procedure :: sizeof => sizeof2
+ end type
+contains
+ integer function sizeof2(a)
+ class(t2) :: a
+ sizeof2 = 2
+ end function
+end module
+
+module m3
+ use m2
+ type :: t3
+ class(t1), pointer :: a
+ contains
+ procedure :: sizeof => sizeof3
+ end type
+contains
+ integer function sizeof3(a)
+ class(t3) :: a
+ sizeof3 = a%a%sizeof()
+ end function
+end module
+
+ use m1
+ use m2
+ use m3
+ type(t1), target :: x
+ type(t2), target :: y
+ type(t3) :: z
+ z%a => x
+ if ((z%sizeof() .ne. 1) .or. (z%a%sizeof() .ne. 1)) call abort
+ z%a => y
+ if ((z%sizeof() .ne. 2) .or. (z%a%sizeof() .ne. 2)) call abort
+end
+
+! { dg-final { cleanup-modules "m1 m2 m3" } }
+