]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgfortran.h (GFC_ARRAY_DESCRIPTOR): Remove dimension of descriptor to use vaiable...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 12 Feb 2018 19:53:17 +0000 (19:53 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 12 Feb 2018 19:53:17 +0000 (19:53 +0000)
2018-02-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

* libgfortran.h (GFC_ARRAY_DESCRIPTOR): Remove dimension
of descriptor to use vaiable members for dim.
Change usage of GFC_ARRAY_DESCRIPTOR accordingly.
(GFC_FILL_ARRAY_DESCRIPTOR): New macro.
(gfc_full_array_i4): New type.
* intrinsics/date_and_time.c (secnds): Use sizeof
(gfc_array_i4) + sizeof (descriptor_dimension) for memory
allocation.
* intrinsics/reshape_generic.c: Use GFC_FULL_ARRAY_DESCRIPTOR.
* io/format.c: Use sizeof (gfc_array_i4) + sizeof
(descriptor_dimension) for memoy allocation.
* io/list_read.c (list_formatted_read_scalar): Use
gfc_full_array_i4 for variable.
(nml_read_obj): Likewise.
* io/write.c (list_formatted_write_scalar): Likewise.
(nml_write_obj): Likewise.
* m4/reshape.m4: Use GFC_FULL_ARRAY_DESCRIPTOR.
* generated/reshape_c10.c: Regenerated.
* generated/reshape_c16.c: Regenerated.
* generated/reshape_c4.c: Regenerated.
* generated/reshape_c8.c: Regenerated.
* generated/reshape_i16.c: Regenerated.
* generated/reshape_i4.c: Regenerated.
* generated/reshape_i8.c: Regenerated.
* generated/reshape_r10.c: Regenerated.
* generated/reshape_r16.c: Regenerated.
* generated/reshape_r4.c: Regenerated.
* generated/reshape_r8.c: Regenerated.

From-SVN: r257601

19 files changed:
libgfortran/ChangeLog
libgfortran/generated/reshape_c10.c
libgfortran/generated/reshape_c16.c
libgfortran/generated/reshape_c4.c
libgfortran/generated/reshape_c8.c
libgfortran/generated/reshape_i16.c
libgfortran/generated/reshape_i4.c
libgfortran/generated/reshape_i8.c
libgfortran/generated/reshape_r10.c
libgfortran/generated/reshape_r16.c
libgfortran/generated/reshape_r4.c
libgfortran/generated/reshape_r8.c
libgfortran/intrinsics/date_and_time.c
libgfortran/intrinsics/reshape_generic.c
libgfortran/io/format.c
libgfortran/io/list_read.c
libgfortran/io/write.c
libgfortran/libgfortran.h
libgfortran/m4/reshape.m4

index 77ae9f76809ae31010fa548a340db89e93c1fe8c..2220ec2bae63a8548a36bcb8fcb6a9a1c17235b8 100644 (file)
@@ -1,3 +1,34 @@
+2018-02-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       * libgfortran.h (GFC_ARRAY_DESCRIPTOR): Remove dimension
+       of descriptor to use vaiable members for dim.
+       Change usage of GFC_ARRAY_DESCRIPTOR accordingly.
+       (GFC_FILL_ARRAY_DESCRIPTOR): New macro.
+       (gfc_full_array_i4): New type.
+       * intrinsics/date_and_time.c (secnds): Use sizeof
+       (gfc_array_i4) + sizeof (descriptor_dimension) for memory
+       allocation.
+       * intrinsics/reshape_generic.c: Use GFC_FULL_ARRAY_DESCRIPTOR.
+       * io/format.c: Use sizeof (gfc_array_i4) + sizeof
+       (descriptor_dimension) for memoy allocation.
+       * io/list_read.c (list_formatted_read_scalar): Use
+       gfc_full_array_i4 for variable.
+       (nml_read_obj): Likewise.
+       * io/write.c (list_formatted_write_scalar): Likewise.
+       (nml_write_obj): Likewise.
+       * m4/reshape.m4: Use GFC_FULL_ARRAY_DESCRIPTOR.
+       * generated/reshape_c10.c: Regenerated.
+       * generated/reshape_c16.c: Regenerated.
+       * generated/reshape_c4.c: Regenerated.
+       * generated/reshape_c8.c: Regenerated.
+       * generated/reshape_i16.c: Regenerated.
+       * generated/reshape_i4.c: Regenerated.
+       * generated/reshape_i8.c: Regenerated.
+       * generated/reshape_r10.c: Regenerated.
+       * generated/reshape_r16.c: Regenerated.
+       * generated/reshape_r4.c: Regenerated.
+       * generated/reshape_r8.c: Regenerated.
+
 2018-01-31  Janne Blomqvist  <jb@gcc.gnu.org>
 
        * generated/cshift1_16.c (cshift1): Regenerated.
index dbea98d17386273854ad99804cccb8f86e86f0d3..a6077551e1b37763369e324745c2ea2f5e092f7d 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_COMPLEX_10)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_c10 (gfc_array_c10 * const restrict, 
index 4cf875f1518e9deddf4fb9d81d841c9da56b4ddd..daecd1eb87569636704fe3c8b8103107685c9c51 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_COMPLEX_16)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_c16 (gfc_array_c16 * const restrict, 
index da718ad9a44b6610ad4e32dbb7a093ec3611c3f4..c2f89e9f99a55ab046847fd5704f954d6ab453d1 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_COMPLEX_4)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_c4 (gfc_array_c4 * const restrict, 
index 9fa7aca1abd9ee0bdede2f37507933c8edd106aa..2b2a0b8ee7c4c8689e52b82858795219fce49024 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_COMPLEX_8)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_c8 (gfc_array_c8 * const restrict, 
index 8d3e218cdd6ab7e962118ba0fff5fcba6cc1edf2..620d74bf137bc8e839d8c8872534c4838ca8438d 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_INTEGER_16)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_16 (gfc_array_i16 * const restrict, 
index d5348529290a6c01e7010f7e51aff50fec216ecd..fb616e64fd64f7d024b259d425c8c763003094b6 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_INTEGER_4)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_4 (gfc_array_i4 * const restrict, 
index 205d45efd256a9999d8afb9b5594f826ac41228b..abe466368282516ac0f42f4566283b04206a2077 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_INTEGER_8)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_8 (gfc_array_i8 * const restrict, 
index 15e68f1f2bae1181060beece6905a2f35997a385..e2f6cb64604f5106676a2b0bb64d6321ee90e666 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_REAL_10)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_r10 (gfc_array_r10 * const restrict, 
index 4e17d31fb7d23e67077110e89e0fb74c878923f1..0a24a751c80d376c8f13db745043c5821e81b193 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_REAL_16)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_r16 (gfc_array_r16 * const restrict, 
index 7f419b113c18b6d46c3045700625c1bcc71ab15d..db8d76a4135ef0dd59e391630558cc21478b3167 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_REAL_4)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_r4 (gfc_array_r4 * const restrict, 
index 0315b0b36ad1b16fb7f0a58ad69ac9b8cc41b267..06fc72f6efc3cf02d11daa4f7f470c9754595907 100644 (file)
@@ -28,7 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if defined (HAVE_GFC_REAL_8)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
 
 
 extern void reshape_r8 (gfc_array_r8 * const restrict, 
index a493b448b6a376620eab24621bc88899578c82ca..78a7cd0e48b50944324116b6136ca52b9e2e8ddc 100644 (file)
@@ -267,8 +267,10 @@ secnds (GFC_REAL_4 *x)
   GFC_INTEGER_4 values[VALUES_SIZE];
   GFC_REAL_4 temp1, temp2;
 
-  /* Make the INTEGER*4 array for passing to date_and_time.  */
-  gfc_array_i4 *avalues = xmalloc (sizeof (gfc_array_i4));
+  /* Make the INTEGER*4 array for passing to date_and_time, with enough space
+   for a rank-one array.  */
+  gfc_array_i4 *avalues = xmalloc (sizeof (gfc_array_i4)
+                                  + sizeof (descriptor_dimension));
   avalues->base_addr = &values[0];
   GFC_DESCRIPTOR_DTYPE (avalues).type = BT_REAL;
   GFC_DESCRIPTOR_DTYPE (avalues).elem_len = 4;
index 94e45f510f9bc207ae947a3f82b07c94d8cf250d..276c69ca59582959c4f2dd8b110fee55568d97e9 100644 (file)
@@ -26,8 +26,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #include "libgfortran.h"
 #include <string.h>
 
-typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
-typedef GFC_ARRAY_DESCRIPTOR(GFC_MAX_DIMENSIONS, char) parray;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+typedef GFC_FULL_ARRAY_DESCRIPTOR(GFC_MAX_DIMENSIONS, char) parray;
 
 static void
 reshape_internal (parray *ret, parray *source, shape_type *shape,
index b718faadc7606b681ad15ed082f8831eb9a0525b..b4920aaf1f1f8d848e6c72de9e06ba9674ac76a6 100644 (file)
@@ -1024,8 +1024,9 @@ parse_format_list (st_parameter_dt *dtp, bool *seen_dd)
 
       t = format_lex (fmt);
 
-      /* Initialize the vlist to a zero size array.  */
-      tail->u.udf.vlist= xmalloc (sizeof(gfc_array_i4));
+      /* Initialize the vlist to a zero size, rank-one array.  */
+      tail->u.udf.vlist= xmalloc (sizeof(gfc_array_i4)
+                                 + sizeof (descriptor_dimension));
       GFC_DESCRIPTOR_DATA(tail->u.udf.vlist) = NULL;
       GFC_DIMENSION_SET(tail->u.udf.vlist->dim[0],1, 0, 0);
 
index fbd7dc27edff3420e1cda20dbf886149376ee70d..d052d1fa828e313f2ed486e7609ad89048308930 100644 (file)
@@ -2198,7 +2198,7 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p,
          gfc_charlen_type child_iomsg_len;
          int noiostat;
          int *child_iostat = NULL;
-         gfc_array_i4 vlist;
+         gfc_full_array_i4 vlist;
 
          GFC_DESCRIPTOR_DATA(&vlist) = NULL;
          GFC_DIMENSION_SET(vlist.dim[0],1, 0, 0);
@@ -2996,7 +2996,7 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info *nl, index_type offset,
                gfc_charlen_type child_iomsg_len;
                int noiostat;
                int *child_iostat = NULL;
-               gfc_array_i4 vlist;
+               gfc_full_array_i4 vlist;
                formatted_dtio dtio_ptr = (formatted_dtio)nl->dtio_sub;
 
                GFC_DESCRIPTOR_DATA(&vlist) = NULL;
index 28ea852867b7e7f3713ebeef393600a196ebb0d1..50ea13364e385f39a7615c71ca507fb4258596df 100644 (file)
@@ -1886,7 +1886,7 @@ list_formatted_write_scalar (st_parameter_dt *dtp, bt type, void *p, int kind,
          gfc_charlen_type child_iomsg_len;
          int noiostat;
          int *child_iostat = NULL;
-         gfc_array_i4 vlist;
+         gfc_full_array_i4 vlist;
 
          GFC_DESCRIPTOR_DATA(&vlist) = NULL;
          GFC_DIMENSION_SET(vlist.dim[0],1, 0, 0);
@@ -2211,7 +2211,7 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info *obj, index_type offset,
                  gfc_charlen_type child_iomsg_len;
                  int noiostat;
                  int *child_iostat = NULL;
-                 gfc_array_i4 vlist;
+                 gfc_full_array_i4 vlist;
                  formatted_dtio dtio_ptr = (formatted_dtio)obj->dtio_sub;
 
                  GFC_DIMENSION_SET(vlist.dim[0],1, 0, 0);
index 3b1dc722f42c080aa6033d61a22e93c2aebed688..38e364f1012ff77bb719a1a90d6c8267b2326c82 100644 (file)
@@ -339,51 +339,65 @@ typedef struct dtype_type
 }
 dtype_type;
 
-#define GFC_ARRAY_DESCRIPTOR(r, type) \
+#define GFC_ARRAY_DESCRIPTOR(type) \
 struct {\
   type *base_addr;\
   size_t offset;\
   dtype_type dtype;\
   index_type span;\
-  descriptor_dimension dim[r];\
+  descriptor_dimension dim[];\
 }
 
 /* Commonly used array descriptor types.  */
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_1) gfc_array_i1;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_2) gfc_array_i2;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
+typedef GFC_ARRAY_DESCRIPTOR (void) gfc_array_void;
+typedef GFC_ARRAY_DESCRIPTOR (char) gfc_array_char;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_INTEGER_1) gfc_array_i1;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_INTEGER_2) gfc_array_i2;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_INTEGER_4) gfc_array_i4;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_INTEGER_8) gfc_array_i8;
 #ifdef HAVE_GFC_INTEGER_16
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_16) gfc_array_i16;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_INTEGER_16) gfc_array_i16;
 #endif
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_REAL_4) gfc_array_r4;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_REAL_8) gfc_array_r8;
 #ifdef HAVE_GFC_REAL_10
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_10) gfc_array_r10;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_REAL_10) gfc_array_r10;
 #endif
 #ifdef HAVE_GFC_REAL_16
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_16) gfc_array_r16;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_REAL_16) gfc_array_r16;
 #endif
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_COMPLEX_4) gfc_array_c4;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_COMPLEX_8) gfc_array_c8;
 #ifdef HAVE_GFC_COMPLEX_10
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_10) gfc_array_c10;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_COMPLEX_10) gfc_array_c10;
 #endif
 #ifdef HAVE_GFC_COMPLEX_16
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_16) gfc_array_c16;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_COMPLEX_16) gfc_array_c16;
 #endif
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_1) gfc_array_l1;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_2) gfc_array_l2;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_LOGICAL_1) gfc_array_l1;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_LOGICAL_2) gfc_array_l2;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_LOGICAL_4) gfc_array_l4;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_LOGICAL_8) gfc_array_l8;
 #ifdef HAVE_GFC_LOGICAL_16
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_16) gfc_array_l16;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_LOGICAL_16) gfc_array_l16;
 #endif
 typedef gfc_array_i1 gfc_array_s1;
 typedef gfc_array_i4 gfc_array_s4;
 
+/* These are for when you actually want to declare a descriptor, as
+   opposed to a pointer to it.  */
+
+#define GFC_FULL_ARRAY_DESCRIPTOR(r, type) \
+struct {\
+  type *base_addr;\
+  size_t offset;\
+  dtype_type dtype;\
+  index_type span;\
+  descriptor_dimension dim[r];\
+}
+
+typedef GFC_FULL_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_full_array_i4;
+
 #define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype.rank)
 #define GFC_DESCRIPTOR_TYPE(desc) ((desc)->dtype.type)
 #define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype.elem_len)
@@ -1345,7 +1359,7 @@ iexport_proto(random_seed_i8);
 
 /* size.c */
 
-typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t;
+typedef GFC_ARRAY_DESCRIPTOR (void) array_t;
 
 extern index_type size0 (const array_t * array); 
 iexport_proto(size0);
index 108911685dedc3d7b101fd16c06dfbdc1e582409..c96ad9f35a3098a72e476afd427d44c671fd07da 100644 (file)
@@ -29,7 +29,7 @@ include(iparm.m4)dnl
 
 `#if defined (HAVE_'rtype_name`)
 
-typedef GFC_ARRAY_DESCRIPTOR(1, 'index_type`) 'shape_type`;'
+typedef GFC_FULL_ARRAY_DESCRIPTOR(1, 'index_type`) 'shape_type`;'
 
 dnl For integer routines, only the kind (ie size) is used to name the
 dnl function.  The same function will be used for integer and logical