annotate gcc/testsuite/gfortran.dg/assumed_rank_bounds_2.f90 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +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 !
kono
parents:
diff changeset
3 ! Test the behavior of lbound, ubound of shape with assumed rank arguments
kono
parents:
diff changeset
4 ! in an array context (without DIM argument).
kono
parents:
diff changeset
5 !
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 program test
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 integer :: a(2:4,-2:5)
kono
parents:
diff changeset
10 integer, allocatable :: b(:,:)
kono
parents:
diff changeset
11 integer, allocatable :: c(:,:)
kono
parents:
diff changeset
12 integer, pointer :: d(:,:)
kono
parents:
diff changeset
13 character(52) :: buffer
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 b = foo(a)
kono
parents:
diff changeset
16 !print *,b(:,1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
17 if (any(b(:,1) /= [11, 101])) STOP 1
111
kono
parents:
diff changeset
18 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
19 write(buffer,*) b(:,1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
20 if (buffer /= ' 11 101') STOP 2
111
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 !print *,b(:,2)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
23 if (any(b(:,2) /= [3, 8])) STOP 3
111
kono
parents:
diff changeset
24 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
25 write(buffer,*) b(:,2)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
26 if (buffer /= ' 3 8') STOP 4
111
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 !print *,b(:,3)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
29 if (any(b(:,3) /= [13, 108])) STOP 5
111
kono
parents:
diff changeset
30 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
31 write(buffer,*) b(:,3)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
32 if (buffer /= ' 13 108') STOP 6
111
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 allocate(c(1:2,-3:6))
kono
parents:
diff changeset
36 b = bar(c)
kono
parents:
diff changeset
37 !print *,b(:,1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
38 if (any(b(:,1) /= [11, 97])) STOP 7
111
kono
parents:
diff changeset
39 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
40 write(buffer,*) b(:,1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
41 if (buffer /= ' 11 97') STOP 8
111
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 !print *,b(:,2)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
44 if (any(b(:,2) /= [12, 106])) STOP 9
111
kono
parents:
diff changeset
45 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
46 write(buffer,*) b(:,2)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
47 if (buffer /= ' 12 106') STOP 10
111
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 !print *,b(:,3)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
50 if (any(b(:,3) /= [2, 10])) STOP 11
111
kono
parents:
diff changeset
51 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
52 write(buffer,*) b(:,3)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
53 if (buffer /= ' 2 10') STOP 12
111
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 allocate(d(3:5,-1:10))
kono
parents:
diff changeset
57 b = baz(d)
kono
parents:
diff changeset
58 !print *,b(:,1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
59 if (any(b(:,1) /= [3, -1])) STOP 13
111
kono
parents:
diff changeset
60 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
61 write(buffer,*) b(:,1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
62 if (buffer /= ' 3 -1') STOP 14
111
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 !print *,b(:,2)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
65 if (any(b(:,2) /= [15, 110])) STOP 15
111
kono
parents:
diff changeset
66 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
67 write(buffer,*) b(:,2)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
68 if (buffer /= ' 15 110') STOP 16
111
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 !print *,b(:,3)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
71 if (any(b(:,3) /= [13, 112])) STOP 17
111
kono
parents:
diff changeset
72 buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
kono
parents:
diff changeset
73 write(buffer,*) b(:,3)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
74 if (buffer /= ' 13 112') STOP 18
111
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 contains
kono
parents:
diff changeset
78 function foo(arg) result(res)
kono
parents:
diff changeset
79 integer :: arg(..)
kono
parents:
diff changeset
80 integer, allocatable :: res(:,:)
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 allocate(res(rank(arg), 3))
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 res(:,1) = lbound(arg) + (/ 10, 100 /)
kono
parents:
diff changeset
85 res(:,2) = ubound(arg)
kono
parents:
diff changeset
86 res(:,3) = (/ 10, 100 /) + shape(arg)
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 end function foo
kono
parents:
diff changeset
89 function bar(arg) result(res)
kono
parents:
diff changeset
90 integer, allocatable :: arg(..)
kono
parents:
diff changeset
91 integer, allocatable :: res(:,:)
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 allocate(res(-1:rank(arg)-2, 3))
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 res(:,1) = lbound(arg) + (/ 10, 100 /)
kono
parents:
diff changeset
96 res(:,2) = (/ 10, 100 /) + ubound(arg)
kono
parents:
diff changeset
97 res(:,3) = shape(arg)
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 end function bar
kono
parents:
diff changeset
100 function baz(arg) result(res)
kono
parents:
diff changeset
101 integer, pointer :: arg(..)
kono
parents:
diff changeset
102 integer, allocatable :: res(:,:)
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 allocate(res(2:rank(arg)+1, 3))
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 res(:,1) = lbound(arg)
kono
parents:
diff changeset
107 res(:,2) = (/ 10, 100 /) + ubound(arg)
kono
parents:
diff changeset
108 res(:,3) = shape(arg) + (/ 10, 100 /)
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 end function baz
kono
parents:
diff changeset
111 end program test
kono
parents:
diff changeset
112