analyzer: testsuite fixes for alloca, getpass, and setjmp (PR 93316)
[gcc.git] / libgfortran / m4 / minloc0.m4
index de701890dadf2aad32607fb69a1e9bf3c0173e6b..acbd28026f524e572549abaa6b366c762b0bd1a7 100644 (file)
@@ -1,5 +1,5 @@
 `/* Implementation of the MINLOC intrinsic
-   Copyright (C) 2002-2016 Free Software Foundation, Inc.
+   Copyright (C) 2002-2020 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
 This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -24,8 +24,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
 #include "libgfortran.h"
-#include <stdlib.h>
-#include <limits.h>'
+#include <assert.h>'
 
 include(iparm.m4)dnl
 include(iforeach.m4)dnl
@@ -44,8 +43,6 @@ FOREACH_FUNCTION(
     minval = atype_max;
 #endif',
 `#if defined('atype_nan`)
-       }
-      while (0);
       if (unlikely (!fast))
        {
          do
@@ -64,16 +61,29 @@ FOREACH_FUNCTION(
          if (likely (fast))
            continue;
        }
-      else do
-       {
+      else
 #endif
-         if (*base < minval)
-           {
-             minval = *base;
-             for (n = 0; n < rank; n++)
-               dest[n * dstride] = count[n] + 1;
-           }')
-
+      if (back)
+       do
+         {
+           if (unlikely (*base <= minval))
+             {
+               minval = *base;
+               for (n = 0; n < rank; n++)
+                 dest[n * dstride] = count[n] + 1;
+             }
+           base += sstride[0];
+         }
+       while (++count[0] != extent[0]);
+      else
+       do
+         {
+           if (unlikely (*base < minval))
+             {
+               minval = *base;
+               for (n = 0; n < rank; n++)
+                 dest[n * dstride] = count[n] + 1;
+             }')
 MASKED_FOREACH_FUNCTION(
 `  atype_name minval;
    int fast = 0;
@@ -83,9 +93,7 @@ MASKED_FOREACH_FUNCTION(
 #else
     minval = atype_max;
 #endif',
-`      }
-      while (0);
-      if (unlikely (!fast))
+`      if (unlikely (!fast))
        {
          do
            {
@@ -112,14 +120,27 @@ MASKED_FOREACH_FUNCTION(
          if (likely (fast))
            continue;
        }
-      else do
-       {
-         if (*mbase && *base < minval)
+        else
+        if (back)
+         do
            {
-             minval = *base;
-             for (n = 0; n < rank; n++)
-               dest[n * dstride] = count[n] + 1;
-           }')
-
+             if (unlikely (*mbase && (*base <= minval)))
+               {
+                 minval = *base;
+                 for (n = 0; n < rank; n++)
+                   dest[n * dstride] = count[n] + 1;
+               }
+               base += sstride[0];
+           }
+           while (++count[0] != extent[0]);
+       else
+         do
+           {
+             if (unlikely (*mbase && (*base < minval)))
+               {
+                 minval = *base;
+                 for (n = 0; n < rank; n++)
+                   dest[n * dstride] = count[n] + 1;
+               }')
 SCALAR_FOREACH_FUNCTION(`0')
 #endif