1! { dg-do run }
2
3  integer, allocatable :: a, b(:), c(:,:)
4  logical :: l
5  if (allocated (a) .or. allocated (b) .or. allocated (c)) STOP 1
6!$omp parallel private (a, b, c)
7  if (allocated (a) .or. allocated (b) .or. allocated (c)) STOP 2
8  allocate (a, b(-7:-1), c(2:3, 3:5))
9  if (.not.allocated (a)) STOP 3
10  if (.not.allocated (b) .or. size (b) /= 7) STOP 4
11  if (lbound (b, 1) /= -7 .or. ubound (b, 1) /= -1) STOP 5
12  if (.not.allocated (c) .or. size (c) /= 6) STOP 6
13  if (size (c, 1) /= 2 .or. size (c, 2) /= 3) STOP 7
14  if (lbound (c, 1) /= 2 .or. ubound (c, 1) /= 3) STOP 8
15  if (lbound (c, 2) /= 3 .or. ubound (c, 2) /= 5) STOP 9
16  a = 4
17  b = 3
18  c = 2
19!$omp end parallel
20  if (allocated (a) .or. allocated (b) .or. allocated (c)) STOP 10
21!$omp parallel firstprivate (a, b, c)
22  if (allocated (a) .or. allocated (b) .or. allocated (c)) STOP 11
23  allocate (a, b(-7:-1), c(2:3, 3:5))
24  if (.not.allocated (a)) STOP 12
25  if (.not.allocated (b) .or. size (b) /= 7) STOP 13
26  if (lbound (b, 1) /= -7 .or. ubound (b, 1) /= -1) STOP 14
27  if (.not.allocated (c) .or. size (c) /= 6) STOP 15
28  if (size (c, 1) /= 2 .or. size (c, 2) /= 3) STOP 16
29  if (lbound (c, 1) /= 2 .or. ubound (c, 1) /= 3) STOP 17
30  if (lbound (c, 2) /= 3 .or. ubound (c, 2) /= 5) STOP 18
31  a = 4
32  b = 3
33  c = 2
34!$omp end parallel
35  if (allocated (a) .or. allocated (b) .or. allocated (c)) STOP 19
36  allocate (a, b(6:9), c(3, 8:9))
37  a = 2
38  b = 4
39  c = 5
40  if (.not.allocated (a)) STOP 20
41  if (.not.allocated (b) .or. size (b) /= 4) STOP 21
42  if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) STOP 22
43  if (.not.allocated (c) .or. size (c) /= 6) STOP 23
44  if (size (c, 1) /= 3 .or. size (c, 2) /= 2) STOP 24
45  if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) STOP 25
46  if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) STOP 26
47!$omp parallel firstprivate (a, b, c)
48  if (.not.allocated (a)) STOP 27
49  if (.not.allocated (b) .or. size (b) /= 4) STOP 28
50  if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) STOP 29
51  if (.not.allocated (c) .or. size (c) /= 6) STOP 30
52  if (size (c, 1) /= 3 .or. size (c, 2) /= 2) STOP 31
53  if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) STOP 32
54  if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) STOP 33
55  if (a /= 2 .or. any (b .ne. 4) .or. any (c .ne. 5)) STOP 34
56  deallocate (a)
57  if (allocated (a)) STOP 35
58  allocate (a)
59  a = 8
60  b = (/ 1, 2, 3 /)
61  c = reshape ((/ 1, 2, 3, 4, 5, 6, 7, 8 /), (/ 2, 4 /))
62  if (.not.allocated (a)) STOP 36
63  if (.not.allocated (b) .or. size (b) /= 3) STOP 37
64  if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 3) STOP 38
65  if (.not.allocated (c) .or. size (c) /= 8) STOP 39
66  if (size (c, 1) /= 2 .or. size (c, 2) /= 4) STOP 40
67  if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 2) STOP 41
68  if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 4) STOP 42
69  if (a /= 8 .or. b(2) /= 2 .or. c(1, 2) /= 3) STOP 43
70!$omp end parallel
71  if (.not.allocated (a)) STOP 44
72  if (.not.allocated (b) .or. size (b) /= 4) STOP 45
73  if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) STOP 46
74  if (.not.allocated (c) .or. size (c) /= 6) STOP 47
75  if (size (c, 1) /= 3 .or. size (c, 2) /= 2) STOP 48
76  if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) STOP 49
77  if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) STOP 50
78  if (a /= 2 .or. any (b .ne. 4) .or. any (c .ne. 5)) STOP 51
79  l = .false.
80!$omp parallel sections lastprivate (a, b, c) firstprivate (l)
81!$omp section
82  if (.not.allocated (a)) STOP 52
83  if (l) then
84    if (.not.allocated (b) .or. size (b) /= 6) STOP 53
85    if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 6) STOP 54
86    if (.not.allocated (c) .or. size (c) /= 8) STOP 55
87    if (size (c, 1) /= 4 .or. size (c, 2) /= 2) STOP 56
88    if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 4) STOP 57
89    if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 2) STOP 58
90    if (a /= 12 .or. b(2) /= 8 .or. c(1, 2) /= 5) STOP 59
91  else
92    if (.not.allocated (b) .or. size (b) /= 4) STOP 60
93    if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) STOP 61
94    if (.not.allocated (c) .or. size (c) /= 6) STOP 62
95    if (size (c, 1) /= 3 .or. size (c, 2) /= 2) STOP 63
96    if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) STOP 64
97    if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) STOP 65
98  end if
99  l = .true.
100  deallocate (a)
101  if (allocated (a)) STOP 66
102  allocate (a)
103  a = 8
104  b = (/ 1, 2, 3 /)
105  c = reshape ((/ 1, 2, 3, 4, 5, 6, 7, 8 /), (/ 2, 4 /))
106  if (.not.allocated (a)) STOP 67
107  if (.not.allocated (b) .or. size (b) /= 3) STOP 68
108  if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 3) STOP 69
109  if (.not.allocated (c) .or. size (c) /= 8) STOP 70
110  if (size (c, 1) /= 2 .or. size (c, 2) /= 4) STOP 71
111  if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 2) STOP 72
112  if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 4) STOP 73
113  if (a /= 8 .or. b(2) /= 2 .or. c(1, 2) /= 3) STOP 74
114!$omp section
115  if (.not.allocated (a)) STOP 75
116  if (l) then
117    if (.not.allocated (b) .or. size (b) /= 3) STOP 76
118    if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 3) STOP 77
119    if (.not.allocated (c) .or. size (c) /= 8) STOP 78
120    if (size (c, 1) /= 2 .or. size (c, 2) /= 4) STOP 79
121    if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 2) STOP 80
122    if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 4) STOP 81
123    if (a /= 8 .or. b(2) /= 2 .or. c(1, 2) /= 3) STOP 82
124  else
125    if (.not.allocated (b) .or. size (b) /= 4) STOP 83
126    if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) STOP 84
127    if (.not.allocated (c) .or. size (c) /= 6) STOP 85
128    if (size (c, 1) /= 3 .or. size (c, 2) /= 2) STOP 86
129    if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) STOP 87
130    if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) STOP 88
131  end if
132  l = .true.
133  deallocate (a)
134  if (allocated (a)) STOP 89
135  allocate (a)
136  a = 12
137  b = (/ 9, 8, 7, 6, 5, 4 /)
138  c = reshape ((/ 1, 2, 3, 4, 5, 6, 7, 8 /), (/ 4, 2 /))
139  if (.not.allocated (a)) STOP 90
140  if (.not.allocated (b) .or. size (b) /= 6) STOP 91
141  if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 6) STOP 92
142  if (.not.allocated (c) .or. size (c) /= 8) STOP 93
143  if (size (c, 1) /= 4 .or. size (c, 2) /= 2) STOP 94
144  if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 4) STOP 95
145  if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 2) STOP 96
146  if (a /= 12 .or. b(2) /= 8 .or. c(1, 2) /= 5) STOP 97
147!$omp end parallel sections
148  if (.not.allocated (a)) STOP 98
149  if (.not.allocated (b) .or. size (b) /= 6) STOP 99
150  if (lbound (b, 1) /= 1 .or. ubound (b, 1) /= 6) STOP 100
151  if (.not.allocated (c) .or. size (c) /= 8) STOP 101
152  if (size (c, 1) /= 4 .or. size (c, 2) /= 2) STOP 102
153  if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 4) STOP 103
154  if (lbound (c, 2) /= 1 .or. ubound (c, 2) /= 2) STOP 104
155  if (a /= 12 .or. b(2) /= 8 .or. c(1, 2) /= 5) STOP 105
156end
157