summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/class_72.f90
blob: 0fd6ec010f5f3e09aa335b9022ba4714836205ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
! PR fortran/102745

implicit none

type t
end type t

type, extends(t) :: t2
end type t2

type t3
end type t3

type(t), allocatable :: var
type(t2), allocatable :: v2ar
type(t3), allocatable :: v3ar
class(t), allocatable :: cvar
class(t2), allocatable :: c2var
class(t3), allocatable :: c3var

call f(var)
call f(v2ar)   ! { dg-error "passed TYPE.t2. to TYPE.t." }
call f(v2ar%t)
call f(cvar)
call f(c2var)  ! { dg-error "passed CLASS.t2. to TYPE.t." }
call f(c2var%t)

call f2(var)   ! { dg-error "passed TYPE.t. to TYPE.t2." }
call f2(v2ar)
call f2(cvar)  ! { dg-error "passed CLASS.t. to TYPE.t2." }
call f2(c2var)


var = var
var = v2ar  ! { dg-error "TYPE.t2. to TYPE.t." }
var = cvar
var = c2var ! { dg-error "TYPE.t2. to TYPE.t." }

v2ar = var  ! { dg-error "Cannot convert TYPE.t. to TYPE.t2." }
v2ar = v2ar
v2ar = cvar ! { dg-error "Cannot convert TYPE.t. to TYPE.t2." }
v2ar = c2var

cvar = var
cvar = v2ar
cvar = cvar
cvar = c2var

c2var = var   ! { dg-error "Cannot convert TYPE.t. to CLASS.t2." }
c2var = v3ar  ! { dg-error "Cannot convert TYPE.t3. to CLASS.t2." }
c2var = v2ar
c2var = cvar  ! { dg-error "Cannot convert CLASS.t. to CLASS.t2." }
c2var = c3var ! { dg-error "Cannot convert CLASS.t3. to CLASS.t2." }
c2var = c2var

allocate (var, source=var)
allocate (var, source=v2ar)   ! { dg-error "incompatible with source-expr" }
allocate (var, source=cvar)
allocate (var, source=c2var)  ! { dg-error "incompatible with source-expr" }

allocate (v2ar, source=var)   ! { dg-error "incompatible with source-expr" }
allocate (v2ar, source=v2ar)
allocate (v2ar, source=cvar)  ! { dg-error "incompatible with source-expr" }
allocate (v2ar, source=c2var)

allocate (cvar, source=var)
allocate (cvar, source=v2ar)
allocate (cvar, source=cvar)
allocate (cvar, source=c2var)

allocate (c2var, source=var)  ! { dg-error "incompatible with source-expr" }
allocate (c2var, source=v2ar)
allocate (c2var, source=cvar) ! { dg-error "incompatible with source-expr" }
allocate (c2var, source=c2var)

contains
 subroutine f(x)
   type(t) :: x
 end
 subroutine f2(x)
   type(t2) :: x
 end
end