OSDN Git Service

* config/i386/i386.c (ix86_expand_movmem, ix86_expand_setmem): Add
[pf3gnuchains/gcc-fork.git] / libgfortran / generated / shape_i4.c
index c6b4f7f..64a6fcd 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the SHAPE intrinsic
-   Copyright 2002 Free Software Foundation, Inc.
+   Copyright 2002, 2006, 2007 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
 This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -28,27 +28,35 @@ License along with libgfortran; see the file COPYING.  If not,
 write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 Boston, MA 02110-1301, USA.  */
 
-#include "config.h"
+#include "libgfortran.h"
 #include <stdlib.h>
 #include <assert.h>
-#include "libgfortran.h"
 
-extern void shape_4 (gfc_array_i4 * ret, const gfc_array_i4 * array);
+
+#if defined (HAVE_GFC_INTEGER_4)
+
+extern void shape_4 (gfc_array_i4 * const restrict ret, 
+       const gfc_array_i4 * const restrict array);
 export_proto(shape_4);
 
 void
-shape_4 (gfc_array_i4 * ret, const gfc_array_i4 * array)
+shape_4 (gfc_array_i4 * const restrict ret, 
+       const gfc_array_i4 * const restrict array)
 {
   int n;
   index_type stride;
+  index_type extent;
 
   stride = ret->dim[0].stride;
-  if (stride == 0)
-    stride = 1;
+
+  if (ret->dim[0].ubound < ret->dim[0].lbound)
+    return;
 
   for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
     {
-      ret->data[n * stride] =
-        array->dim[n].ubound + 1 - array->dim[n].lbound;
+      extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      ret->data[n * stride] = extent > 0 ? extent : 0 ;
     }
 }
+
+#endif