aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/same_type_as_2.f03
blob: 6fd031170070b8ffbb98f99fb30fce8d0c7139d5 (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
! { dg-do run }
!
! Verifying the runtime behavior of the intrinsic function SAME_TYPE_AS.
!
! Contributed by Janus Weil <janus@gcc.gnu.org>

 type :: t1
  integer :: i
 end type 

 type, extends(t1) :: t2
  integer :: j
 end type

 CLASS(t1), pointer :: c1,c2
 TYPE(t1), target :: x1
 TYPE(t2) ,target :: x2

 intrinsic :: SAME_TYPE_AS
 logical :: l

 c1 => NULL()

 l = SAME_TYPE_AS (x1,x1)
 print *,l
 if (.not.l) call abort()
 l = SAME_TYPE_AS (x1,x2)
 print *,l
 if (l) call abort()

 c1 => x1
 l = SAME_TYPE_AS (c1,x1)
 print *,l
 if (.not.l) call abort()
 l = SAME_TYPE_AS (c1,x2)
 print *,l
 if (l) call abort()

 c1 => x2
 c2 => x2
 l = SAME_TYPE_AS (c1,c2)
 print *,l
 if (.not.l) call abort()

 c1 => x1
 c2 => x2
 l = SAME_TYPE_AS (c1,c2)
 print *,l
 if (l) call abort()

end