annotate gcc/testsuite/gfortran.dg/submodule_6.f08 @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +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 ! { dg-require-effective-target lto }
kono
parents:
diff changeset
3 ! { dg-options "-flto" }
kono
parents:
diff changeset
4 !
kono
parents:
diff changeset
5 ! Checks that the results of module procedures have the correct characteristics
kono
parents:
diff changeset
6 ! and that submodules use the module version of vtables (PR66762). This latter
kono
parents:
diff changeset
7 ! requires the -flto compile option.
kono
parents:
diff changeset
8 !
kono
parents:
diff changeset
9 ! Contributed by Reinhold Bader <reinhold.bader@lrz.de>
kono
parents:
diff changeset
10 !
kono
parents:
diff changeset
11 module mod_a
kono
parents:
diff changeset
12 implicit none
kono
parents:
diff changeset
13 type, abstract :: t_a
kono
parents:
diff changeset
14 end type t_a
kono
parents:
diff changeset
15 interface
kono
parents:
diff changeset
16 module subroutine p_a(this, q)
kono
parents:
diff changeset
17 class(t_a), intent(inout) :: this
kono
parents:
diff changeset
18 class(*), intent(in) :: q
kono
parents:
diff changeset
19 end subroutine
kono
parents:
diff changeset
20 module function create_a() result(r)
kono
parents:
diff changeset
21 class(t_a), allocatable :: r
kono
parents:
diff changeset
22 end function
kono
parents:
diff changeset
23 module subroutine print(this)
kono
parents:
diff changeset
24 class(t_a), intent(in) :: this
kono
parents:
diff changeset
25 end subroutine
kono
parents:
diff changeset
26 end interface
kono
parents:
diff changeset
27 end module mod_a
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 module mod_b
kono
parents:
diff changeset
30 implicit none
kono
parents:
diff changeset
31 type t_b
kono
parents:
diff changeset
32 integer, allocatable :: I(:)
kono
parents:
diff changeset
33 end type t_b
kono
parents:
diff changeset
34 interface
kono
parents:
diff changeset
35 module function create_b(i) result(r)
kono
parents:
diff changeset
36 type(t_b) :: r
kono
parents:
diff changeset
37 integer :: i(:)
kono
parents:
diff changeset
38 end function
kono
parents:
diff changeset
39 end interface
kono
parents:
diff changeset
40 end module mod_b
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 submodule(mod_b) imp_create
kono
parents:
diff changeset
43 contains
kono
parents:
diff changeset
44 module procedure create_b
kono
parents:
diff changeset
45 if (allocated(r%i)) deallocate(r%i)
kono
parents:
diff changeset
46 allocate(r%i, source=i)
kono
parents:
diff changeset
47 end procedure
kono
parents:
diff changeset
48 end submodule imp_create
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 submodule(mod_a) imp_p_a
kono
parents:
diff changeset
51 use mod_b
kono
parents:
diff changeset
52 type, extends(t_a) :: t_imp
kono
parents:
diff changeset
53 type(t_b) :: b
kono
parents:
diff changeset
54 end type t_imp
kono
parents:
diff changeset
55 integer, parameter :: ii(2) = [1,2]
kono
parents:
diff changeset
56 contains
kono
parents:
diff changeset
57 module procedure create_a
kono
parents:
diff changeset
58 type(t_b) :: b
kono
parents:
diff changeset
59 b = create_b(ii)
kono
parents:
diff changeset
60 allocate(r, source=t_imp(b))
kono
parents:
diff changeset
61 end procedure
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 module procedure p_a
kono
parents:
diff changeset
64 select type (this)
kono
parents:
diff changeset
65 type is (t_imp)
kono
parents:
diff changeset
66 select type (q)
kono
parents:
diff changeset
67 type is (t_b)
kono
parents:
diff changeset
68 this%b = q
kono
parents:
diff changeset
69 class default
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
70 STOP 1
111
kono
parents:
diff changeset
71 end select
kono
parents:
diff changeset
72 class default
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
73 STOP 2
111
kono
parents:
diff changeset
74 end select
kono
parents:
diff changeset
75 end procedure p_a
kono
parents:
diff changeset
76 module procedure print
kono
parents:
diff changeset
77 select type (this)
kono
parents:
diff changeset
78 type is (t_imp)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
79 if (any (this%b%i .ne. [3,4,5])) STOP 3
111
kono
parents:
diff changeset
80 class default
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
81 STOP 4
111
kono
parents:
diff changeset
82 end select
kono
parents:
diff changeset
83 end procedure
kono
parents:
diff changeset
84 end submodule imp_p_a
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 program p
kono
parents:
diff changeset
87 use mod_a
kono
parents:
diff changeset
88 use mod_b
kono
parents:
diff changeset
89 implicit none
kono
parents:
diff changeset
90 class(t_a), allocatable :: a
kono
parents:
diff changeset
91 allocate(a, source=create_a())
kono
parents:
diff changeset
92 call p_a(a, create_b([3,4,5]))
kono
parents:
diff changeset
93 call print(a)
kono
parents:
diff changeset
94 end program p