Debian Codegraph @

gcc/testsuite/gfortran.dg/constructor_7.f90

raw
1 ! { dg-do compile }
2 ! { dg-options "-std=f95" }
3 !
4 ! PR fortran/53111
5 !
6
7 ! ------------ INVALID ONE ------------------------
8
9 module m
10 type t
11 integer :: i
12 end type t
13 end
14
15 module m2
16 interface t
17 module procedure sub
18 end interface t
19 contains
20 integer function sub()
21 sub = 4
22 end function sub
23 end 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
30 use m ! { dg-error "Fortran 2003: Generic name 't' of function 'sub' at .1. being the same name as derived type at" }
31 use 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
33 end
34
35 ! ------------ INVALID TWO ------------------------
36
37 module m3
38 type t2 ! { dg-error "Fortran 2003: Generic name 't2' of function 'sub2' at .1. being the same name as derived type at" }
39 integer :: i
40 end type t2
41 interface t2
42 module procedure sub2
43 end interface t2
44 contains
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
48 end module m3