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