1! { dg-do compile }
2! { dg-options "-std=f95" }
3!
4! PR fortran/53111
5!
6
7! ------------ INVALID ONE ------------------------
8
9module m
10type t
11  integer :: i
12end type t
13end
14
15module m2
16 interface t
17   module procedure sub
18 end interface t
19contains
20 integer function sub()
21   sub = 4
22 end function sub
23end module m2
24
25! Note: The following is formally valid as long as "t" is not used.
26! For simplicity, -std=f95 will give an error.
27! It is unlikely that a real-world program is rejected with -std=f95
28! because of that.
29
30use m   ! { dg-error "Fortran 2003: Generic name 't' of function 'sub' at .1. being the same name as derived type at" }
31use m2  ! { dg-error "Fortran 2003: Generic name 't' of function 'sub' at .1. being the same name as derived type at" }
32! i = sub()  ! << Truly invalid in F95, valid in F2003
33end
34
35! ------------ INVALID TWO ------------------------
36
37module m3
38type t2  ! { dg-error "Fortran 2003: Generic name 't2' of function 'sub2' at .1. being the same name as derived type at" }
39  integer :: i
40end type t2
41 interface t2
42   module procedure sub2
43 end interface t2
44contains
45 integer function sub2()  ! { dg-error "Fortran 2003: Generic name 't2' of function 'sub2' at .1. being the same name as derived type at" }
46   sub2 = 4
47 end function sub2
48end module m3
49