diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2008-10-15 16:27:58 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2008-10-15 16:27:58 +0000 |
commit | 21c74256c36074cd3bab4895079977ab11672789 (patch) | |
tree | 39776d8541e7a723cf713a2f77af4ba4cf9d3ea0 /libgfortran/generated/reshape_r10.c | |
parent | 2c7a7f46d89be753c00b5b7d23d0d943eb0b2d29 (diff) | |
download | gcc-21c74256c36074cd3bab4895079977ab11672789.tar.gz |
re PR libfortran/34670 (bounds checking for array intrinsics)
2008-10-15 Thomas Koenig <tkoenig@gcc.gnu.org>
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 <tkoenig@gcc.gnu.org>
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.
From-SVN: r141144
Diffstat (limited to 'libgfortran/generated/reshape_r10.c')
-rw-r--r-- | libgfortran/generated/reshape_r10.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libgfortran/generated/reshape_r10.c b/libgfortran/generated/reshape_r10.c index 2987ef7a58c..846d12f1f08 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]; |