annotate gcc/testsuite/gfortran.dg/class_array_14.f90 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! { dg-do run }
kono
parents:
diff changeset
2 !
kono
parents:
diff changeset
3 ! PR fortran/54618
kono
parents:
diff changeset
4 !
kono
parents:
diff changeset
5 ! Check whether default initialization works with INTENT(OUT)
kono
parents:
diff changeset
6 ! and ALLOCATABLE and no segfault occurs with OPTIONAL.
kono
parents:
diff changeset
7 !
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 subroutine test1()
kono
parents:
diff changeset
10 type typ1
kono
parents:
diff changeset
11 integer :: i = 6
kono
parents:
diff changeset
12 end type typ1
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 type(typ1) :: x
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 x%i = 77
kono
parents:
diff changeset
17 call f(x)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
18 if (x%i /= 6) STOP 1
111
kono
parents:
diff changeset
19 call f()
kono
parents:
diff changeset
20 contains
kono
parents:
diff changeset
21 subroutine f(y1)
kono
parents:
diff changeset
22 class(typ1), intent(out), optional :: y1
kono
parents:
diff changeset
23 end subroutine f
kono
parents:
diff changeset
24 end subroutine test1
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 subroutine test2()
kono
parents:
diff changeset
27 type mytype
kono
parents:
diff changeset
28 end type mytype
kono
parents:
diff changeset
29 type, extends(mytype):: mytype2
kono
parents:
diff changeset
30 end type mytype2
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 class(mytype), allocatable :: x,y
kono
parents:
diff changeset
33 allocate (mytype2 :: x)
kono
parents:
diff changeset
34 call g(x)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
35 if (allocated (x) .or. .not. same_type_as (x,y)) STOP 2
111
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 allocate (mytype2 :: x)
kono
parents:
diff changeset
38 call h(x)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
39 if (allocated (x) .or. .not. same_type_as (x,y)) STOP 3
111
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 call h()
kono
parents:
diff changeset
42 contains
kono
parents:
diff changeset
43 subroutine g(y2)
kono
parents:
diff changeset
44 class(mytype), intent(out), allocatable :: y2
kono
parents:
diff changeset
45 end subroutine g
kono
parents:
diff changeset
46 subroutine h(y3)
kono
parents:
diff changeset
47 class(mytype), optional, intent(out), allocatable :: y3
kono
parents:
diff changeset
48 end subroutine h
kono
parents:
diff changeset
49 end subroutine test2
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 call test1()
kono
parents:
diff changeset
52 call test2()
kono
parents:
diff changeset
53 end