From: Thomas Koenig Date: Mon, 31 Jul 2017 09:34:36 +0000 (+0000) Subject: re PR fortran/81581 (runtime checks for DIM argument of intrinsic SUM missing) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cfdf6ff61b8107d124f41c426d65acf8b5ad8cf5;p=gcc.git re PR fortran/81581 (runtime checks for DIM argument of intrinsic SUM missing) 2017-07-31 Thomas Koenig PR fortran/81581 * m4/ifuntion.m4 (name`'rtype_qual`_'atype_code): Perform check for dim. (`m'name`'rtype_qual`_'atype_code): Likewise. Change type of rank and tim to index_type. (`s'name`'rtype_qual`_'atype_code): Perform check for dim. * generated/iall_i16.c: Regenerated. * generated/iall_i1.c: Regenerated. * generated/iall_i2.c: Regenerated. * generated/iall_i4.c: Regenerated. * generated/iall_i8.c: Regenerated. * generated/iany_i16.c: Regenerated. * generated/iany_i1.c: Regenerated. * generated/iany_i2.c: Regenerated. * generated/iany_i4.c: Regenerated. * generated/iany_i8.c: Regenerated. * generated/iparity_i16.c: Regenerated. * generated/iparity_i1.c: Regenerated. * generated/iparity_i2.c: Regenerated. * generated/iparity_i4.c: Regenerated. * generated/iparity_i8.c: Regenerated. * generated/maxloc1_16_i16.c: Regenerated. * generated/maxloc1_16_i1.c: Regenerated. * generated/maxloc1_16_i2.c: Regenerated. * generated/maxloc1_16_i4.c: Regenerated. * generated/maxloc1_16_i8.c: Regenerated. * generated/maxloc1_16_r10.c: Regenerated. * generated/maxloc1_16_r16.c: Regenerated. * generated/maxloc1_16_r4.c: Regenerated. * generated/maxloc1_16_r8.c: Regenerated. * generated/maxloc1_4_i16.c: Regenerated. * generated/maxloc1_4_i1.c: Regenerated. * generated/maxloc1_4_i2.c: Regenerated. * generated/maxloc1_4_i4.c: Regenerated. * generated/maxloc1_4_i8.c: Regenerated. * generated/maxloc1_4_r10.c: Regenerated. * generated/maxloc1_4_r16.c: Regenerated. * generated/maxloc1_4_r4.c: Regenerated. * generated/maxloc1_4_r8.c: Regenerated. * generated/maxloc1_8_i16.c: Regenerated. * generated/maxloc1_8_i1.c: Regenerated. * generated/maxloc1_8_i2.c: Regenerated. * generated/maxloc1_8_i4.c: Regenerated. * generated/maxloc1_8_i8.c: Regenerated. * generated/maxloc1_8_r10.c: Regenerated. * generated/maxloc1_8_r16.c: Regenerated. * generated/maxloc1_8_r4.c: Regenerated. * generated/maxloc1_8_r8.c: Regenerated. * generated/maxval_i16.c: Regenerated. * generated/maxval_i1.c: Regenerated. * generated/maxval_i2.c: Regenerated. * generated/maxval_i4.c: Regenerated. * generated/maxval_i8.c: Regenerated. * generated/maxval_r10.c: Regenerated. * generated/maxval_r16.c: Regenerated. * generated/maxval_r4.c: Regenerated. * generated/maxval_r8.c: Regenerated. * generated/minloc1_16_i16.c: Regenerated. * generated/minloc1_16_i1.c: Regenerated. * generated/minloc1_16_i2.c: Regenerated. * generated/minloc1_16_i4.c: Regenerated. * generated/minloc1_16_i8.c: Regenerated. * generated/minloc1_16_r10.c: Regenerated. * generated/minloc1_16_r16.c: Regenerated. * generated/minloc1_16_r4.c: Regenerated. * generated/minloc1_16_r8.c: Regenerated. * generated/minloc1_4_i16.c: Regenerated. * generated/minloc1_4_i1.c: Regenerated. * generated/minloc1_4_i2.c: Regenerated. * generated/minloc1_4_i4.c: Regenerated. * generated/minloc1_4_i8.c: Regenerated. * generated/minloc1_4_r10.c: Regenerated. * generated/minloc1_4_r16.c: Regenerated. * generated/minloc1_4_r4.c: Regenerated. * generated/minloc1_4_r8.c: Regenerated. * generated/minloc1_8_i16.c: Regenerated. * generated/minloc1_8_i1.c: Regenerated. * generated/minloc1_8_i2.c: Regenerated. * generated/minloc1_8_i4.c: Regenerated. * generated/minloc1_8_i8.c: Regenerated. * generated/minloc1_8_r10.c: Regenerated. * generated/minloc1_8_r16.c: Regenerated. * generated/minloc1_8_r4.c: Regenerated. * generated/minloc1_8_r8.c: Regenerated. * generated/minval_i16.c: Regenerated. * generated/minval_i1.c: Regenerated. * generated/minval_i2.c: Regenerated. * generated/minval_i4.c: Regenerated. * generated/minval_i8.c: Regenerated. * generated/minval_r10.c: Regenerated. * generated/minval_r16.c: Regenerated. * generated/minval_r4.c: Regenerated. * generated/minval_r8.c: Regenerated. * generated/norm2_r10.c: Regenerated. * generated/norm2_r16.c: Regenerated. * generated/norm2_r4.c: Regenerated. * generated/norm2_r8.c: Regenerated. * generated/parity_l16.c: Regenerated. * generated/parity_l1.c: Regenerated. * generated/parity_l2.c: Regenerated. * generated/parity_l4.c: Regenerated. * generated/parity_l8.c: Regenerated. * generated/product_c10.c: Regenerated. * generated/product_c16.c: Regenerated. * generated/product_c4.c: Regenerated. * generated/product_c8.c: Regenerated. * generated/product_i16.c: Regenerated. * generated/product_i1.c: Regenerated. * generated/product_i2.c: Regenerated. * generated/product_i4.c: Regenerated. * generated/product_i8.c: Regenerated. * generated/product_r10.c: Regenerated. * generated/product_r16.c: Regenerated. * generated/product_r4.c: Regenerated. * generated/product_r8.c: Regenerated. * generated/sum_c10.c: Regenerated. * generated/sum_c16.c: Regenerated. * generated/sum_c4.c: Regenerated. * generated/sum_c8.c: Regenerated. * generated/sum_i16.c: Regenerated. * generated/sum_i1.c: Regenerated. * generated/sum_i2.c: Regenerated. * generated/sum_i4.c: Regenerated. * generated/sum_i8.c: Regenerated. * generated/sum_r10.c: Regenerated. * generated/sum_r16.c: Regenerated. * generated/sum_r4.c: Regenerated. * generated/sum_r8.c: Regenerated. 2017-07-31 Thomas Koenig PR fortran/81581 * gfortran.dg/dim_sum_1.f90: New test case. * gfortran.dg/dim_sum_2.f90: New test case. * gfortran.dg/dim_sum_3.f90: New test case. From-SVN: r250735 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f77d27ce53d..f7e647c1863 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-07-31 Thomas Koenig + + PR fortran/81581 + * gfortran.dg/dim_sum_1.f90: New test case. + * gfortran.dg/dim_sum_2.f90: New test case. + * gfortran.dg/dim_sum_3.f90: New test case. + 2017-07-31 Martin Liska * gcc.dg/builtin-unreachable-6.c: Update scanned patterns. diff --git a/gcc/testsuite/gfortran.dg/dim_sum_1.f90 b/gcc/testsuite/gfortran.dg/dim_sum_1.f90 new file mode 100644 index 00000000000..b2fb94312d3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dim_sum_1.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! { dg-shouldfail "Dim argument incorrect in SUM intrinsic: is 5, should be between 1 and 2" } + +program summation + + integer, parameter :: n1=5, n2=7 + integer, dimension(1:n1,1:n2) :: arr + integer, dimension(1:n1) :: r2 + integer, dimension(1:n2) :: r1 + integer :: i,j + character(len=80) :: c1, c2 + character(len=50) :: fmt = '(10I5)' + do j=1,n2 + do i=1,n1 + arr(i,j) = i+j*10 + end do + end do + + r1 = sum(arr,dim=1) + write (unit=c2, fmt=fmt) r1 + call print_sum(1,c1) + if (c1 /= c2) call abort + r2 = sum(arr,dim=2) + write (unit=c2, fmt=fmt) r2 + call print_sum(2,c1) + if (c1 /= c2) call abort + call print_sum(5,c1) + +contains + + subroutine print_sum(d, c) + integer, intent(in) :: d + character(len=80), intent(out) :: c + write (unit=c, fmt=fmt) sum(arr,dim=d) + end subroutine + +end diff --git a/gcc/testsuite/gfortran.dg/dim_sum_2.f90 b/gcc/testsuite/gfortran.dg/dim_sum_2.f90 new file mode 100644 index 00000000000..6290444a81d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dim_sum_2.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! { dg-shouldfail "Dim argument incorrect in SUM intrinsic: is 5, should be between 1 and 2" } + +program summation + + integer, parameter :: n1=5, n2=7 + integer, dimension(1:n1,1:n2) :: arr + integer, dimension(1:n1) :: r2 + integer, dimension(1:n2) :: r1 + integer :: i,j + character(len=80) :: c1, c2 + character(len=50) :: fmt = '(10I5)' + do j=1,n2 + do i=1,n1 + arr(i,j) = i+j*10 + end do + end do + + r1 = sum(arr,dim=1,mask=arr>23) + write (unit=c2, fmt=fmt) r1 + call print_sum(1,c1) + if (c1 /= c2) call abort + r2 = sum(arr,dim=2,mask=arr>23) + write (unit=c2, fmt=fmt) r2 + call print_sum(2,c1) + if (c1 /= c2) call abort + call print_sum(5,c1) + +contains + + subroutine print_sum(d, c) + integer, intent(in) :: d + character(len=80), intent(out) :: c + write (unit=c, fmt=fmt) sum(arr,dim=d,mask=arr>23) + end subroutine + +end diff --git a/gcc/testsuite/gfortran.dg/dim_sum_3.f90 b/gcc/testsuite/gfortran.dg/dim_sum_3.f90 new file mode 100644 index 00000000000..2661b3700fd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dim_sum_3.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! { dg-shouldfail "Dim argument incorrect in SUM intrinsic: is 5, should be between 1 and 2" } + +program summation + + integer, parameter :: n1=5, n2=7 + integer, dimension(1:n1,1:n2) :: arr + integer, dimension(1:n1) :: r2 + integer, dimension(1:n2) :: r1 + integer :: i,j + character(len=80) :: c1, c2 + character(len=50) :: fmt = '(10I5)' + do j=1,n2 + do i=1,n1 + arr(i,j) = i+j*10 + end do + end do + + r1 = sum(arr,dim=1,mask=.true.) + write (unit=c2, fmt=fmt) r1 + call print_sum(1,c1) + if (c1 /= c2) call abort + r2 = sum(arr,dim=2,mask=.true.) + write (unit=c2, fmt=fmt) r2 + call print_sum(2,c1) + if (c1 /= c2) call abort + call print_sum(5,c1) + +contains + + subroutine print_sum(d, c) + integer, intent(in) :: d + character(len=80), intent(out) :: c + write (unit=c, fmt=fmt) sum(arr,dim=d,mask=.true.) + end subroutine + +end diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 5d145d09794..3b3cf7f86f9 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,134 @@ +2017-07-31 Thomas Koenig + + PR fortran/81581 + * m4/ifuntion.m4 (name`'rtype_qual`_'atype_code): Perform check + for dim. + (`m'name`'rtype_qual`_'atype_code): Likewise. Change type of rank + and tim to index_type. + (`s'name`'rtype_qual`_'atype_code): Perform check for dim. + * generated/iall_i16.c: Regenerated. + * generated/iall_i1.c: Regenerated. + * generated/iall_i2.c: Regenerated. + * generated/iall_i4.c: Regenerated. + * generated/iall_i8.c: Regenerated. + * generated/iany_i16.c: Regenerated. + * generated/iany_i1.c: Regenerated. + * generated/iany_i2.c: Regenerated. + * generated/iany_i4.c: Regenerated. + * generated/iany_i8.c: Regenerated. + * generated/iparity_i16.c: Regenerated. + * generated/iparity_i1.c: Regenerated. + * generated/iparity_i2.c: Regenerated. + * generated/iparity_i4.c: Regenerated. + * generated/iparity_i8.c: Regenerated. + * generated/maxloc1_16_i16.c: Regenerated. + * generated/maxloc1_16_i1.c: Regenerated. + * generated/maxloc1_16_i2.c: Regenerated. + * generated/maxloc1_16_i4.c: Regenerated. + * generated/maxloc1_16_i8.c: Regenerated. + * generated/maxloc1_16_r10.c: Regenerated. + * generated/maxloc1_16_r16.c: Regenerated. + * generated/maxloc1_16_r4.c: Regenerated. + * generated/maxloc1_16_r8.c: Regenerated. + * generated/maxloc1_4_i16.c: Regenerated. + * generated/maxloc1_4_i1.c: Regenerated. + * generated/maxloc1_4_i2.c: Regenerated. + * generated/maxloc1_4_i4.c: Regenerated. + * generated/maxloc1_4_i8.c: Regenerated. + * generated/maxloc1_4_r10.c: Regenerated. + * generated/maxloc1_4_r16.c: Regenerated. + * generated/maxloc1_4_r4.c: Regenerated. + * generated/maxloc1_4_r8.c: Regenerated. + * generated/maxloc1_8_i16.c: Regenerated. + * generated/maxloc1_8_i1.c: Regenerated. + * generated/maxloc1_8_i2.c: Regenerated. + * generated/maxloc1_8_i4.c: Regenerated. + * generated/maxloc1_8_i8.c: Regenerated. + * generated/maxloc1_8_r10.c: Regenerated. + * generated/maxloc1_8_r16.c: Regenerated. + * generated/maxloc1_8_r4.c: Regenerated. + * generated/maxloc1_8_r8.c: Regenerated. + * generated/maxval_i16.c: Regenerated. + * generated/maxval_i1.c: Regenerated. + * generated/maxval_i2.c: Regenerated. + * generated/maxval_i4.c: Regenerated. + * generated/maxval_i8.c: Regenerated. + * generated/maxval_r10.c: Regenerated. + * generated/maxval_r16.c: Regenerated. + * generated/maxval_r4.c: Regenerated. + * generated/maxval_r8.c: Regenerated. + * generated/minloc1_16_i16.c: Regenerated. + * generated/minloc1_16_i1.c: Regenerated. + * generated/minloc1_16_i2.c: Regenerated. + * generated/minloc1_16_i4.c: Regenerated. + * generated/minloc1_16_i8.c: Regenerated. + * generated/minloc1_16_r10.c: Regenerated. + * generated/minloc1_16_r16.c: Regenerated. + * generated/minloc1_16_r4.c: Regenerated. + * generated/minloc1_16_r8.c: Regenerated. + * generated/minloc1_4_i16.c: Regenerated. + * generated/minloc1_4_i1.c: Regenerated. + * generated/minloc1_4_i2.c: Regenerated. + * generated/minloc1_4_i4.c: Regenerated. + * generated/minloc1_4_i8.c: Regenerated. + * generated/minloc1_4_r10.c: Regenerated. + * generated/minloc1_4_r16.c: Regenerated. + * generated/minloc1_4_r4.c: Regenerated. + * generated/minloc1_4_r8.c: Regenerated. + * generated/minloc1_8_i16.c: Regenerated. + * generated/minloc1_8_i1.c: Regenerated. + * generated/minloc1_8_i2.c: Regenerated. + * generated/minloc1_8_i4.c: Regenerated. + * generated/minloc1_8_i8.c: Regenerated. + * generated/minloc1_8_r10.c: Regenerated. + * generated/minloc1_8_r16.c: Regenerated. + * generated/minloc1_8_r4.c: Regenerated. + * generated/minloc1_8_r8.c: Regenerated. + * generated/minval_i16.c: Regenerated. + * generated/minval_i1.c: Regenerated. + * generated/minval_i2.c: Regenerated. + * generated/minval_i4.c: Regenerated. + * generated/minval_i8.c: Regenerated. + * generated/minval_r10.c: Regenerated. + * generated/minval_r16.c: Regenerated. + * generated/minval_r4.c: Regenerated. + * generated/minval_r8.c: Regenerated. + * generated/norm2_r10.c: Regenerated. + * generated/norm2_r16.c: Regenerated. + * generated/norm2_r4.c: Regenerated. + * generated/norm2_r8.c: Regenerated. + * generated/parity_l16.c: Regenerated. + * generated/parity_l1.c: Regenerated. + * generated/parity_l2.c: Regenerated. + * generated/parity_l4.c: Regenerated. + * generated/parity_l8.c: Regenerated. + * generated/product_c10.c: Regenerated. + * generated/product_c16.c: Regenerated. + * generated/product_c4.c: Regenerated. + * generated/product_c8.c: Regenerated. + * generated/product_i16.c: Regenerated. + * generated/product_i1.c: Regenerated. + * generated/product_i2.c: Regenerated. + * generated/product_i4.c: Regenerated. + * generated/product_i8.c: Regenerated. + * generated/product_r10.c: Regenerated. + * generated/product_r16.c: Regenerated. + * generated/product_r4.c: Regenerated. + * generated/product_r8.c: Regenerated. + * generated/sum_c10.c: Regenerated. + * generated/sum_c16.c: Regenerated. + * generated/sum_c4.c: Regenerated. + * generated/sum_c8.c: Regenerated. + * generated/sum_i16.c: Regenerated. + * generated/sum_i1.c: Regenerated. + * generated/sum_i2.c: Regenerated. + * generated/sum_i4.c: Regenerated. + * generated/sum_i8.c: Regenerated. + * generated/sum_r10.c: Regenerated. + * generated/sum_r16.c: Regenerated. + * generated/sum_r4.c: Regenerated. + * generated/sum_r8.c: Regenerated. + 2017-07-24 Thomas Koenig PR fortran/80365 diff --git a/libgfortran/generated/iall_i1.c b/libgfortran/generated/iall_i1.c index 619c833c33b..3453fd20c0f 100644 --- a/libgfortran/generated/iall_i1.c +++ b/libgfortran/generated/iall_i1.c @@ -52,8 +52,15 @@ iall_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miall_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iall_i16.c b/libgfortran/generated/iall_i16.c index 4d37d9c80bf..9f6747aa99d 100644 --- a/libgfortran/generated/iall_i16.c +++ b/libgfortran/generated/iall_i16.c @@ -52,8 +52,15 @@ iall_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miall_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iall_i2.c b/libgfortran/generated/iall_i2.c index 283ceffb2c9..5ac86ab9cea 100644 --- a/libgfortran/generated/iall_i2.c +++ b/libgfortran/generated/iall_i2.c @@ -52,8 +52,15 @@ iall_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miall_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iall_i4.c b/libgfortran/generated/iall_i4.c index ef0ac58d3b9..0d3ba8aebca 100644 --- a/libgfortran/generated/iall_i4.c +++ b/libgfortran/generated/iall_i4.c @@ -52,8 +52,15 @@ iall_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miall_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iall_i8.c b/libgfortran/generated/iall_i8.c index ef780b01c71..d3424a07df7 100644 --- a/libgfortran/generated/iall_i8.c +++ b/libgfortran/generated/iall_i8.c @@ -52,8 +52,15 @@ iall_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miall_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iany_i1.c b/libgfortran/generated/iany_i1.c index b60d4f2d383..1009c1803e2 100644 --- a/libgfortran/generated/iany_i1.c +++ b/libgfortran/generated/iany_i1.c @@ -52,8 +52,15 @@ iany_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miany_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iany_i16.c b/libgfortran/generated/iany_i16.c index f8fb40acd1c..6910040aa02 100644 --- a/libgfortran/generated/iany_i16.c +++ b/libgfortran/generated/iany_i16.c @@ -52,8 +52,15 @@ iany_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miany_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iany_i2.c b/libgfortran/generated/iany_i2.c index ef931b35a57..09d8cc4a5a5 100644 --- a/libgfortran/generated/iany_i2.c +++ b/libgfortran/generated/iany_i2.c @@ -52,8 +52,15 @@ iany_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miany_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iany_i4.c b/libgfortran/generated/iany_i4.c index d0ecaef23d0..4d18e791835 100644 --- a/libgfortran/generated/iany_i4.c +++ b/libgfortran/generated/iany_i4.c @@ -52,8 +52,15 @@ iany_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miany_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iany_i8.c b/libgfortran/generated/iany_i8.c index c963165cf18..e857424d750 100644 --- a/libgfortran/generated/iany_i8.c +++ b/libgfortran/generated/iany_i8.c @@ -52,8 +52,15 @@ iany_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miany_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iparity_i1.c b/libgfortran/generated/iparity_i1.c index 18e9fc24be1..ff5fbeb496b 100644 --- a/libgfortran/generated/iparity_i1.c +++ b/libgfortran/generated/iparity_i1.c @@ -52,8 +52,15 @@ iparity_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miparity_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iparity_i16.c b/libgfortran/generated/iparity_i16.c index 5b8ea697483..fcd7bef68a1 100644 --- a/libgfortran/generated/iparity_i16.c +++ b/libgfortran/generated/iparity_i16.c @@ -52,8 +52,15 @@ iparity_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miparity_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iparity_i2.c b/libgfortran/generated/iparity_i2.c index 0076667caba..9aa34e07780 100644 --- a/libgfortran/generated/iparity_i2.c +++ b/libgfortran/generated/iparity_i2.c @@ -52,8 +52,15 @@ iparity_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miparity_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iparity_i4.c b/libgfortran/generated/iparity_i4.c index 20798423f5c..71835df9f3e 100644 --- a/libgfortran/generated/iparity_i4.c +++ b/libgfortran/generated/iparity_i4.c @@ -52,8 +52,15 @@ iparity_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miparity_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/iparity_i8.c b/libgfortran/generated/iparity_i8.c index 60e390e99b7..e04360c0f54 100644 --- a/libgfortran/generated/iparity_i8.c +++ b/libgfortran/generated/iparity_i8.c @@ -52,8 +52,15 @@ iparity_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ miparity_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_i1.c b/libgfortran/generated/maxloc1_16_i1.c index 48f2fc01e59..f6bab618c7a 100644 --- a/libgfortran/generated/maxloc1_16_i1.c +++ b/libgfortran/generated/maxloc1_16_i1.c @@ -52,8 +52,15 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i1 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_i16.c b/libgfortran/generated/maxloc1_16_i16.c index 6c154fb84e7..b3b8b36826f 100644 --- a/libgfortran/generated/maxloc1_16_i16.c +++ b/libgfortran/generated/maxloc1_16_i16.c @@ -52,8 +52,15 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_i2.c b/libgfortran/generated/maxloc1_16_i2.c index 029e061e43c..fb38b2b43aa 100644 --- a/libgfortran/generated/maxloc1_16_i2.c +++ b/libgfortran/generated/maxloc1_16_i2.c @@ -52,8 +52,15 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i2 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_i4.c b/libgfortran/generated/maxloc1_16_i4.c index aceb7aeb69b..d17f4eb5d2a 100644 --- a/libgfortran/generated/maxloc1_16_i4.c +++ b/libgfortran/generated/maxloc1_16_i4.c @@ -52,8 +52,15 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i4 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c index 000a0cf599c..f0bd1ace0f3 100644 --- a/libgfortran/generated/maxloc1_16_i8.c +++ b/libgfortran/generated/maxloc1_16_i8.c @@ -52,8 +52,15 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_r10.c b/libgfortran/generated/maxloc1_16_r10.c index 53378d958e2..db8ff10eb2f 100644 --- a/libgfortran/generated/maxloc1_16_r10.c +++ b/libgfortran/generated/maxloc1_16_r10.c @@ -52,8 +52,15 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_r10 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_r16.c b/libgfortran/generated/maxloc1_16_r16.c index 4bdc4d66b89..1f48631547d 100644 --- a/libgfortran/generated/maxloc1_16_r16.c +++ b/libgfortran/generated/maxloc1_16_r16.c @@ -52,8 +52,15 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_r16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_r4.c b/libgfortran/generated/maxloc1_16_r4.c index 36d79e23ce3..c444f6b20c2 100644 --- a/libgfortran/generated/maxloc1_16_r4.c +++ b/libgfortran/generated/maxloc1_16_r4.c @@ -52,8 +52,15 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_r4 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_16_r8.c b/libgfortran/generated/maxloc1_16_r8.c index 3993f77619b..33205ff21a0 100644 --- a/libgfortran/generated/maxloc1_16_r8.c +++ b/libgfortran/generated/maxloc1_16_r8.c @@ -52,8 +52,15 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_r8 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_i1.c b/libgfortran/generated/maxloc1_4_i1.c index 05d2af4be3e..6e466e68fa1 100644 --- a/libgfortran/generated/maxloc1_4_i1.c +++ b/libgfortran/generated/maxloc1_4_i1.c @@ -52,8 +52,15 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i1 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c index 67e8a9ca2c7..dfff85b1151 100644 --- a/libgfortran/generated/maxloc1_4_i16.c +++ b/libgfortran/generated/maxloc1_4_i16.c @@ -52,8 +52,15 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_i2.c b/libgfortran/generated/maxloc1_4_i2.c index 60ceaa698f4..1006c0046f1 100644 --- a/libgfortran/generated/maxloc1_4_i2.c +++ b/libgfortran/generated/maxloc1_4_i2.c @@ -52,8 +52,15 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i2 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c index d2f30b7246a..4186654e169 100644 --- a/libgfortran/generated/maxloc1_4_i4.c +++ b/libgfortran/generated/maxloc1_4_i4.c @@ -52,8 +52,15 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c index 13a7dc6d34c..01cfa7336b8 100644 --- a/libgfortran/generated/maxloc1_4_i8.c +++ b/libgfortran/generated/maxloc1_4_i8.c @@ -52,8 +52,15 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_r10.c b/libgfortran/generated/maxloc1_4_r10.c index 204229293c4..2992e2bd99a 100644 --- a/libgfortran/generated/maxloc1_4_r10.c +++ b/libgfortran/generated/maxloc1_4_r10.c @@ -52,8 +52,15 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_r10 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_r16.c b/libgfortran/generated/maxloc1_4_r16.c index 95076481c10..325211a2ccf 100644 --- a/libgfortran/generated/maxloc1_4_r16.c +++ b/libgfortran/generated/maxloc1_4_r16.c @@ -52,8 +52,15 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_r16 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_r4.c b/libgfortran/generated/maxloc1_4_r4.c index 87c6ca5eb40..9f48540eca5 100644 --- a/libgfortran/generated/maxloc1_4_r4.c +++ b/libgfortran/generated/maxloc1_4_r4.c @@ -52,8 +52,15 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_r4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_4_r8.c b/libgfortran/generated/maxloc1_4_r8.c index a13986a1fa8..f5f4145a3c4 100644 --- a/libgfortran/generated/maxloc1_4_r8.c +++ b/libgfortran/generated/maxloc1_4_r8.c @@ -52,8 +52,15 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_r8 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_i1.c b/libgfortran/generated/maxloc1_8_i1.c index 71a5d97efe4..297a19b5775 100644 --- a/libgfortran/generated/maxloc1_8_i1.c +++ b/libgfortran/generated/maxloc1_8_i1.c @@ -52,8 +52,15 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i1 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c index 92cf55c4e2c..773e3df1636 100644 --- a/libgfortran/generated/maxloc1_8_i16.c +++ b/libgfortran/generated/maxloc1_8_i16.c @@ -52,8 +52,15 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_i2.c b/libgfortran/generated/maxloc1_8_i2.c index fd1063c5df1..204d01044cd 100644 --- a/libgfortran/generated/maxloc1_8_i2.c +++ b/libgfortran/generated/maxloc1_8_i2.c @@ -52,8 +52,15 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i2 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c index db82ae894ae..7c73244d39d 100644 --- a/libgfortran/generated/maxloc1_8_i4.c +++ b/libgfortran/generated/maxloc1_8_i4.c @@ -52,8 +52,15 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i4 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c index 43b4af14792..a8965871a50 100644 --- a/libgfortran/generated/maxloc1_8_i8.c +++ b/libgfortran/generated/maxloc1_8_i8.c @@ -52,8 +52,15 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_r10.c b/libgfortran/generated/maxloc1_8_r10.c index 9ba6cb950e4..4bc66cdd121 100644 --- a/libgfortran/generated/maxloc1_8_r10.c +++ b/libgfortran/generated/maxloc1_8_r10.c @@ -52,8 +52,15 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_r10 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_r16.c b/libgfortran/generated/maxloc1_8_r16.c index f7eb1ebf9be..959e3f98554 100644 --- a/libgfortran/generated/maxloc1_8_r16.c +++ b/libgfortran/generated/maxloc1_8_r16.c @@ -52,8 +52,15 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_r16 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_r4.c b/libgfortran/generated/maxloc1_8_r4.c index 67b455bb735..06849640a77 100644 --- a/libgfortran/generated/maxloc1_8_r4.c +++ b/libgfortran/generated/maxloc1_8_r4.c @@ -52,8 +52,15 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_r4 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxloc1_8_r8.c b/libgfortran/generated/maxloc1_8_r8.c index bd0913f4fea..ae40ff65ff9 100644 --- a/libgfortran/generated/maxloc1_8_r8.c +++ b/libgfortran/generated/maxloc1_8_r8.c @@ -52,8 +52,15 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_r8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_i1.c b/libgfortran/generated/maxval_i1.c index 90ddf350378..fe4733518e6 100644 --- a/libgfortran/generated/maxval_i1.c +++ b/libgfortran/generated/maxval_i1.c @@ -52,8 +52,15 @@ maxval_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_i16.c b/libgfortran/generated/maxval_i16.c index 6a54739e290..21174935b25 100644 --- a/libgfortran/generated/maxval_i16.c +++ b/libgfortran/generated/maxval_i16.c @@ -52,8 +52,15 @@ maxval_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_i2.c b/libgfortran/generated/maxval_i2.c index 3cdb5b9d3ed..9a5a6b876a4 100644 --- a/libgfortran/generated/maxval_i2.c +++ b/libgfortran/generated/maxval_i2.c @@ -52,8 +52,15 @@ maxval_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c index d7ae9951a4a..5451a4e565b 100644 --- a/libgfortran/generated/maxval_i4.c +++ b/libgfortran/generated/maxval_i4.c @@ -52,8 +52,15 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c index d622da09b27..93d81249d7b 100644 --- a/libgfortran/generated/maxval_i8.c +++ b/libgfortran/generated/maxval_i8.c @@ -52,8 +52,15 @@ maxval_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_r10.c b/libgfortran/generated/maxval_r10.c index 9c4c6fbb26c..d3b10d123c8 100644 --- a/libgfortran/generated/maxval_r10.c +++ b/libgfortran/generated/maxval_r10.c @@ -52,8 +52,15 @@ maxval_r10 (gfc_array_r10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarray, GFC_REAL_10 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_r16.c b/libgfortran/generated/maxval_r16.c index f10573233e3..32e935a2d09 100644 --- a/libgfortran/generated/maxval_r16.c +++ b/libgfortran/generated/maxval_r16.c @@ -52,8 +52,15 @@ maxval_r16 (gfc_array_r16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarray, GFC_REAL_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_r4.c b/libgfortran/generated/maxval_r4.c index 94d4f335a19..92627190558 100644 --- a/libgfortran/generated/maxval_r4.c +++ b/libgfortran/generated/maxval_r4.c @@ -52,8 +52,15 @@ maxval_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray, GFC_REAL_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/maxval_r8.c b/libgfortran/generated/maxval_r8.c index 5ba70b62edb..b12f34dd68a 100644 --- a/libgfortran/generated/maxval_r8.c +++ b/libgfortran/generated/maxval_r8.c @@ -52,8 +52,15 @@ maxval_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray, GFC_REAL_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_i1.c b/libgfortran/generated/minloc1_16_i1.c index bf6be092e85..b27e146c45f 100644 --- a/libgfortran/generated/minloc1_16_i1.c +++ b/libgfortran/generated/minloc1_16_i1.c @@ -52,8 +52,15 @@ minloc1_16_i1 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i1 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_i16.c b/libgfortran/generated/minloc1_16_i16.c index e4d9dab0b7f..be0cd693f14 100644 --- a/libgfortran/generated/minloc1_16_i16.c +++ b/libgfortran/generated/minloc1_16_i16.c @@ -52,8 +52,15 @@ minloc1_16_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_i2.c b/libgfortran/generated/minloc1_16_i2.c index 450142f7a82..4b9dcac503f 100644 --- a/libgfortran/generated/minloc1_16_i2.c +++ b/libgfortran/generated/minloc1_16_i2.c @@ -52,8 +52,15 @@ minloc1_16_i2 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i2 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_i4.c b/libgfortran/generated/minloc1_16_i4.c index e1ca90f803b..b305ac8ad47 100644 --- a/libgfortran/generated/minloc1_16_i4.c +++ b/libgfortran/generated/minloc1_16_i4.c @@ -52,8 +52,15 @@ minloc1_16_i4 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i4 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_i8.c b/libgfortran/generated/minloc1_16_i8.c index b5212041d73..6a60af9f845 100644 --- a/libgfortran/generated/minloc1_16_i8.c +++ b/libgfortran/generated/minloc1_16_i8.c @@ -52,8 +52,15 @@ minloc1_16_i8 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i8 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_r10.c b/libgfortran/generated/minloc1_16_r10.c index 880bb7e2986..bb5546f45c8 100644 --- a/libgfortran/generated/minloc1_16_r10.c +++ b/libgfortran/generated/minloc1_16_r10.c @@ -52,8 +52,15 @@ minloc1_16_r10 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_r10 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_r16.c b/libgfortran/generated/minloc1_16_r16.c index 4343508d4a0..636195e80ed 100644 --- a/libgfortran/generated/minloc1_16_r16.c +++ b/libgfortran/generated/minloc1_16_r16.c @@ -52,8 +52,15 @@ minloc1_16_r16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_r16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_r4.c b/libgfortran/generated/minloc1_16_r4.c index b2fb09c92e9..89f453fa0fa 100644 --- a/libgfortran/generated/minloc1_16_r4.c +++ b/libgfortran/generated/minloc1_16_r4.c @@ -52,8 +52,15 @@ minloc1_16_r4 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_r4 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_16_r8.c b/libgfortran/generated/minloc1_16_r8.c index f62cf337153..42ca7da88b2 100644 --- a/libgfortran/generated/minloc1_16_r8.c +++ b/libgfortran/generated/minloc1_16_r8.c @@ -52,8 +52,15 @@ minloc1_16_r8 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_r8 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_i1.c b/libgfortran/generated/minloc1_4_i1.c index 5bf2dbacdc4..3ff1eb16109 100644 --- a/libgfortran/generated/minloc1_4_i1.c +++ b/libgfortran/generated/minloc1_4_i1.c @@ -52,8 +52,15 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i1 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_i16.c b/libgfortran/generated/minloc1_4_i16.c index c8925879e9c..10f07a136e1 100644 --- a/libgfortran/generated/minloc1_4_i16.c +++ b/libgfortran/generated/minloc1_4_i16.c @@ -52,8 +52,15 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i16 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_i2.c b/libgfortran/generated/minloc1_4_i2.c index 42d5afaf3d2..344202db39e 100644 --- a/libgfortran/generated/minloc1_4_i2.c +++ b/libgfortran/generated/minloc1_4_i2.c @@ -52,8 +52,15 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i2 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_i4.c b/libgfortran/generated/minloc1_4_i4.c index 456ea792b3f..ac9d44c8ecf 100644 --- a/libgfortran/generated/minloc1_4_i4.c +++ b/libgfortran/generated/minloc1_4_i4.c @@ -52,8 +52,15 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_i8.c b/libgfortran/generated/minloc1_4_i8.c index a65195dcc3f..11d212062f9 100644 --- a/libgfortran/generated/minloc1_4_i8.c +++ b/libgfortran/generated/minloc1_4_i8.c @@ -52,8 +52,15 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i8 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_r10.c b/libgfortran/generated/minloc1_4_r10.c index b106e97dde8..3365e7ada6a 100644 --- a/libgfortran/generated/minloc1_4_r10.c +++ b/libgfortran/generated/minloc1_4_r10.c @@ -52,8 +52,15 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_r10 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_r16.c b/libgfortran/generated/minloc1_4_r16.c index b1ef3b3ee62..3b5989cce8f 100644 --- a/libgfortran/generated/minloc1_4_r16.c +++ b/libgfortran/generated/minloc1_4_r16.c @@ -52,8 +52,15 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_r16 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_r4.c b/libgfortran/generated/minloc1_4_r4.c index 9ddf490d68b..d79f905a659 100644 --- a/libgfortran/generated/minloc1_4_r4.c +++ b/libgfortran/generated/minloc1_4_r4.c @@ -52,8 +52,15 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_r4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_4_r8.c b/libgfortran/generated/minloc1_4_r8.c index 0619ac6f0a7..3175f331494 100644 --- a/libgfortran/generated/minloc1_4_r8.c +++ b/libgfortran/generated/minloc1_4_r8.c @@ -52,8 +52,15 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_r8 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_i1.c b/libgfortran/generated/minloc1_8_i1.c index 27c7fa9e350..bfd935444e6 100644 --- a/libgfortran/generated/minloc1_8_i1.c +++ b/libgfortran/generated/minloc1_8_i1.c @@ -52,8 +52,15 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i1 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_i16.c b/libgfortran/generated/minloc1_8_i16.c index 274b17e45f9..1fc912928f3 100644 --- a/libgfortran/generated/minloc1_8_i16.c +++ b/libgfortran/generated/minloc1_8_i16.c @@ -52,8 +52,15 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i16 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_i2.c b/libgfortran/generated/minloc1_8_i2.c index 416622c36e7..5cf6eed7e69 100644 --- a/libgfortran/generated/minloc1_8_i2.c +++ b/libgfortran/generated/minloc1_8_i2.c @@ -52,8 +52,15 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i2 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_i4.c b/libgfortran/generated/minloc1_8_i4.c index ff67899917c..8d7a8f3f8ec 100644 --- a/libgfortran/generated/minloc1_8_i4.c +++ b/libgfortran/generated/minloc1_8_i4.c @@ -52,8 +52,15 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i4 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_i8.c b/libgfortran/generated/minloc1_8_i8.c index c4247ac7f17..00352634052 100644 --- a/libgfortran/generated/minloc1_8_i8.c +++ b/libgfortran/generated/minloc1_8_i8.c @@ -52,8 +52,15 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_r10.c b/libgfortran/generated/minloc1_8_r10.c index c57f72aabe6..918c0b17388 100644 --- a/libgfortran/generated/minloc1_8_r10.c +++ b/libgfortran/generated/minloc1_8_r10.c @@ -52,8 +52,15 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_r10 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_r16.c b/libgfortran/generated/minloc1_8_r16.c index c1d2cd2a88e..c5b35955ac8 100644 --- a/libgfortran/generated/minloc1_8_r16.c +++ b/libgfortran/generated/minloc1_8_r16.c @@ -52,8 +52,15 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_r16 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_r4.c b/libgfortran/generated/minloc1_8_r4.c index c1faa797d4c..2112352aa59 100644 --- a/libgfortran/generated/minloc1_8_r4.c +++ b/libgfortran/generated/minloc1_8_r4.c @@ -52,8 +52,15 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_r4 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minloc1_8_r8.c b/libgfortran/generated/minloc1_8_r8.c index e7c5ee19ad1..d3d303ed082 100644 --- a/libgfortran/generated/minloc1_8_r8.c +++ b/libgfortran/generated/minloc1_8_r8.c @@ -52,8 +52,15 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -224,8 +231,8 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_r8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_i1.c b/libgfortran/generated/minval_i1.c index ccfdfa7670b..9c899bab4f6 100644 --- a/libgfortran/generated/minval_i1.c +++ b/libgfortran/generated/minval_i1.c @@ -52,8 +52,15 @@ minval_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_i16.c b/libgfortran/generated/minval_i16.c index 9d3a1502e98..8b427f92004 100644 --- a/libgfortran/generated/minval_i16.c +++ b/libgfortran/generated/minval_i16.c @@ -52,8 +52,15 @@ minval_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_i2.c b/libgfortran/generated/minval_i2.c index 0c335a06894..79f3c9b3086 100644 --- a/libgfortran/generated/minval_i2.c +++ b/libgfortran/generated/minval_i2.c @@ -52,8 +52,15 @@ minval_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_i4.c b/libgfortran/generated/minval_i4.c index 73de782ef09..3b1830668d1 100644 --- a/libgfortran/generated/minval_i4.c +++ b/libgfortran/generated/minval_i4.c @@ -52,8 +52,15 @@ minval_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_i8.c b/libgfortran/generated/minval_i8.c index 4a2a7150084..5d415f3a7f7 100644 --- a/libgfortran/generated/minval_i8.c +++ b/libgfortran/generated/minval_i8.c @@ -52,8 +52,15 @@ minval_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_r10.c b/libgfortran/generated/minval_r10.c index 27966136955..c86d8c6c7bb 100644 --- a/libgfortran/generated/minval_r10.c +++ b/libgfortran/generated/minval_r10.c @@ -52,8 +52,15 @@ minval_r10 (gfc_array_r10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_r10 (gfc_array_r10 * const restrict retarray, GFC_REAL_10 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_r16.c b/libgfortran/generated/minval_r16.c index 8bc429b8d92..421026d7bd4 100644 --- a/libgfortran/generated/minval_r16.c +++ b/libgfortran/generated/minval_r16.c @@ -52,8 +52,15 @@ minval_r16 (gfc_array_r16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_r16 (gfc_array_r16 * const restrict retarray, GFC_REAL_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_r4.c b/libgfortran/generated/minval_r4.c index a5ecce21dd9..ff3d919a69b 100644 --- a/libgfortran/generated/minval_r4.c +++ b/libgfortran/generated/minval_r4.c @@ -52,8 +52,15 @@ minval_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_r4 (gfc_array_r4 * const restrict retarray, GFC_REAL_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/minval_r8.c b/libgfortran/generated/minval_r8.c index 78c751ef699..0970c31ba9a 100644 --- a/libgfortran/generated/minval_r8.c +++ b/libgfortran/generated/minval_r8.c @@ -52,8 +52,15 @@ minval_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -217,8 +224,8 @@ mminval_r8 (gfc_array_r8 * const restrict retarray, GFC_REAL_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/norm2_r10.c b/libgfortran/generated/norm2_r10.c index 4c5a2306285..4f6eceefe24 100644 --- a/libgfortran/generated/norm2_r10.c +++ b/libgfortran/generated/norm2_r10.c @@ -55,8 +55,15 @@ norm2_r10 (gfc_array_r10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in NORM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/norm2_r16.c b/libgfortran/generated/norm2_r16.c index 5eaefb8a92d..596195fb85b 100644 --- a/libgfortran/generated/norm2_r16.c +++ b/libgfortran/generated/norm2_r16.c @@ -59,8 +59,15 @@ norm2_r16 (gfc_array_r16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in NORM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/norm2_r4.c b/libgfortran/generated/norm2_r4.c index 0482b16ca2d..4f61ea33b01 100644 --- a/libgfortran/generated/norm2_r4.c +++ b/libgfortran/generated/norm2_r4.c @@ -55,8 +55,15 @@ norm2_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in NORM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/norm2_r8.c b/libgfortran/generated/norm2_r8.c index 173faa63eb2..d325236b50b 100644 --- a/libgfortran/generated/norm2_r8.c +++ b/libgfortran/generated/norm2_r8.c @@ -55,8 +55,15 @@ norm2_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in NORM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/parity_l1.c b/libgfortran/generated/parity_l1.c index 4fe64dec7db..34cac760a3d 100644 --- a/libgfortran/generated/parity_l1.c +++ b/libgfortran/generated/parity_l1.c @@ -52,8 +52,15 @@ parity_l1 (gfc_array_l1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/parity_l16.c b/libgfortran/generated/parity_l16.c index d9e0a8efcdc..8aae3038e7b 100644 --- a/libgfortran/generated/parity_l16.c +++ b/libgfortran/generated/parity_l16.c @@ -52,8 +52,15 @@ parity_l16 (gfc_array_l16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/parity_l2.c b/libgfortran/generated/parity_l2.c index 3cf26312f02..0d87c525028 100644 --- a/libgfortran/generated/parity_l2.c +++ b/libgfortran/generated/parity_l2.c @@ -52,8 +52,15 @@ parity_l2 (gfc_array_l2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/parity_l4.c b/libgfortran/generated/parity_l4.c index 70cdd18aef9..5c524ad13a8 100644 --- a/libgfortran/generated/parity_l4.c +++ b/libgfortran/generated/parity_l4.c @@ -52,8 +52,15 @@ parity_l4 (gfc_array_l4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/parity_l8.c b/libgfortran/generated/parity_l8.c index d22c9a55371..d655ebd0837 100644 --- a/libgfortran/generated/parity_l8.c +++ b/libgfortran/generated/parity_l8.c @@ -52,8 +52,15 @@ parity_l8 (gfc_array_l8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) diff --git a/libgfortran/generated/product_c10.c b/libgfortran/generated/product_c10.c index 4e2f6f2b566..b84870cab32 100644 --- a/libgfortran/generated/product_c10.c +++ b/libgfortran/generated/product_c10.c @@ -52,8 +52,15 @@ product_c10 (gfc_array_c10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_c10 (gfc_array_c10 * const restrict retarray, GFC_COMPLEX_10 * restrict dest; const GFC_COMPLEX_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_c10 (gfc_array_c10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_c10 (gfc_array_c10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_c16.c b/libgfortran/generated/product_c16.c index df73041f170..e1618c5a645 100644 --- a/libgfortran/generated/product_c16.c +++ b/libgfortran/generated/product_c16.c @@ -52,8 +52,15 @@ product_c16 (gfc_array_c16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_c16 (gfc_array_c16 * const restrict retarray, GFC_COMPLEX_16 * restrict dest; const GFC_COMPLEX_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_c16 (gfc_array_c16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_c16 (gfc_array_c16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_c4.c b/libgfortran/generated/product_c4.c index 3d097a9a3ec..679670c9389 100644 --- a/libgfortran/generated/product_c4.c +++ b/libgfortran/generated/product_c4.c @@ -52,8 +52,15 @@ product_c4 (gfc_array_c4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_c4 (gfc_array_c4 * const restrict retarray, GFC_COMPLEX_4 * restrict dest; const GFC_COMPLEX_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_c4 (gfc_array_c4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_c4 (gfc_array_c4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_c8.c b/libgfortran/generated/product_c8.c index 4bb1ddee0fe..1f4dd10796b 100644 --- a/libgfortran/generated/product_c8.c +++ b/libgfortran/generated/product_c8.c @@ -52,8 +52,15 @@ product_c8 (gfc_array_c8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_c8 (gfc_array_c8 * const restrict retarray, GFC_COMPLEX_8 * restrict dest; const GFC_COMPLEX_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_c8 (gfc_array_c8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_c8 (gfc_array_c8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_i1.c b/libgfortran/generated/product_i1.c index fc03a48bc05..43e20b8dcb1 100644 --- a/libgfortran/generated/product_i1.c +++ b/libgfortran/generated/product_i1.c @@ -52,8 +52,15 @@ product_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_i16.c b/libgfortran/generated/product_i16.c index 6a4e1aa29a3..d786c950686 100644 --- a/libgfortran/generated/product_i16.c +++ b/libgfortran/generated/product_i16.c @@ -52,8 +52,15 @@ product_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_i2.c b/libgfortran/generated/product_i2.c index 82a650f6ec6..bdb875598ff 100644 --- a/libgfortran/generated/product_i2.c +++ b/libgfortran/generated/product_i2.c @@ -52,8 +52,15 @@ product_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_i4.c b/libgfortran/generated/product_i4.c index 84f7c36e439..1328055736a 100644 --- a/libgfortran/generated/product_i4.c +++ b/libgfortran/generated/product_i4.c @@ -52,8 +52,15 @@ product_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_i8.c b/libgfortran/generated/product_i8.c index 5ace17304e4..5adf2de1453 100644 --- a/libgfortran/generated/product_i8.c +++ b/libgfortran/generated/product_i8.c @@ -52,8 +52,15 @@ product_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_r10.c b/libgfortran/generated/product_r10.c index 54e22915b88..404b1a5bf41 100644 --- a/libgfortran/generated/product_r10.c +++ b/libgfortran/generated/product_r10.c @@ -52,8 +52,15 @@ product_r10 (gfc_array_r10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_r10 (gfc_array_r10 * const restrict retarray, GFC_REAL_10 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_r16.c b/libgfortran/generated/product_r16.c index d3a2afdbdad..592a9b9bf50 100644 --- a/libgfortran/generated/product_r16.c +++ b/libgfortran/generated/product_r16.c @@ -52,8 +52,15 @@ product_r16 (gfc_array_r16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_r16 (gfc_array_r16 * const restrict retarray, GFC_REAL_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_r4.c b/libgfortran/generated/product_r4.c index 94a2f106038..882c0917f9b 100644 --- a/libgfortran/generated/product_r4.c +++ b/libgfortran/generated/product_r4.c @@ -52,8 +52,15 @@ product_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_r4 (gfc_array_r4 * const restrict retarray, GFC_REAL_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/product_r8.c b/libgfortran/generated/product_r8.c index 2daba7587bd..cc1454963a1 100644 --- a/libgfortran/generated/product_r8.c +++ b/libgfortran/generated/product_r8.c @@ -52,8 +52,15 @@ product_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ mproduct_r8 (gfc_array_r8 * const restrict retarray, GFC_REAL_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_c10.c b/libgfortran/generated/sum_c10.c index 9d16db231b4..d3e8550e57d 100644 --- a/libgfortran/generated/sum_c10.c +++ b/libgfortran/generated/sum_c10.c @@ -52,8 +52,15 @@ sum_c10 (gfc_array_c10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_c10 (gfc_array_c10 * const restrict retarray, GFC_COMPLEX_10 * restrict dest; const GFC_COMPLEX_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_c10 (gfc_array_c10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_c10 (gfc_array_c10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_c16.c b/libgfortran/generated/sum_c16.c index 58111014100..280c2ff89c6 100644 --- a/libgfortran/generated/sum_c16.c +++ b/libgfortran/generated/sum_c16.c @@ -52,8 +52,15 @@ sum_c16 (gfc_array_c16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_c16 (gfc_array_c16 * const restrict retarray, GFC_COMPLEX_16 * restrict dest; const GFC_COMPLEX_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_c16 (gfc_array_c16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_c16 (gfc_array_c16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_c4.c b/libgfortran/generated/sum_c4.c index 27438bf4bac..0e3a74da851 100644 --- a/libgfortran/generated/sum_c4.c +++ b/libgfortran/generated/sum_c4.c @@ -52,8 +52,15 @@ sum_c4 (gfc_array_c4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_c4 (gfc_array_c4 * const restrict retarray, GFC_COMPLEX_4 * restrict dest; const GFC_COMPLEX_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_c4 (gfc_array_c4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_c4 (gfc_array_c4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_c8.c b/libgfortran/generated/sum_c8.c index cb58bbf5724..f04f374ee12 100644 --- a/libgfortran/generated/sum_c8.c +++ b/libgfortran/generated/sum_c8.c @@ -52,8 +52,15 @@ sum_c8 (gfc_array_c8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_c8 (gfc_array_c8 * const restrict retarray, GFC_COMPLEX_8 * restrict dest; const GFC_COMPLEX_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_c8 (gfc_array_c8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_c8 (gfc_array_c8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_i1.c b/libgfortran/generated/sum_i1.c index 1980383b5db..b7e8a981319 100644 --- a/libgfortran/generated/sum_i1.c +++ b/libgfortran/generated/sum_i1.c @@ -52,8 +52,15 @@ sum_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_i16.c b/libgfortran/generated/sum_i16.c index 0abaff00ade..489b9bbcdf7 100644 --- a/libgfortran/generated/sum_i16.c +++ b/libgfortran/generated/sum_i16.c @@ -52,8 +52,15 @@ sum_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_i2.c b/libgfortran/generated/sum_i2.c index 6332b647743..40304c846ce 100644 --- a/libgfortran/generated/sum_i2.c +++ b/libgfortran/generated/sum_i2.c @@ -52,8 +52,15 @@ sum_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_i4.c b/libgfortran/generated/sum_i4.c index 27dd47ee8c5..736ccd17710 100644 --- a/libgfortran/generated/sum_i4.c +++ b/libgfortran/generated/sum_i4.c @@ -52,8 +52,15 @@ sum_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_i8.c b/libgfortran/generated/sum_i8.c index f7639db0ae7..0eb9e3f92e0 100644 --- a/libgfortran/generated/sum_i8.c +++ b/libgfortran/generated/sum_i8.c @@ -52,8 +52,15 @@ sum_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_r10.c b/libgfortran/generated/sum_r10.c index 07caf236034..e37dd26a029 100644 --- a/libgfortran/generated/sum_r10.c +++ b/libgfortran/generated/sum_r10.c @@ -52,8 +52,15 @@ sum_r10 (gfc_array_r10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_r10 (gfc_array_r10 * const restrict retarray, GFC_REAL_10 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_r16.c b/libgfortran/generated/sum_r16.c index 374c2b326f3..b3058035cc9 100644 --- a/libgfortran/generated/sum_r16.c +++ b/libgfortran/generated/sum_r16.c @@ -52,8 +52,15 @@ sum_r16 (gfc_array_r16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_r16 (gfc_array_r16 * const restrict retarray, GFC_REAL_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c index 4b5caeede98..c53dc7e198a 100644 --- a/libgfortran/generated/sum_r4.c +++ b/libgfortran/generated/sum_r4.c @@ -52,8 +52,15 @@ sum_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_r4 (gfc_array_r4 * const restrict retarray, GFC_REAL_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/generated/sum_r8.c b/libgfortran/generated/sum_r8.c index 18872d7d535..4657def97e4 100644 --- a/libgfortran/generated/sum_r8.c +++ b/libgfortran/generated/sum_r8.c @@ -52,8 +52,15 @@ sum_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ - dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + dim = (*pdim) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) @@ -203,8 +210,8 @@ msum_r8 (gfc_array_r8 * const restrict retarray, GFC_REAL_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4 index 43d8775d04c..91cfd28d5d1 100644 --- a/libgfortran/m4/ifunction.m4 +++ b/libgfortran/m4/ifunction.m4 @@ -45,6 +45,13 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in u_name intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -193,8 +200,8 @@ void rtype_name * restrict dest; const atype_name * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -204,6 +211,14 @@ void dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in u_name intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -380,6 +395,13 @@ void dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in u_name intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);