summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/entry_6.f90
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/entry_6.f90
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/entry_6.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/entry_6.f9056
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/entry_6.f90 b/gcc/testsuite/gfortran.dg/entry_6.f90
new file mode 100644
index 000000000..103392606
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/entry_6.f90
@@ -0,0 +1,56 @@
+! { dg-do run }
+! Tests the fix for PR24558, which reported that module
+! alternate function entries did not work.
+!
+! Contributed by Erik Edelmann <eedelman@gcc.gnu.org>
+!
+module foo
+contains
+ function n1 (a)
+ integer :: n1, n2, a, b
+ integer, save :: c
+ c = a
+ n1 = c**3
+ return
+ entry n2 (b)
+ n2 = c * b
+ n2 = n2**2
+ return
+ end function n1
+ function z1 (u)
+ complex :: z1, z2, u, v
+ z1 = (1.0, 2.0) * u
+ return
+ entry z2 (v)
+ z2 = (3, 4) * v
+ return
+ end function z1
+ function n3 (d)
+ integer :: n3, d
+ n3 = n2(d) * n1(d) ! Check sibling references.
+ return
+ end function n3
+ function c1 (a)
+ character(4) :: c1, c2, a, b
+ c1 = a
+ if (a .eq. "abcd") c1 = "ABCD"
+ return
+ entry c2 (b)
+ c2 = b
+ if (b .eq. "wxyz") c2 = "WXYZ"
+ return
+ end function c1
+end module foo
+ use foo
+ if (n1(9) .ne. 729) call abort ()
+ if (n2(2) .ne. 324) call abort ()
+ if (n3(19) .ne. 200564019) call abort ()
+ if (c1("lmno") .ne. "lmno") call abort ()
+ if (c1("abcd") .ne. "ABCD") call abort ()
+ if (c2("lmno") .ne. "lmno") call abort ()
+ if (c2("wxyz") .ne. "WXYZ") call abort ()
+ if (z1((3,4)) .ne. (-5, 10)) call abort ()
+ if (z2((5,6)) .ne. (-9, 38)) call abort ()
+ end
+
+! { dg-final { cleanup-modules "foo" } }