Debian Codegraph @

gcc/testsuite/gfortran.dg/bounds_check_27.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fcheck=bounds" }
3 !
4 ! PR fortran/116706 - bogus bounds check for reallocation on assignment
5 ! Contributed by Balint Aradi <baradi09 at gmail.com>
6
7 program testprog
8 implicit none
9
10 type :: data_node
11 integer, allocatable :: data(:)
12 end type data_node
13
14 type :: data_list
15 type(data_node), pointer :: nodes(:) => null()
16 end type data_list
17
18 type :: upoly_node
19 class(*), allocatable :: data(:)
20 end type upoly_node
21
22 type :: star_list
23 type(upoly_node), pointer :: nodes(:) => null()
24 end type star_list
25
26 type(data_list) :: datalist
27 type(star_list) :: starlist
28 class(star_list), allocatable :: astarlist
29 class(star_list), pointer :: pstarlist
30
31 allocate (datalist%nodes(2))
32 datalist%nodes(1)%data = [1, 2, 3]
33
34 allocate (starlist%nodes(2))
35 starlist%nodes(1)%data = [1., 2., 3.]
36
37 allocate (astarlist)
38 allocate (astarlist%nodes(2))
39 astarlist%nodes(1)%data = [1, 2, 3]
40
41 allocate (pstarlist)
42 allocate (pstarlist%nodes(2))
43 pstarlist%nodes(1)%data = [1., 2., 3.]
44
45 end program testprog