Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / separate-mp01.f90
blob27bf2a2f0ca0c69b34a1a87d81bbec2b6669b57e
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 ! case 1: ma_create_new_fun' was not declared a separate module procedure
4 module m1
5 integer :: i
6 interface ma
7 module function ma_create_fun( ) result(this)
8 integer this
9 end function
10 end interface
11 end module
13 submodule (m1) ma_submodule
14 integer :: j
15 contains
16 module function ma_create_fun() result(this)
17 integer this
18 i = 1
19 j = 2
20 end function
22 !ERROR: 'ma_create_new_fun' was not declared a separate module procedure
23 module function ma_create_new_fun() result(this)
24 integer :: this
25 i = 2
26 j = 1
27 print *, "Hello"
28 end function
29 end submodule
31 ! case 2: 'mb_create_new_sub' was not declared a separate module procedure
32 module m2
33 integer :: i
34 interface mb
35 module subroutine mb_create_sub
36 end subroutine mb_create_sub
37 end interface
38 end module
40 submodule (m2) mb_submodule
41 integer :: j
42 contains
43 module subroutine mb_create_sub
44 integer this
45 i = 1
46 j = 2
47 end subroutine mb_create_sub
49 !ERROR: 'mb_create_new_sub' was not declared a separate module procedure
50 module SUBROUTINE mb_create_new_sub()
51 integer :: this
52 i = 2
53 j = 1
54 end SUBROUTINE mb_create_new_sub
55 end submodule
57 ! case 3: separate module procedure without module prefix
58 module m3
59 interface mc
60 function mc_create( ) result(this)
61 integer :: this
62 end function
63 end interface
64 end module
66 submodule (m3) mc_submodule
67 contains
68 !ERROR: 'mc_create' was not declared a separate module procedure
69 module function mc_create() result(this)
70 integer :: this
71 end function
72 end submodule
74 ! case 4: Submodule having separate module procedure rather than a module
75 module m4
76 interface
77 real module function func1() ! module procedure interface body for func1
78 end function
79 end interface
80 end module
82 submodule (m4) m4sub
83 interface
84 module function func2(b) ! module procedure interface body for func2
85 integer :: b
86 integer :: func2
87 end function
89 real module function func3() ! module procedure interface body for func3
90 end function
91 end interface
92 contains
93 real module function func1() ! implementation of func1 declared in m4
94 func1 = 20
95 end function
96 end submodule
98 submodule (m4:m4sub) m4sub2
99 contains
100 module function func2(b) ! implementation of func2 declared in m4sub
101 integer :: b
102 integer :: func2
103 func2 = b
104 end function
106 real module function func3() ! implementation of func3 declared in m4sub
107 func3 = 20
108 end function
109 end submodule