]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/generated/sum_r4.c
Update copyright years.
[thirdparty/gcc.git] / libgfortran / generated / sum_r4.c
index 4228bde8be8d8d9dda1139b7dae65df624e8b591..1147f2e5ef5c9bed64d53f5a4f0fac73fc20c0e8 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the SUM intrinsic
-   Copyright (C) 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2024 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
 This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -106,12 +106,7 @@ sum_r4 (gfc_array_r4 * const restrict retarray,
 
       retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_4));
       if (alloc_size == 0)
-       {
-         /* Make sure we have a zero-sized array.  */
-         GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
-         return;
-
-       }
+       return;
     }
   else
     {
@@ -220,6 +215,16 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
   index_type mdelta;
   int mask_kind;
 
+  if (mask == NULL)
+    {
+#ifdef HAVE_BACK_ARG
+      sum_r4 (retarray, array, pdim, back);
+#else
+      sum_r4 (retarray, array, pdim);
+#endif
+      return;
+    }
+
   dim = (*pdim) - 1;
   rank = GFC_DESCRIPTOR_RANK (array) - 1;
 
@@ -232,8 +237,8 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
@@ -291,15 +296,9 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
+      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_4));
       if (alloc_size == 0)
-       {
-         /* Make sure we have a zero-sized array.  */
-         GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
-         return;
-       }
-      else
-       retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_4));
-
+       return;
     }
   else
     {
@@ -399,7 +398,7 @@ ssum_r4 (gfc_array_r4 * const restrict retarray,
   index_type dim;
 
 
-  if (*mask)
+  if (mask == NULL || *mask)
     {
 #ifdef HAVE_BACK_ARG
       sum_r4 (retarray, array, pdim, back);
@@ -456,14 +455,9 @@ ssum_r4 (gfc_array_r4 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
 
+      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_4));
       if (alloc_size == 0)
-       {
-         /* Make sure we have a zero-sized array.  */
-         GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
-         return;
-       }
-      else
-       retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_4));
+       return;
     }
   else
     {