aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2020-09-03 20:33:14 +0200
committerHarald Anlauf <anlauf@gmx.de>2020-09-03 20:33:14 +0200
commit8eeeecbcc17041fdfd3ccc928161ae86e7f9b456 (patch)
tree03d0de302626130b582dc2597059889d8b87d245 /gcc
parent753b4679bc46f6806cf45d9afc3783c6d3b63589 (diff)
downloadgcc-8eeeecbcc17041fdfd3ccc928161ae86e7f9b456.zip
gcc-8eeeecbcc17041fdfd3ccc928161ae86e7f9b456.tar.gz
gcc-8eeeecbcc17041fdfd3ccc928161ae86e7f9b456.tar.bz2
PR fortran/96890 - Wrong answer with intrinsic IALL
The IALL intrinsic would always return 0 when the DIM and MASK arguments were present since the initial value of repeated BIT-AND operations was set to 0 instead of -1. libgfortran/ChangeLog: * m4/iall.m4: Initial value for result should be -1. * generated/iall_i1.c (miall_i1): Generated. * generated/iall_i16.c (miall_i16): Likewise. * generated/iall_i2.c (miall_i2): Likewise. * generated/iall_i4.c (miall_i4): Likewise. * generated/iall_i8.c (miall_i8): Likewise. gcc/testsuite/ChangeLog: * gfortran.dg/iall_masked.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gfortran.dg/iall_masked.f9022
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/iall_masked.f90 b/gcc/testsuite/gfortran.dg/iall_masked.f90
new file mode 100644
index 0000000..33cc410
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/iall_masked.f90
@@ -0,0 +1,22 @@
+! { dg-do run }
+! PR fortran/96890 - Wrong answer with intrinsic IALL
+program p
+ implicit none
+ integer :: iarr1(0), iarr2(2,2), iarr3(2,2,2)
+ logical :: mask1(0), mask2(2,2), mask3(2,2,2)
+
+ if ( iall(iarr1, mask1) /= -1 ) stop 1
+ if ( iall(iarr1, 1, mask1) /= -1 ) stop 2
+
+ iarr2 = reshape ([ 1, 2, 3, 4 ], shape (iarr2))
+ mask2 = reshape ([ .true., .false., .true., .false. ], shape (mask2))
+
+ if (any (iall(iarr2, 2, mask2) /= [1,-1]) ) stop 3
+
+ iarr3 = reshape ([ 1, 2, 3, 4, &
+ 5, 6, 7, 8 ], shape (iarr3))
+ mask3 = reshape ([ .true., .false., .true., .false.,&
+ .true., .false., .true., .false. ], shape (iarr3))
+
+ if (any (iall(iarr3, 2, mask3) /= reshape ([1,-1,5,-1],[2,2]))) stop 4
+end