]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/generated/norm2_r16.c
Update copyright years.
[thirdparty/gcc.git] / libgfortran / generated / norm2_r16.c
index 35cbe93cccb1a057b0957d064766ba46f8f2f51d..63cb3b99d340c77ef8014611b4102947275a8000 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the NORM2 intrinsic
-   Copyright (C) 2010-2017 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
    Contributed by Tobias Burnus  <burnus@net-b.de>
 
 This file is part of the GNU Fortran runtime library (libgfortran).
@@ -59,8 +59,15 @@ norm2_r16 (gfc_array_r16 * 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 NORM 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)
@@ -100,7 +107,7 @@ norm2_r16 (gfc_array_r16 * const restrict retarray,
        }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->dtype.rank = rank;
 
       alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
 
@@ -152,8 +159,10 @@ norm2_r16 (gfc_array_r16 * const restrict retarray,
          *dest = 0;
        else
          {
+#if ! defined HAVE_BACK_ARG
            for (n = 0; n < len; n++, src += delta)
              {
+#endif
 
          if (*src != 0)
            {
@@ -191,9 +200,9 @@ norm2_r16 (gfc_array_r16 * const restrict retarray,
          base -= sstride[n] * extent[n];
          dest -= dstride[n] * extent[n];
          n++;
-         if (n == rank)
+         if (n >= rank)
            {
-             /* Break out of the look.  */
+             /* Break out of the loop.  */
              continue_loop = 0;
              break;
            }