summaryrefslogtreecommitdiffstats
path: root/test cases/fortran/12 submodule
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/fortran/12 submodule')
-rw-r--r--test cases/fortran/12 submodule/a1.f9026
-rw-r--r--test cases/fortran/12 submodule/a2.f9010
-rw-r--r--test cases/fortran/12 submodule/a3.f9013
-rw-r--r--test cases/fortran/12 submodule/child.f9013
-rw-r--r--test cases/fortran/12 submodule/meson.build13
-rw-r--r--test cases/fortran/12 submodule/parent.f9026
6 files changed, 101 insertions, 0 deletions
diff --git a/test cases/fortran/12 submodule/a1.f90 b/test cases/fortran/12 submodule/a1.f90
new file mode 100644
index 0000000..c4b4555
--- /dev/null
+++ b/test cases/fortran/12 submodule/a1.f90
@@ -0,0 +1,26 @@
+module a1
+implicit none
+
+interface
+module elemental real function pi2tau(pi)
+ real, intent(in) :: pi
+end function pi2tau
+
+module real function get_pi()
+end function get_pi
+end interface
+
+end module a1
+
+program hierN
+
+use a1
+real :: tau, pi
+
+pi = get_pi()
+
+tau = pi2tau(pi)
+
+print *,'pi=',pi,'tau=',tau
+
+end program
diff --git a/test cases/fortran/12 submodule/a2.f90 b/test cases/fortran/12 submodule/a2.f90
new file mode 100644
index 0000000..ba8a0dd
--- /dev/null
+++ b/test cases/fortran/12 submodule/a2.f90
@@ -0,0 +1,10 @@
+! testing no space between submodule()
+submodule(a1) a2
+
+contains
+
+module procedure pi2tau
+ pi2tau = 2*pi
+end procedure pi2tau
+
+end submodule a2
diff --git a/test cases/fortran/12 submodule/a3.f90 b/test cases/fortran/12 submodule/a3.f90
new file mode 100644
index 0000000..3881675
--- /dev/null
+++ b/test cases/fortran/12 submodule/a3.f90
@@ -0,0 +1,13 @@
+! submodule (bogus) foo
+! testing don't detect commented submodule
+
+submodule (a1:a2) a3 ! testing inline comment
+
+contains
+
+module procedure get_pi
+ get_pi = 4.*atan(1.)
+end procedure get_pi
+
+
+end submodule a3
diff --git a/test cases/fortran/12 submodule/child.f90 b/test cases/fortran/12 submodule/child.f90
new file mode 100644
index 0000000..baf1fef
--- /dev/null
+++ b/test cases/fortran/12 submodule/child.f90
@@ -0,0 +1,13 @@
+submodule (parent) child
+
+contains
+
+module procedure pi2tau
+ pi2tau = 2*pi
+end procedure pi2tau
+
+module procedure good
+print *, 'Good!'
+end procedure good
+
+end submodule child
diff --git a/test cases/fortran/12 submodule/meson.build b/test cases/fortran/12 submodule/meson.build
new file mode 100644
index 0000000..204a36b
--- /dev/null
+++ b/test cases/fortran/12 submodule/meson.build
@@ -0,0 +1,13 @@
+project('submodule single level', 'fortran',
+ meson_version: '>= 0.50.0')
+
+fortc = meson.get_compiler('fortran')
+if fortc.get_id() == 'gcc' and fortc.version().version_compare('<6.0')
+ error('MESON_SKIP_TEST need gfortran >= 6.0 for submodule support')
+endif
+
+hier2 = executable('single', 'parent.f90', 'child.f90')
+test('single-level hierarchy', hier2)
+
+hierN = executable('multi', 'a1.f90', 'a2.f90', 'a3.f90')
+test('multi-level hierarchy', hierN)
diff --git a/test cases/fortran/12 submodule/parent.f90 b/test cases/fortran/12 submodule/parent.f90
new file mode 100644
index 0000000..efc7cf6
--- /dev/null
+++ b/test cases/fortran/12 submodule/parent.f90
@@ -0,0 +1,26 @@
+module parent
+real, parameter :: pi = 4.*atan(1.)
+real :: tau
+
+interface
+module elemental real function pi2tau(pi)
+ real, intent(in) :: pi
+end function pi2tau
+
+module subroutine good()
+end subroutine good
+end interface
+
+end module parent
+
+program main
+
+use parent
+
+tau = pi2tau(pi)
+
+print *,'pi=',pi, 'tau=', tau
+
+call good()
+
+end program