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/generated | |
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/generated')
-rw-r--r-- | libgfortran/generated/reshape_c10.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_c16.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_c4.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_c8.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_i16.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_i4.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_i8.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_r10.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_r16.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_r4.c | 27 | ||||
-rw-r--r-- | libgfortran/generated/reshape_r8.c | 27 |
11 files changed, 297 insertions, 0 deletions
diff --git a/libgfortran/generated/reshape_c10.c b/libgfortran/generated/reshape_c10.c index 732d947..ed54f1b 100644 --- a/libgfortran/generated/reshape_c10.c +++ b/libgfortran/generated/reshape_c10.c @@ -119,6 +119,33 @@ reshape_c10 (gfc_array_c10 * 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++) { diff --git a/libgfortran/generated/reshape_c16.c b/libgfortran/generated/reshape_c16.c index 71532c9..6361509 100644 --- a/libgfortran/generated/reshape_c16.c +++ b/libgfortran/generated/reshape_c16.c @@ -119,6 +119,33 @@ reshape_c16 (gfc_array_c16 * 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++) { diff --git a/libgfortran/generated/reshape_c4.c b/libgfortran/generated/reshape_c4.c index 4253b06..869d623 100644 --- a/libgfortran/generated/reshape_c4.c +++ b/libgfortran/generated/reshape_c4.c @@ -119,6 +119,33 @@ reshape_c4 (gfc_array_c4 * 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++) { diff --git a/libgfortran/generated/reshape_c8.c b/libgfortran/generated/reshape_c8.c index add90f2..24ec469 100644 --- a/libgfortran/generated/reshape_c8.c +++ b/libgfortran/generated/reshape_c8.c @@ -119,6 +119,33 @@ reshape_c8 (gfc_array_c8 * 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++) { diff --git a/libgfortran/generated/reshape_i16.c b/libgfortran/generated/reshape_i16.c index e2d5a27..e857b6b 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++) { diff --git a/libgfortran/generated/reshape_i4.c b/libgfortran/generated/reshape_i4.c index 3e0c9d6..517d25d 100644 --- a/libgfortran/generated/reshape_i4.c +++ b/libgfortran/generated/reshape_i4.c @@ -119,6 +119,33 @@ reshape_4 (gfc_array_i4 * 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++) { diff --git a/libgfortran/generated/reshape_i8.c b/libgfortran/generated/reshape_i8.c index bf3185e..75ba319 100644 --- a/libgfortran/generated/reshape_i8.c +++ b/libgfortran/generated/reshape_i8.c @@ -119,6 +119,33 @@ reshape_8 (gfc_array_i8 * 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++) { diff --git a/libgfortran/generated/reshape_r10.c b/libgfortran/generated/reshape_r10.c index 9f6159a..2987ef7 100644 --- a/libgfortran/generated/reshape_r10.c +++ b/libgfortran/generated/reshape_r10.c @@ -119,6 +119,33 @@ reshape_r10 (gfc_array_r10 * 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++) { diff --git a/libgfortran/generated/reshape_r16.c b/libgfortran/generated/reshape_r16.c index 69578f0..2d84b2b 100644 --- a/libgfortran/generated/reshape_r16.c +++ b/libgfortran/generated/reshape_r16.c @@ -119,6 +119,33 @@ reshape_r16 (gfc_array_r16 * 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++) { diff --git a/libgfortran/generated/reshape_r4.c b/libgfortran/generated/reshape_r4.c index 112dbf2..fa68f82 100644 --- a/libgfortran/generated/reshape_r4.c +++ b/libgfortran/generated/reshape_r4.c @@ -119,6 +119,33 @@ reshape_r4 (gfc_array_r4 * 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++) { diff --git a/libgfortran/generated/reshape_r8.c b/libgfortran/generated/reshape_r8.c index 015546f..8af5739 100644 --- a/libgfortran/generated/reshape_r8.c +++ b/libgfortran/generated/reshape_r8.c @@ -119,6 +119,33 @@ reshape_r8 (gfc_array_r8 * 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++) { |