summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/scalar_mask_2.f90
blob: 967ac5c22c2100b2b546d66176ceff921553aa10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
! { dg-do run { xfail spu-*-* } }
! FAILs on SPU because of rounding error reading kinds.h
program main
  ! Test scalar masks for different intrinsics.
  real, dimension(2,2) :: a
  logical(kind=2) :: lo
  lo = .false.
  a(1,1) = 1.
  a(1,2) = -1.
  a(2,1) = 13.
  a(2,2) = -31.
  if (any (minloc (a, lo) /= 0)) call abort
  if (any (minloc (a, .true.) /= (/ 2, 2 /))) call abort
  if (any (minloc(a, 1, .true.) /= (/ 1, 2/))) call abort
  if (any (minloc(a, 1, lo ) /= (/ 0, 0/))) call abort

  if (any (maxloc (a, lo) /= 0)) call abort
  if (any (maxloc (a, .true.) /= (/ 2,1 /))) call abort
  if (any (maxloc(a, 1, .true.) /= (/ 2, 1/))) call abort
  if (any (maxloc(a, 1, lo) /= (/ 0, 0/))) call abort

  if (any (maxval(a, 1, lo) /= -HUGE(a))) call abort
  if (any (maxval(a, 1, .true.) /= (/13., -1./))) call abort
  if (any (minval(a, 1, lo) /= HUGE(a))) call abort
  if (any (minval(a, 1, .true.) /= (/1., -31./))) call abort

  if (any (product(a, 1, .true.) /= (/13., 31./))) call abort
  if (any (product(a, 1, lo ) /= (/1., 1./))) call abort

  if (any (sum(a, 1, .true.) /= (/14., -32./))) call abort
  if (any (sum(a, 1, lo) /= (/0., 0./))) call abort

end program main