aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/m4/ifunction.m4
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/m4/ifunction.m4')
-rw-r--r--libgfortran/m4/ifunction.m426
1 files changed, 24 insertions, 2 deletions
diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4
index 43d8775..91cfd28 100644
--- a/libgfortran/m4/ifunction.m4
+++ b/libgfortran/m4/ifunction.m4
@@ -45,6 +45,13 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray,
dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
+ if (unlikely (dim < 0 || dim > rank))
+ {
+ runtime_error ("Dim argument incorrect in u_name 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)
len = 0;
@@ -193,8 +200,8 @@ void
rtype_name * restrict dest;
const atype_name * 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;
@@ -204,6 +211,14 @@ void
dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+ if (unlikely (dim < 0 || dim > rank))
+ {
+ runtime_error ("Dim argument incorrect in u_name 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;
@@ -380,6 +395,13 @@ void
dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
+ if (unlikely (dim < 0 || dim > rank))
+ {
+ runtime_error ("Dim argument incorrect in u_name 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);