aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/generated/maxloc1_8_i8.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/generated/maxloc1_8_i8.c')
-rw-r--r--libgfortran/generated/maxloc1_8_i8.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c
index 43b4af1..a896587 100644
--- a/libgfortran/generated/maxloc1_8_i8.c
+++ b/libgfortran/generated/maxloc1_8_i8.c
@@ -52,8 +52,15 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
int continue_loop;
/* Make dim zero based to avoid confusion. */
- dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
+ dim = (*pdim) - 1;
+
+ if (unlikely (dim < 0 || dim > rank))
+ {
+ runtime_error ("Dim argument incorrect in MAXLOC intrinsic: "
+ "is %ld, should be between 1 and %ld",
+ (long int) dim + 1, (long int) rank + 1);
+ }
len = GFC_DESCRIPTOR_EXTENT(array,dim);
if (len < 0)
@@ -224,8 +231,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
GFC_INTEGER_8 * restrict dest;
const GFC_INTEGER_8 * restrict base;
const GFC_LOGICAL_1 * restrict mbase;
- int rank;
- int dim;
+ index_type rank;
+ index_type dim;
index_type n;
index_type len;
index_type delta;
@@ -235,6 +242,14 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+ if (unlikely (dim < 0 || dim > rank))
+ {
+ runtime_error ("Dim argument incorrect in MAXLOC intrinsic: "
+ "is %ld, should be between 1 and %ld",
+ (long int) dim + 1, (long int) rank + 1);
+ }
+
len = GFC_DESCRIPTOR_EXTENT(array,dim);
if (len <= 0)
return;
@@ -445,6 +460,13 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
+ if (unlikely (dim < 0 || dim > rank))
+ {
+ runtime_error ("Dim argument incorrect in MAXLOC intrinsic: "
+ "is %ld, should be between 1 and %ld",
+ (long int) dim + 1, (long int) rank + 1);
+ }
+
for (n = 0; n < dim; n++)
{
extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);