summaryrefslogtreecommitdiff
path: root/libgfortran/generated/product_i16.c
diff options
context:
space:
mode:
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2017-07-31 14:52:19 +0000
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2017-07-31 14:52:19 +0000
commitb31856d3ac23cf3dab1e95cb96230dc81564c84a (patch)
tree49524df297e69390449c3ef5037b2360d14c7b1a /libgfortran/generated/product_i16.c
parent1ade4d1864f2cf61eb5c045f57c0bcac80943c04 (diff)
parenta168a775e93ec31ae743ad282d8e60fa1c116891 (diff)
downloadgcc-b31856d3ac23cf3dab1e95cb96230dc81564c84a.tar.gz
Merged trunk revision 250739 into the hsa branch
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/hsa@250744 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/generated/product_i16.c')
-rw-r--r--libgfortran/generated/product_i16.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/libgfortran/generated/product_i16.c b/libgfortran/generated/product_i16.c
index 6a4e1aa29a3..d786c950686 100644
--- a/libgfortran/generated/product_i16.c
+++ b/libgfortran/generated/product_i16.c
@@ -52,8 +52,15 @@ product_i16 (gfc_array_i16 * 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 PRODUCT 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)
@@ -203,8 +210,8 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray,
GFC_INTEGER_16 * restrict dest;
const GFC_INTEGER_16 * 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;
@@ -214,6 +221,14 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray,
dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+ if (unlikely (dim < 0 || dim > rank))
+ {
+ runtime_error ("Dim argument incorrect in PRODUCT 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;
@@ -391,6 +406,13 @@ sproduct_i16 (gfc_array_i16 * const restrict retarray,
dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
+ if (unlikely (dim < 0 || dim > rank))
+ {
+ runtime_error ("Dim argument incorrect in PRODUCT 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);