3 ! Tests comparisons of MODULE PROCEDURE characteristics and
4 ! the characteristics of their dummies. Also tests the error
5 ! arising from redefining dummies and results in MODULE
8 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
13 character(len
=16) :: greeting
= "Hello, world! "
14 character(len
=16), private
:: byebye
= "adieu, world! "
18 module function array1(this
) result (that
)
19 type(foo
), intent(in
), dimension(:) :: this
20 type(foo
), allocatable
, dimension(:) :: that
22 character(16) module function array2(this
, that
)
23 type(foo
), intent(in
), dimension(:) :: this
24 type(foo
), allocatable
, dimension(:) :: that
26 module subroutine array3(this
, that
)
27 type(foo
), intent(in
), dimension(:) :: this
28 type(foo
), intent(inOUT
), allocatable
, dimension(:) :: that
30 module subroutine array4(this
, that
)
31 type(foo
), intent(in
), dimension(:) :: this
32 type(foo
), intent(inOUT
), allocatable
, dimension(:) :: that
34 integer module function scalar1 (arg
)
35 real, intent(in
) :: arg
37 module function scalar2 (arg
) result(res
)
38 real, intent(in
) :: arg
41 module function scalar3 (arg
) result(res
)
42 real, intent(in
) :: arg
45 module function scalar4 (arg
) result(res
)
46 real, intent(in
) :: arg
49 module function scalar5 (arg
) result(res
)
50 real, intent(in
) :: arg
51 real, allocatable
:: res
53 module function scalar6 (arg
) result(res
)
54 real, intent(in
) :: arg
55 real, allocatable
:: res
57 module function scalar7 (arg
) result(res
)
58 real, intent(in
) :: arg
59 real, allocatable
:: res
65 SUBMODULE (foo_interface
) foo_interface_son
69 module function array1 (this
) result(that
) ! { dg-error "Rank mismatch in function result" }
70 type(foo
), intent(in
), dimension(:) :: this
71 type(foo
), allocatable
:: that
74 character(16) module function array2(this
) ! { dg-error "Mismatch in number of MODULE PROCEDURE formal arguments" }
75 type(foo
), intent(in
), dimension(:) :: this
76 type(foo
), allocatable
, dimension(:) :: that
77 allocate (that(2), source
= this(1))
78 that
%greeting
= that
%byebye
79 array2
= trim (that(size (that
))%greeting(1:5))//", people!"
82 module subroutine array3(thiss
, that
) ! { dg-error "Mismatch in MODULE PROCEDURE formal argument names" }
83 type(foo
), intent(in
), dimension(:) :: thiss
84 type(foo
), intent(inOUT
), allocatable
, dimension(:) :: that
85 allocate (that(size(thiss
)), source
= thiss
)
86 that
%greeting
= that
%byebye
89 module subroutine array4(this
, that
, the_other
) ! { dg-error "Mismatch in number of MODULE PROCEDURE formal arguments" }
90 type(foo
), intent(in
), dimension(:) :: this
91 type(foo
), intent(inOUT
), allocatable
, dimension(:) :: that
, the_other
93 allocate (that(size(this
)), source
= this
)
94 that
%greeting
= that
%byebye
96 that(i
)%greeting
= trim (that(i
)%greeting(1:5))//", people!"
100 recursive module function scalar1 (arg
) ! { dg-error "Mismatch in RECURSIVE" }
101 real, intent(in
) :: arg
104 pure
module function scalar2 (arg
) result(res
) ! { dg-error "Mismatch in PURE" }
105 real, intent(in
) :: arg
109 module procedure scalar7
110 real, intent(in
) :: arg
! { dg-error "redefinition of the declaration" }
111 real, allocatable
:: res
! { dg-error "redefinition of the declaration" }
112 end function ! { dg-error "Expecting END PROCEDURE statement" }
113 end procedure
! This prevents a cascade of errors.
114 end SUBMODULE foo_interface_son
117 SUBMODULE (foo_interface
) foo_interface_daughter
121 module function scalar3 (arg
) result(res
) ! { dg-error "Type mismatch in argument" }
122 integer, intent(in
) :: arg
126 module function scalar4 (arg
) result(res
) ! { dg-error "Type mismatch in function result" }
127 real, intent(in
) :: arg
131 module function scalar5 (arg
) result(res
) ! { dg-error "ALLOCATABLE attribute mismatch in function result " }
132 real, intent(in
) :: arg
136 module function scalar6 (arg
) result(res
) ! { dg-error "Rank mismatch in argument" }
137 real, intent(in
), dimension(2) :: arg
138 real, allocatable
:: res
140 end SUBMODULE foo_interface_daughter