annotate gcc/testsuite/gfortran.dg/implicit_2.f90 @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! { dg-do compile }
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 module implicit_2
kono
parents:
diff changeset
4 ! This should cause an error if function types are resolved from the
kono
parents:
diff changeset
5 ! module namespace.
kono
parents:
diff changeset
6 implicit none
kono
parents:
diff changeset
7 type t
kono
parents:
diff changeset
8 integer i
kono
parents:
diff changeset
9 end type
kono
parents:
diff changeset
10 contains
kono
parents:
diff changeset
11 ! This caused an ICE because we were trying to apply the implicit type
kono
parents:
diff changeset
12 ! after we had applied the explicit type.
kono
parents:
diff changeset
13 subroutine test()
kono
parents:
diff changeset
14 implicit type (t) (v)
kono
parents:
diff changeset
15 type (t) v1, v2
kono
parents:
diff changeset
16 v1%i = 1
kono
parents:
diff changeset
17 call foo (v2%i)
kono
parents:
diff changeset
18 end subroutine
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 ! A similar error because we failed to apply the implicit type to a function.
kono
parents:
diff changeset
21 ! This is a contained function to check we lookup the type in the function
kono
parents:
diff changeset
22 ! namespace, not it's parent.
kono
parents:
diff changeset
23 function f() result (val)
kono
parents:
diff changeset
24 implicit type (t) (v)
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 val%i = 1
kono
parents:
diff changeset
27 end function
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 ! And again for a result variable.
kono
parents:
diff changeset
30 function fun()
kono
parents:
diff changeset
31 implicit type (t) (f)
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 fun%i = 1
kono
parents:
diff changeset
34 end function
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 ! intrinsic types are resolved later than derived type, so check those as well.
kono
parents:
diff changeset
37 function test2()
kono
parents:
diff changeset
38 implicit integer (t)
kono
parents:
diff changeset
39 test2 = 42
kono
parents:
diff changeset
40 end function
kono
parents:
diff changeset
41 subroutine bar()
kono
parents:
diff changeset
42 ! Check that implicit types are applied to names already known to be
kono
parents:
diff changeset
43 ! variables.
kono
parents:
diff changeset
44 implicit type(t) (v)
kono
parents:
diff changeset
45 save v
kono
parents:
diff changeset
46 v%i = 42
kono
parents:
diff changeset
47 end subroutine
kono
parents:
diff changeset
48 end module