diff options
Diffstat (limited to 'libgfortran/generated/reshape_i16.c')
-rw-r--r-- | libgfortran/generated/reshape_i16.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libgfortran/generated/reshape_i16.c b/libgfortran/generated/reshape_i16.c index e2d5a275842..e857b6b6a24 100644 --- a/libgfortran/generated/reshape_i16.c +++ b/libgfortran/generated/reshape_i16.c @@ -119,6 +119,33 @@ reshape_16 (gfc_array_i16 * 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++) { |