The following patch adds testcase coverage for the 3 recently fixed
libgfortran PRs.
On trunk before those fixes I'm getting with -m32
FAIL: gfortran.dg/pr120152_1.f90 -O0 (test for excess errors)
FAIL: gfortran.dg/pr120152_1.f90 -Os (test for excess errors)
and with -m64
FAIL: gfortran.dg/pr120152_1.f90 -O0 (test for excess errors)
FAIL: gfortran.dg/pr120152_1.f90 -Os (test for excess errors)
FAIL: gfortran.dg/pr120152_2.f90 -O0 (test for excess errors)
FAIL: gfortran.dg/pr120152_2.f90 -Os (test for excess errors)
FAIL: gfortran.dg/pr120153.f90 -O0 (test for excess errors)
FAIL: gfortran.dg/pr120153.f90 -O1 (test for excess errors)
FAIL: gfortran.dg/pr120153.f90 -O2 (test for excess errors)
FAIL: gfortran.dg/pr120153.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors)
FAIL: gfortran.dg/pr120153.f90 -O3 -g (test for excess errors)
FAIL: gfortran.dg/pr120153.f90 -Os (test for excess errors)
FAIL: gfortran.dg/pr120158.f90 -O0 execution test
FAIL: gfortran.dg/pr120158.f90 -O1 execution test
FAIL: gfortran.dg/pr120158.f90 -O2 execution test
FAIL: gfortran.dg/pr120158.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test
FAIL: gfortran.dg/pr120158.f90 -O3 -g execution test
FAIL: gfortran.dg/pr120158.f90 -Os execution test
On latest trunk everything PASSes.
2025-05-08 Jakub Jelinek <jakub@redhat.com>
PR libfortran/120152
PR libfortran/120153
PR libfortran/120158
* gfortran.dg/pr120152_1.f90: New test.
* gfortran.dg/pr120152_2.f90: New test.
* gfortran.dg/pr120153.f90: New test.
* gfortran.dg/pr120158.f90: New test.
(cherry picked from commit
66f5f03853035cc917627e7d044bff8ccd9eca3f)
--- /dev/null
+! PR libfortran/120152
+! { dg-do run }
+
+subroutine f1
+ integer(kind=8) :: a (10, 10, 10), b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 8, .true.)
+end
+subroutine f2
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 4, .true.)
+end
+subroutine f3
+ integer(kind=8) :: a (10, 10, 10), b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=8, back=.true.)
+end
+subroutine f4
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=4, back=.true.)
+end
+subroutine f5
+ integer(kind=8) :: a (10, 10, 10), b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 8, .true.)
+end
+subroutine f6
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 4, .true.)
+end
+program pr120152
+ call f1
+ call f2
+ call f3
+ call f4
+ call f5
+ call f6
+end
--- /dev/null
+! PR libfortran/120152
+! { dg-do run { target fortran_large_int } }
+
+subroutine f1
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=8) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 8, .true.)
+end
+subroutine f2
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 4, .true.)
+end
+subroutine f3
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=8) :: b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=8, back=.true.)
+end
+subroutine f4
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=4, back=.true.)
+end
+subroutine f5
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=8) :: b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 8, .true.)
+end
+subroutine f6
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 4, .true.)
+end
+subroutine f7
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 16, .true.)
+end
+subroutine f8
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=16, back=.true.)
+end
+subroutine f9
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 16, .true.)
+end
+program pr120152
+ call f1
+ call f2
+ call f3
+ call f4
+ call f5
+ call f6
+ call f7
+ call f8
+ call f9
+end
--- /dev/null
+! PR libfortran/120153
+! { dg-do run { target fortran_large_int } }
+! { dg-additional-options "-funsigned" }
+
+subroutine f1
+ unsigned(kind=16) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0u_16
+ c = .true.
+ b = maxloc (a, 2, c, 16, .true.)
+end
+subroutine f2
+ unsigned(kind=16) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ a = 0u_16
+ b = maxloc (a, 2, kind=16, back=.true.)
+end
+subroutine f3
+ unsigned(kind=16) :: a (10, 10, 10)
+ integer(kind=8) :: b (10, 10)
+ logical :: c
+ a = 0u_16
+ c = .false.
+ b = maxloc (a, 2, c, 16, .true.)
+end
+subroutine f4
+ unsigned(kind=16) :: a (5, 5, 5)
+ call random_number (a)
+end
+program pr120153
+ call f1
+ call f2
+ call f3
+ call f4
+end
--- /dev/null
+! PR libfortran/120158
+! { dg-do run { target fortran_large_int } }
+! { dg-additional-options "-funsigned" }
+
+ unsigned(kind=8) :: a(10, 10, 10), b(10, 10)
+ integer(kind=8) :: c(10, 10), d(10, 10)
+ a = 0u_8
+ if (maxval (a) .ne. 0u_8) stop 1
+ b = maxval (a, 1)
+ if (any (b .ne. 0u_8)) stop 2
+ c = maxloc (a, 1)
+ d = maxloc (a, 2, back=.true.)
+ if (any (c .ne. 1)) stop 3
+ if (any (d .ne. 10)) stop 4
+end