diff options
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 18 | ||||
-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 | ||||
-rw-r--r-- | libgfortran/intrinsics/reshape_generic.c | 27 | ||||
-rw-r--r-- | libgfortran/m4/reshape.m4 | 27 |
14 files changed, 369 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 30b91d10f90..3a0b2483532 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,21 @@ +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-06 Tobias Burnus <burnus@net-b.de> * libgfortran.h (likely,unlikely): New makros. diff --git a/libgfortran/generated/reshape_c10.c b/libgfortran/generated/reshape_c10.c index 732d947a8da..ed54f1b637e 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 71532c929ef..636150933a0 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 4253b066815..869d6231239 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 add90f2f205..24ec469bcab 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 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++) { diff --git a/libgfortran/generated/reshape_i4.c b/libgfortran/generated/reshape_i4.c index 3e0c9d68542..517d25d8703 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 bf3185e1c2c..75ba3197f34 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 9f6159aeafb..2987ef7a58c 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 69578f033a5..2d84b2b8672 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 112dbf2955d..fa68f826dac 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 015546ffe1a..8af57393439 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++) { diff --git a/libgfortran/intrinsics/reshape_generic.c b/libgfortran/intrinsics/reshape_generic.c index de1e9426756..5abae82ca03 100644 --- a/libgfortran/intrinsics/reshape_generic.c +++ b/libgfortran/intrinsics/reshape_generic.c @@ -108,6 +108,33 @@ reshape_internal (parray *ret, parray *source, shape_type *shape, 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/m4/reshape.m4 b/libgfortran/m4/reshape.m4 index a10ad715584..400e82cde69 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++) { |