xref: /llvm-project/flang/test/Lower/dispatch-table.f90 (revision d0829fbdeda0a2faa8cf684e1396e579691bdfa2)
1! RUN: bbc -emit-fir %s -o - | FileCheck %s
2
3! Tests the generation of fir.type_info operations.
4
5module polymorphic_types
6  type p1
7    integer :: a
8    integer :: b
9  contains
10    procedure :: proc1 => proc1_p1
11    procedure :: aproc
12    procedure :: zproc
13  end type
14
15  type, extends(p1) :: p2
16    integer :: c
17  contains
18    procedure :: proc1 => proc1_p2
19    procedure :: aproc2
20  end type
21
22  type, extends(p2) :: p3
23    integer :: d
24  contains
25    procedure :: aproc3
26  end type
27contains
28
29
30  subroutine proc1_p1(p)
31    class(p1) :: p
32  end subroutine
33
34  subroutine aproc(p)
35    class(p1) :: p
36  end subroutine
37
38  subroutine zproc(p)
39    class(p1) :: p
40  end subroutine
41
42  subroutine proc1_p2(p)
43    class(p2) :: p
44  end subroutine
45
46  subroutine aproc2(p)
47    class(p2) :: p
48  end subroutine
49
50  subroutine aproc3(p)
51    class(p3) :: p
52  end subroutine
53
54end module
55
56! CHECK-LABEL: fir.type_info @_QMpolymorphic_typesTp1
57! CHECK:         fir.dt_entry "aproc", @_QMpolymorphic_typesPaproc
58! CHECK:         fir.dt_entry "proc1", @_QMpolymorphic_typesPproc1_p1
59! CHECK:         fir.dt_entry "zproc", @_QMpolymorphic_typesPzproc
60! CHECK:       }
61
62! CHECK-LABEL: fir.type_info @_QMpolymorphic_typesTp2 {{.*}}extends !fir.type<_QMpolymorphic_typesTp1{{.*}}>
63! CHECK:         fir.dt_entry "aproc", @_QMpolymorphic_typesPaproc
64! CHECK:         fir.dt_entry "proc1", @_QMpolymorphic_typesPproc1_p2
65! CHECK:         fir.dt_entry "zproc", @_QMpolymorphic_typesPzproc
66! CHECK:         fir.dt_entry "aproc2", @_QMpolymorphic_typesPaproc2
67! CHECK:       }
68
69! CHECK-LABEL: fir.type_info @_QMpolymorphic_typesTp3 {{.*}}extends !fir.type<_QMpolymorphic_typesTp2{{.*}}>
70! CHECK:         fir.dt_entry "aproc", @_QMpolymorphic_typesPaproc
71! CHECK:         fir.dt_entry "proc1", @_QMpolymorphic_typesPproc1_p2
72! CHECK:         fir.dt_entry "zproc", @_QMpolymorphic_typesPzproc
73! CHECK:         fir.dt_entry "aproc2", @_QMpolymorphic_typesPaproc2
74! CHECK:         fir.dt_entry "aproc3", @_QMpolymorphic_typesPaproc3
75! CHECK:       }
76