diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2008-09-07 13:33:18 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2008-09-07 13:33:18 +0000 |
commit | fd7f97542330504c3ead0e857be4a94eb6f55b07 (patch) | |
tree | 7b6b6c1148c1ce29f42903a013d5d58a03c9d417 /libgfortran/m4 | |
parent | 73356a7d3b37e41a0f43a2d95f8def36416bee7d (diff) | |
download | gcc-fd7f97542330504c3ead0e857be4a94eb6f55b07.zip gcc-fd7f97542330504c3ead0e857be4a94eb6f55b07.tar.gz gcc-fd7f97542330504c3ead0e857be4a94eb6f55b07.tar.bz2 |
re PR fortran/37203 (Check ORDER= of RESHAPE)
2008-09-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/37203
* intrinsics/reshape_generic.c: Add checking on
out-of-bounds and duplicate values of order argument.
* 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.
2008-09-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/37203
* gfortran.d/reshape_order_1.f90: New test case.
* gfortran.d/reshape_order_2.f90: New test case.
* gfortran.d/reshape_order_3.f90: New test case.
* gfortran.d/reshape_order_4.f90: New test case.
From-SVN: r140086
Diffstat (limited to 'libgfortran/m4')
-rw-r--r-- | libgfortran/m4/reshape.m4 | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4 index a10ad71..400e82c 100644 --- a/libgfortran/m4/reshape.m4 +++ b/libgfortran/m4/reshape.m4 @@ -123,6 +123,33 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret, if (shape_empty) return; + if (unlikely (compile_options.bounds_check)) + { + if (order) + { + int seen[GFC_MAX_DIMENSIONS]; + index_type v; + + for (n = 0; n < rdim; n++) + seen[n] = 0; + + for (n = 0; n < rdim; n++) + { + v = order->data[n * order->dim[0].stride] - 1; + + if (v < 0 || v >= rdim) + runtime_error("Value %ld out of range in ORDER argument" + " to RESHAPE intrinsic", (long int) v + 1); + + if (seen[v] != 0) + runtime_error("Duplicate value %ld in ORDER argument to" + " RESHAPE intrinsic", (long int) v + 1); + + seen[v] = 1; + } + } + } + rsize = 1; for (n = 0; n < rdim; n++) { |