From: tkoenig Date: Wed, 15 Oct 2008 16:27:58 +0000 (+0000) Subject: 2008-10-15 Thomas Koenig X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80726d88a8b0416bd3169d9ff2d41f501b214cb1;p=thirdparty%2Fgcc.git 2008-10-15 Thomas Koenig PR libfortran/34670 * intrinsics/reshape_generic.c: Add bounds checking. * m4/reshape.m4: Likewise. * generated/reshape_c10.c: Regenerated. * generated/reshape_c16.c: Regenerated. * generated/reshape_c4.c: Regenerated. * generated/reshape_c8.c: Regenerated. * generated/reshape_i16.c: Regenerated. * generated/reshape_i4.c: Regenerated. * generated/reshape_i8.c: Regenerated. * generated/reshape_r10.c: Regenerated. * generated/reshape_r16.c: Regenerated. * generated/reshape_r4.c: Regenerated. * generated/reshape_r8.c: Regenerated. * generated/spread_r4.c: Regenerated. 2008-10-15 Thomas Koenig PR libfortran/34670 * gfortran.dg/reshape_3.f90: New test. * gfortran.dg/reshape_4.f90: New test. * gfortran.dg/reshape_order_1.f90: Use correct shape. * gfortran.dg/reshape_order_2.f90: Likewise. * gfortran.dg/reshape_order_3.f90: Likewise. * gfortran.dg/reshape_order_4.f90: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141144 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2647c9551086..8cee6d05feb7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2008-10-15 Thomas Koenig + + PR libfortran/34670 + * gfortran.dg/reshape_3.f90: New test. + * gfortran.dg/reshape_4.f90: New test. + * gfortran.dg/reshape_order_1.f90: Use correct shape. + * gfortran.dg/reshape_order_2.f90: Likewise. + * gfortran.dg/reshape_order_3.f90: Likewise. + * gfortran.dg/reshape_order_4.f90: Likewise. + 2008-10-15 Jan Sjodin Harsha Jagasia diff --git a/gcc/testsuite/gfortran.dg/reshape_order_1.f90 b/gcc/testsuite/gfortran.dg/reshape_order_1.f90 index 3909bfde22b6..880d9d76b682 100644 --- a/gcc/testsuite/gfortran.dg/reshape_order_1.f90 +++ b/gcc/testsuite/gfortran.dg/reshape_order_1.f90 @@ -4,7 +4,7 @@ program main implicit none integer(kind=1), dimension(6) :: source1 = (/ 1, 2, 3, 4, 5, 6 /) - integer, dimension(2) :: shape1 = (/ 2, 5/) + integer, dimension(2) :: shape1 = (/ 2, 3/) integer(kind=1), dimension(2) :: pad1 = (/ 0, 0/) character(len=200) :: l1, l2 integer :: i1, i2 diff --git a/gcc/testsuite/gfortran.dg/reshape_order_2.f90 b/gcc/testsuite/gfortran.dg/reshape_order_2.f90 index 3c8ef411370e..20a6f19b958d 100644 --- a/gcc/testsuite/gfortran.dg/reshape_order_2.f90 +++ b/gcc/testsuite/gfortran.dg/reshape_order_2.f90 @@ -4,7 +4,7 @@ program main implicit none integer(kind=1), dimension(6) :: source1 = (/ 1, 2, 3, 4, 5, 6 /) - integer, dimension(2) :: shape1 = (/ 2, 5/) + integer, dimension(2) :: shape1 = (/ 2, 3/) integer(kind=1), dimension(2) :: pad1 = (/ 0, 0/) character(len=200) :: l1, l2 integer :: i1, i2 diff --git a/gcc/testsuite/gfortran.dg/reshape_order_3.f90 b/gcc/testsuite/gfortran.dg/reshape_order_3.f90 index 263488025d8c..4b757f81cb4c 100644 --- a/gcc/testsuite/gfortran.dg/reshape_order_3.f90 +++ b/gcc/testsuite/gfortran.dg/reshape_order_3.f90 @@ -4,7 +4,7 @@ program main implicit none integer(kind=4), dimension(6) :: source1 = (/ 1, 2, 3, 4, 5, 6 /) - integer, dimension(2) :: shape1 = (/ 2, 5/) + integer, dimension(2) :: shape1 = (/ 2, 3/) integer(kind=4), dimension(2) :: pad1 = (/ 0, 0/) character(len=200) :: l1, l2 integer :: i1, i2 diff --git a/gcc/testsuite/gfortran.dg/reshape_order_4.f90 b/gcc/testsuite/gfortran.dg/reshape_order_4.f90 index bd0536d844ab..c66df8e83d80 100644 --- a/gcc/testsuite/gfortran.dg/reshape_order_4.f90 +++ b/gcc/testsuite/gfortran.dg/reshape_order_4.f90 @@ -4,7 +4,7 @@ program main implicit none integer(kind=4), dimension(6) :: source1 = (/ 1, 2, 3, 4, 5, 6 /) - integer, dimension(2) :: shape1 = (/ 2, 5/) + integer, dimension(2) :: shape1 = (/ 2, 3/) integer(kind=4), dimension(2) :: pad1 = (/ 0, 0/) character(len=200) :: l1, l2 integer :: i1, i2 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 4e72cb8bfc7f..ae4e64e071a8 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,21 @@ +2008-10-15 Thomas Koenig + + PR libfortran/34670 + * intrinsics/reshape_generic.c: Add bounds checking. + * m4/reshape.m4: Likewise. + * generated/reshape_c10.c: Regenerated. + * generated/reshape_c16.c: Regenerated. + * generated/reshape_c4.c: Regenerated. + * generated/reshape_c8.c: Regenerated. + * generated/reshape_i16.c: Regenerated. + * generated/reshape_i4.c: Regenerated. + * generated/reshape_i8.c: Regenerated. + * generated/reshape_r10.c: Regenerated. + * generated/reshape_r16.c: Regenerated. + * generated/reshape_r4.c: Regenerated. + * generated/reshape_r8.c: Regenerated. + * generated/spread_r4.c: Regenerated. + 2008-10-13 Jerry DeLisle dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_c16.c b/libgfortran/generated/reshape_c16.c index 636150933a02..79745f2de582 100644 --- a/libgfortran/generated/reshape_c16.c +++ b/libgfortran/generated/reshape_c16.c @@ -121,6 +121,27 @@ reshape_c16 (gfc_array_c16 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_c4.c b/libgfortran/generated/reshape_c4.c index 869d62312396..90383adf922c 100644 --- a/libgfortran/generated/reshape_c4.c +++ b/libgfortran/generated/reshape_c4.c @@ -121,6 +121,27 @@ reshape_c4 (gfc_array_c4 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_c8.c b/libgfortran/generated/reshape_c8.c index 24ec469bcab1..49178e5e09ad 100644 --- a/libgfortran/generated/reshape_c8.c +++ b/libgfortran/generated/reshape_c8.c @@ -121,6 +121,27 @@ reshape_c8 (gfc_array_c8 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_i16.c b/libgfortran/generated/reshape_i16.c index e857b6b6a244..a62646513655 100644 --- a/libgfortran/generated/reshape_i16.c +++ b/libgfortran/generated/reshape_i16.c @@ -121,6 +121,27 @@ reshape_16 (gfc_array_i16 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_i4.c b/libgfortran/generated/reshape_i4.c index 517d25d8703e..1d3aa49e9470 100644 --- a/libgfortran/generated/reshape_i4.c +++ b/libgfortran/generated/reshape_i4.c @@ -121,6 +121,27 @@ reshape_4 (gfc_array_i4 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_i8.c b/libgfortran/generated/reshape_i8.c index 75ba3197f349..8c51795f1ff5 100644 --- a/libgfortran/generated/reshape_i8.c +++ b/libgfortran/generated/reshape_i8.c @@ -121,6 +121,27 @@ reshape_8 (gfc_array_i8 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_r10.c b/libgfortran/generated/reshape_r10.c index 2987ef7a58c2..846d12f1f082 100644 --- a/libgfortran/generated/reshape_r10.c +++ b/libgfortran/generated/reshape_r10.c @@ -121,6 +121,27 @@ reshape_r10 (gfc_array_r10 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_r16.c b/libgfortran/generated/reshape_r16.c index 2d84b2b86727..286e374ff18d 100644 --- a/libgfortran/generated/reshape_r16.c +++ b/libgfortran/generated/reshape_r16.c @@ -121,6 +121,27 @@ reshape_r16 (gfc_array_r16 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_r4.c b/libgfortran/generated/reshape_r4.c index fa68f826dac7..cd16b24a9eb9 100644 --- a/libgfortran/generated/reshape_r4.c +++ b/libgfortran/generated/reshape_r4.c @@ -121,6 +121,27 @@ reshape_r4 (gfc_array_r4 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/reshape_r8.c b/libgfortran/generated/reshape_r8.c index 8af573934391..9da26d4c1994 100644 --- a/libgfortran/generated/reshape_r8.c +++ b/libgfortran/generated/reshape_r8.c @@ -121,6 +121,27 @@ reshape_r8 (gfc_array_r8 * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/generated/spread_r4.c b/libgfortran/generated/spread_r4.c index c151df3122a0..a9357afdc61b 100644 --- a/libgfortran/generated/spread_r4.c +++ b/libgfortran/generated/spread_r4.c @@ -131,7 +131,8 @@ spread_r4 (gfc_array_r4 *ret, const gfc_array_r4 *source, if (n == along - 1) { rdelta = ret->dim[n].stride; - + printf("ret_extent = %ld, ncopies = %ld\n", + (long int) ret_extent, (long int) ncopies); if (ret_extent != ncopies) runtime_error("Incorrect extent in return value of SPREAD" " intrinsic in dimension %ld: is %ld," diff --git a/libgfortran/intrinsics/reshape_generic.c b/libgfortran/intrinsics/reshape_generic.c index 5abae82ca034..2d8306cbe31c 100644 --- a/libgfortran/intrinsics/reshape_generic.c +++ b/libgfortran/intrinsics/reshape_generic.c @@ -110,6 +110,27 @@ reshape_internal (parray *ret, parray *source, shape_type *shape, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS]; diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4 index 400e82cde697..8d7ea728086b 100644 --- a/libgfortran/m4/reshape.m4 +++ b/libgfortran/m4/reshape.m4 @@ -125,6 +125,27 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret, if (unlikely (compile_options.bounds_check)) { + index_type ret_extent, source_extent; + + rs = 1; + for (n = 0; n < rdim; n++) + { + rs *= shape_data[n]; + ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound; + if (ret_extent != shape_data[n]) + runtime_error("Incorrect extent in return value of RESHAPE" + " intrinsic in dimension %ld: is %ld," + " should be %ld", (long int) n+1, + (long int) ret_extent, (long int) shape_data[n]); + } + + source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound; + + if (rs != source_extent) + runtime_error("Incorrect size in SOURCE argument to RESHAPE" + " intrinsic: is %ld, should be %ld", + (long int) source_extent, (long int) rs); + if (order) { int seen[GFC_MAX_DIMENSIONS];