2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / implicit_2.f90
blobc0582d703b6014e174e51986a8a33ac9a88dd901
1 ! { dg-do compile }
3 module implicit_2
4 ! This should cause an error if function types are resolved from the
5 ! module namespace.
6 implicit none
7 type t
8 integer i
9 end type
10 contains
11 ! This caused an ICE because we were trying to apply the implicit type
12 ! after we had applied the explicit type.
13 subroutine test()
14 implicit type (t) (v)
15 type (t) v1, v2
16 v1%i = 1
17 call foo (v2%i)
18 end subroutine
20 ! A similar error because we failed to apply the implicit type to a function.
21 ! This is a contained function to check we lookup the type in the function
22 ! namespace, not it's parent.
23 function f() result (val)
24 implicit type (t) (v)
26 val%i = 1
27 end function
29 ! And again for a result variable.
30 function fun()
31 implicit type (t) (f)
33 fun%i = 1
34 end function
36 ! intrinsic types are resolved later than derived type, so check those as well.
37 function test2()
38 implicit integer (t)
39 test2 = 42
40 end function
41 subroutine bar()
42 ! Check that implicit types are applied to names already known to be
43 ! variables.
44 implicit type(t) (v)
45 save v
46 v%i = 42
47 end subroutine
48 end module