Debian Codegraph @

gcc/testsuite/gfortran.dg/pr100194.f90

raw
1 ! { dg-do run }
2 !
3 ! PR fortran/100194
4 ! ICE in gfc_trans_create_temp_array when passing a non-contiguous
5 ! assumed-rank array to a contiguous assumed-rank dummy argument.
6 !
7 ! Contributed by Martin Diehl <[email protected]>
8
9 subroutine s(x)
10 real :: x(..)
11 call t(x)
12 contains
13 subroutine t(y)
14 real, contiguous :: y(..)
15 end
16 end
17
18 ! The following from the PR, these compiled OK before the patch.
19 !
20 ! Contributed by G. Steinmetz <[email protected]>
21
22 subroutine z3(x)
23 real, contiguous :: x(..)
24 call t(x)
25 contains
26 subroutine t(y)
27 real, contiguous :: y(..)
28 end
29 end
30
31 subroutine z2(x)
32 real, contiguous :: x(..)
33 call t(x)
34 contains
35 subroutine t(y)
36 real :: y(..)
37 end
38 end
39
40 ! Runtime follow-up from Paul Thomas <[email protected]>.
41
42 program p
43 implicit none
44 interface
45 subroutine pr100194_runtime(x, res)
46 integer :: x(..)
47 integer, allocatable :: res(:)
48 end subroutine pr100194_runtime
49 end interface
50
51 type :: ty
52 character(4) :: chr
53 integer :: r(2)
54 end type ty
55
56 integer :: x(4) = [42, 84, 126, 168]
57 type(ty) :: y = ty("abcd", [42, 84])
58 integer, allocatable :: z(:)
59 integer, allocatable :: u(:, :)
60
61 u = reshape ([x, 4 * x, 16 * x, 64 * x], [4, 4])
62
63 call pr100194_runtime(x, z)
64 if (any (z /= [84, 168, 252, 336])) stop 1
65
66 call pr100194_runtime(x(1:4:2), z)
67 if (any (z /= [84, 252])) stop 2
68
69 call pr100194_runtime(x([1, 3, 4, 2]), z)
70 if (any (z /= [84, 252, 336, 168])) stop 3
71
72 call pr100194_runtime(y%r, z)
73 if (any (z /= [84, 168])) stop 4
74
75 call pr100194_runtime(u(1, :), z)
76 if (any (z /= [84, 336, 1344, 5376])) stop 5
77
78 call pr100194_runtime(u(:, 1), z)
79 if (any (z /= [84, 168, 252, 336])) stop 6
80 end program p
81
82 subroutine pr100194_runtime(x, res)
83 integer :: x(..)
84 integer, allocatable :: res(:)
85
86 call t(x)
87
88 contains
89
90 subroutine t(y)
91 integer, contiguous :: y(..)
92
93 select rank (y)
94 rank (1)
95 res = 2 * y
96 end select
97 end subroutine t
98 end subroutine pr100194_runtime