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