summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/import4.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/import4.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/import4.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/import4.f9099
1 files changed, 99 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/import4.f90 b/gcc/testsuite/gfortran.dg/import4.f90
new file mode 100644
index 000000000..761c9846b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/import4.f90
@@ -0,0 +1,99 @@
+! { dg-do run }
+! Test for import in modules
+! PR fortran/29601
+
+subroutine bar(r)
+ implicit none
+ integer(8) :: r
+ if(r /= 42) call abort()
+ r = 13
+end subroutine bar
+
+subroutine foo(a)
+ implicit none
+ type myT
+ sequence
+ character(len=3) :: c
+ end type myT
+ type(myT) :: a
+ if(a%c /= "xyz") call abort()
+ a%c = "abc"
+end subroutine
+
+subroutine new(a,b)
+ implicit none
+ type gType
+ sequence
+ integer(8) :: c
+ end type gType
+ real(8) :: a
+ type(gType) :: b
+ if(a /= 99.0 .or. b%c /= 11) call abort()
+ a = -123.0
+ b%c = -44
+end subroutine new
+
+module general
+ implicit none
+ integer,parameter :: ikind = 8
+ type gType
+ sequence
+ integer(ikind) :: c
+ end type gType
+end module general
+
+module modtest
+ use general
+ implicit none
+ type myT
+ sequence
+ character(len=3) :: c
+ end type myT
+ integer, parameter :: dp = 8
+ interface
+ subroutine bar(x)
+ import :: dp
+ integer(dp) :: x
+ end subroutine bar
+ subroutine foo(c)
+ import :: myT
+ type(myT) :: c
+ end subroutine foo
+ subroutine new(x,y)
+ import :: ikind,gType
+ real(ikind) :: x
+ type(gType) :: y
+ end subroutine new
+ end interface
+ contains
+ subroutine test
+ integer(dp) :: y
+ y = 42
+ call bar(y)
+ if(y /= 13) call abort()
+ end subroutine test
+ subroutine test2()
+ type(myT) :: z
+ z%c = "xyz"
+ call foo(z)
+ if(z%c /= "abc") call abort()
+ end subroutine test2
+end module modtest
+
+program all
+ use modtest
+ implicit none
+ call test()
+ call test2()
+ call test3()
+contains
+ subroutine test3()
+ real(ikind) :: r
+ type(gType) :: t
+ r = 99.0
+ t%c = 11
+ call new(r,t)
+ if(r /= -123.0 .or. t%c /= -44) call abort()
+ end subroutine test3
+end program all
+! { dg-final { cleanup-modules "modtest general" } }