2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / minloc_1.f90
blobb8572945b312568e3770cdc7fbafdfe90d5d17ae
1 ! { dg-do run }
2 ! { dg-add-options ieee }
3 ! { dg-skip-if "NaN not supported" { spu-*-* } }
4 real :: a(3), nan, minf, pinf
5 integer :: ia(1)
6 real, allocatable :: c(:)
7 logical :: l
8 logical :: l2(3)
10 nan = 0.0
11 minf = 0.0
12 pinf = 0.0
13 nan = 0.0/nan
14 minf = -1.0/minf
15 pinf = 1.0/pinf
17 allocate (c(3))
18 a(:) = nan
19 ia = minloc (a)
20 if (ia(1).ne.1) call abort
21 a(:) = pinf
22 ia = minloc (a)
23 if (ia(1).ne.1) call abort
24 a(1:2) = nan
25 ia = minloc (a)
26 if (ia(1).ne.3) call abort
27 a(2) = 1.0
28 ia = minloc (a)
29 if (ia(1).ne.2) call abort
30 a(2) = minf
31 ia = minloc (a)
32 if (ia(1).ne.2) call abort
33 c(:) = nan
34 ia = minloc (c)
35 if (ia(1).ne.1) call abort
36 c(:) = pinf
37 ia = minloc (c)
38 if (ia(1).ne.1) call abort
39 c(1:2) = nan
40 ia = minloc (c)
41 if (ia(1).ne.3) call abort
42 c(2) = 1.0
43 ia = minloc (c)
44 if (ia(1).ne.2) call abort
45 c(2) = minf
46 ia = minloc (c)
47 if (ia(1).ne.2) call abort
48 l = .false.
49 l2(:) = .false.
50 a(:) = nan
51 ia = minloc (a, mask = l)
52 if (ia(1).ne.0) call abort
53 ia = minloc (a, mask = l2)
54 if (ia(1).ne.0) call abort
55 a(:) = pinf
56 ia = minloc (a, mask = l)
57 if (ia(1).ne.0) call abort
58 ia = minloc (a, mask = l2)
59 if (ia(1).ne.0) call abort
60 a(1:2) = nan
61 ia = minloc (a, mask = l)
62 if (ia(1).ne.0) call abort
63 ia = minloc (a, mask = l2)
64 if (ia(1).ne.0) call abort
65 a(2) = 1.0
66 ia = minloc (a, mask = l)
67 if (ia(1).ne.0) call abort
68 ia = minloc (a, mask = l2)
69 if (ia(1).ne.0) call abort
70 a(2) = minf
71 ia = minloc (a, mask = l)
72 if (ia(1).ne.0) call abort
73 ia = minloc (a, mask = l2)
74 if (ia(1).ne.0) call abort
75 c(:) = nan
76 ia = minloc (c, mask = l)
77 if (ia(1).ne.0) call abort
78 ia = minloc (c, mask = l2)
79 if (ia(1).ne.0) call abort
80 c(:) = pinf
81 ia = minloc (c, mask = l)
82 if (ia(1).ne.0) call abort
83 ia = minloc (c, mask = l2)
84 if (ia(1).ne.0) call abort
85 c(1:2) = nan
86 ia = minloc (c, mask = l)
87 if (ia(1).ne.0) call abort
88 ia = minloc (c, mask = l2)
89 if (ia(1).ne.0) call abort
90 c(2) = 1.0
91 ia = minloc (c, mask = l)
92 if (ia(1).ne.0) call abort
93 ia = minloc (c, mask = l2)
94 if (ia(1).ne.0) call abort
95 c(2) = minf
96 ia = minloc (c, mask = l)
97 if (ia(1).ne.0) call abort
98 ia = minloc (c, mask = l2)
99 if (ia(1).ne.0) call abort
100 l = .true.
101 l2(:) = .true.
102 a(:) = nan
103 ia = minloc (a, mask = l)
104 if (ia(1).ne.1) call abort
105 ia = minloc (a, mask = l2)
106 if (ia(1).ne.1) call abort
107 a(:) = pinf
108 ia = minloc (a, mask = l)
109 if (ia(1).ne.1) call abort
110 ia = minloc (a, mask = l2)
111 if (ia(1).ne.1) call abort
112 a(1:2) = nan
113 ia = minloc (a, mask = l)
114 if (ia(1).ne.3) call abort
115 ia = minloc (a, mask = l2)
116 if (ia(1).ne.3) call abort
117 a(2) = 1.0
118 ia = minloc (a, mask = l)
119 if (ia(1).ne.2) call abort
120 ia = minloc (a, mask = l2)
121 if (ia(1).ne.2) call abort
122 a(2) = minf
123 ia = minloc (a, mask = l)
124 if (ia(1).ne.2) call abort
125 ia = minloc (a, mask = l2)
126 if (ia(1).ne.2) call abort
127 c(:) = nan
128 ia = minloc (c, mask = l)
129 if (ia(1).ne.1) call abort
130 ia = minloc (c, mask = l2)
131 if (ia(1).ne.1) call abort
132 c(:) = pinf
133 ia = minloc (c, mask = l)
134 if (ia(1).ne.1) call abort
135 ia = minloc (c, mask = l2)
136 if (ia(1).ne.1) call abort
137 c(1:2) = nan
138 ia = minloc (c, mask = l)
139 if (ia(1).ne.3) call abort
140 ia = minloc (c, mask = l2)
141 if (ia(1).ne.3) call abort
142 c(2) = 1.0
143 ia = minloc (c, mask = l)
144 if (ia(1).ne.2) call abort
145 ia = minloc (c, mask = l2)
146 if (ia(1).ne.2) call abort
147 c(2) = minf
148 ia = minloc (c, mask = l)
149 if (ia(1).ne.2) call abort
150 ia = minloc (c, mask = l2)
151 if (ia(1).ne.2) call abort
152 deallocate (c)
153 allocate (c(-2:-3))
154 ia = minloc (c)
155 if (ia(1).ne.0) call abort