File: class_73.f90

package info (click to toggle)
lfortran 0.60.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,412 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 37; javascript: 15
file content (53 lines) | stat: -rw-r--r-- 1,272 bytes parent folder | download
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
program class_73
   implicit none

   type :: toml_map_structure
   end type toml_map_structure

   type, extends(toml_map_structure) :: toml_ordered_map
      integer, allocatable :: arr(:)
   end type toml_ordered_map

   class(toml_map_structure), allocatable :: self, self2, self3
   type(toml_ordered_map), allocatable, target :: map
   type(toml_ordered_map), pointer :: map_ptr

   allocate(map)
   allocate(map%arr(3))
   map%arr = [1, 2, 3]    
   self = map
   select type(self)
    type is (toml_ordered_map)
        if (any(self%arr /= [1,2,3])) error stop
    class default
        error stop
   end select

   map_ptr => map
   if (any(map_ptr%arr /= [1,2,3])) error stop
   deallocate(self)
   self = map_ptr
   select type(self)
    type is (toml_ordered_map)
        if (any(self%arr /= [1,2,3])) error stop
    class default
        error stop
   end select

   allocate(self2)
   self2 = map
   select type(self2)
    type is (toml_ordered_map)
        if (any(self2%arr /= [1,2,3])) error stop
    class default
        error stop
   end select

   call move_alloc(map, self3)
   select type(self3)
    type is (toml_ordered_map)
        if (any(self3%arr /= [1,2,3])) error stop
    class default
        error stop
   end select
end program class_73