]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgfortran: Fix -Wincompatible-pointer-types errors
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Dec 2023 21:56:41 +0000 (22:56 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 5 Dec 2023 21:56:41 +0000 (22:56 +0100)
As reported, libgfortran fails to build on targets where int32_t and int
are different types, because it uses int vs. GFC_INTEGER_4 (under hood
int32_t) interchangeably.

The following patch fixes that.

2023-12-05  Florian Weimer  <fweimer@redhat.com>
    Jakub Jelinek  <jakub@redhat.com>

* io/list_read.c (list_formatted_read_scalar) <case BT_CLASS>:
Change types of unit and noiostat to GFC_INTEGER_4 from int, change
type of child_iostat from to GFC_INTEGER_4 * from int *, formatting
fixes.
(nml_read_obj): Likewise.
* io/write.c (list_formatted_write_scalar) <case BT_CLASS>: Likewise.
(nml_write_obj): Likewise.
* io/transfer.c (unformatted_read, unformatted_write): Likewise.

libgfortran/io/list_read.c
libgfortran/io/transfer.c
libgfortran/io/write.c

index db3330060ce1d22d9695bd1f61c82d622947b452..765f8d7fb378c9ec0a388000b6d39d2bc9ea293d 100644 (file)
@@ -2189,14 +2189,14 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p,
       break;
     case BT_CLASS:
       {
-         int unit = dtp->u.p.current_unit->unit_number;
+         GFC_INTEGER_4 unit = dtp->u.p.current_unit->unit_number;
          char iotype[] = "LISTDIRECTED";
           gfc_charlen_type iotype_len = 12;
          char tmp_iomsg[IOMSG_LEN] = "";
          char *child_iomsg;
          gfc_charlen_type child_iomsg_len;
-         int noiostat;
-         int *child_iostat = NULL;
+         GFC_INTEGER_4 noiostat;
+         GFC_INTEGER_4 *child_iostat = NULL;
          gfc_full_array_i4 vlist;
 
          GFC_DESCRIPTOR_DATA(&vlist) = NULL;
@@ -2204,8 +2204,8 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p,
 
          /* Set iostat, intent(out).  */
          noiostat = 0;
-         child_iostat = (dtp->common.flags & IOPARM_HAS_IOSTAT) ?
-                         dtp->common.iostat : &noiostat;
+         child_iostat = ((dtp->common.flags & IOPARM_HAS_IOSTAT)
+                         ? dtp->common.iostat : &noiostat);
 
          /* Set iomsge, intent(inout).  */
          if (dtp->common.flags & IOPARM_HAS_IOMSG)
@@ -2987,14 +2987,14 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info *nl, index_type offset,
            /* If this object has a User Defined procedure, call it.  */
            if (nl->dtio_sub != NULL)
              {
-               int unit = dtp->u.p.current_unit->unit_number;
+               GFC_INTEGER_4 unit = dtp->u.p.current_unit->unit_number;
                char iotype[] = "NAMELIST";
                gfc_charlen_type iotype_len = 8;
                char tmp_iomsg[IOMSG_LEN] = "";
                char *child_iomsg;
                gfc_charlen_type child_iomsg_len;
-               int noiostat;
-               int *child_iostat = NULL;
+               GFC_INTEGER_4 noiostat;
+               GFC_INTEGER_4 *child_iostat = NULL;
                gfc_full_array_i4 vlist;
                formatted_dtio dtio_ptr = (formatted_dtio)nl->dtio_sub;
 
@@ -3006,8 +3006,8 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info *nl, index_type offset,
 
                /* Set iostat, intent(out).  */
                noiostat = 0;
-               child_iostat = (dtp->common.flags & IOPARM_HAS_IOSTAT) ?
-                               dtp->common.iostat : &noiostat;
+               child_iostat = ((dtp->common.flags & IOPARM_HAS_IOSTAT)
+                               ? dtp->common.iostat : &noiostat);
 
                /* Set iomsg, intent(inout).  */
                if (dtp->common.flags & IOPARM_HAS_IOMSG)
index 0104f6ccd696f65dae6747fd04540917505e58ba..500db90c828c11473850e02654329e7137a504f7 100644 (file)
@@ -1092,17 +1092,17 @@ unformatted_read (st_parameter_dt *dtp, bt type,
 
   if (type == BT_CLASS)
     {
-         int unit = dtp->u.p.current_unit->unit_number;
+         GFC_INTEGER_4 unit = dtp->u.p.current_unit->unit_number;
          char tmp_iomsg[IOMSG_LEN] = "";
          char *child_iomsg;
          gfc_charlen_type child_iomsg_len;
-         int noiostat;
-         int *child_iostat = NULL;
+         GFC_INTEGER_4 noiostat;
+         GFC_INTEGER_4 *child_iostat = NULL;
 
          /* Set iostat, intent(out).  */
          noiostat = 0;
-         child_iostat = (dtp->common.flags & IOPARM_HAS_IOSTAT) ?
-                         dtp->common.iostat : &noiostat;
+         child_iostat = ((dtp->common.flags & IOPARM_HAS_IOSTAT)
+                         ? dtp->common.iostat : &noiostat);
 
          /* Set iomsg, intent(inout).  */
          if (dtp->common.flags & IOPARM_HAS_IOMSG)
@@ -1119,7 +1119,7 @@ unformatted_read (st_parameter_dt *dtp, bt type,
          /* Call the user defined unformatted READ procedure.  */
          dtp->u.p.current_unit->child_dtio++;
          dtp->u.p.ufdtio_ptr (dest, &unit, child_iostat, child_iomsg,
-                             child_iomsg_len);
+                              child_iomsg_len);
          dtp->u.p.current_unit->child_dtio--;
          return;
     }
@@ -1222,17 +1222,17 @@ unformatted_write (st_parameter_dt *dtp, bt type,
 
   if (type == BT_CLASS)
     {
-         int unit = dtp->u.p.current_unit->unit_number;
+         GFC_INTEGER_4 unit = dtp->u.p.current_unit->unit_number;
          char tmp_iomsg[IOMSG_LEN] = "";
          char *child_iomsg;
          gfc_charlen_type child_iomsg_len;
-         int noiostat;
-         int *child_iostat = NULL;
+         GFC_INTEGER_4 noiostat;
+         GFC_INTEGER_4 *child_iostat = NULL;
 
          /* Set iostat, intent(out).  */
          noiostat = 0;
-         child_iostat = (dtp->common.flags & IOPARM_HAS_IOSTAT) ?
-                         dtp->common.iostat : &noiostat;
+         child_iostat = ((dtp->common.flags & IOPARM_HAS_IOSTAT)
+                         ? dtp->common.iostat : &noiostat);
 
          /* Set iomsg, intent(inout).  */
          if (dtp->common.flags & IOPARM_HAS_IOMSG)
@@ -1249,7 +1249,7 @@ unformatted_write (st_parameter_dt *dtp, bt type,
          /* Call the user defined unformatted WRITE procedure.  */
          dtp->u.p.current_unit->child_dtio++;
          dtp->u.p.ufdtio_ptr (source, &unit, child_iostat, child_iomsg,
-                             child_iomsg_len);
+                              child_iomsg_len);
          dtp->u.p.current_unit->child_dtio--;
          return;
     }
@@ -1688,13 +1688,13 @@ formatted_transfer_scalar_read (st_parameter_dt *dtp, bt type, void *p, int kind
            return;
          if (require_type (dtp, BT_CLASS, type, f))
            return;
-         int unit = dtp->u.p.current_unit->unit_number;
+         GFC_INTEGER_4 unit = dtp->u.p.current_unit->unit_number;
          char dt[] = "DT";
          char tmp_iomsg[IOMSG_LEN] = "";
          char *child_iomsg;
          gfc_charlen_type child_iomsg_len;
-         int noiostat;
-         int *child_iostat = NULL;
+         GFC_INTEGER_4 noiostat;
+         GFC_INTEGER_4 *child_iostat = NULL;
          char *iotype;
          gfc_charlen_type iotype_len = f->u.udf.string_len;
 
@@ -1709,8 +1709,8 @@ formatted_transfer_scalar_read (st_parameter_dt *dtp, bt type, void *p, int kind
 
          /* Set iostat, intent(out).  */
          noiostat = 0;
-         child_iostat = (dtp->common.flags & IOPARM_HAS_IOSTAT) ?
-                         dtp->common.iostat : &noiostat;
+         child_iostat = ((dtp->common.flags & IOPARM_HAS_IOSTAT)
+                         ? dtp->common.iostat : &noiostat);
 
          /* Set iomsg, intent(inout).  */
          if (dtp->common.flags & IOPARM_HAS_IOMSG)
@@ -2169,13 +2169,13 @@ formatted_transfer_scalar_write (st_parameter_dt *dtp, bt type, void *p, int kin
        case FMT_DT:
          if (n == 0)
            goto need_data;
-         int unit = dtp->u.p.current_unit->unit_number;
+         GFC_INTEGER_4 unit = dtp->u.p.current_unit->unit_number;
          char dt[] = "DT";
          char tmp_iomsg[IOMSG_LEN] = "";
          char *child_iomsg;
          gfc_charlen_type child_iomsg_len;
-         int noiostat;
-         int *child_iostat = NULL;
+         GFC_INTEGER_4 noiostat;
+         GFC_INTEGER_4 *child_iostat = NULL;
          char *iotype;
          gfc_charlen_type iotype_len = f->u.udf.string_len;
 
@@ -2190,8 +2190,8 @@ formatted_transfer_scalar_write (st_parameter_dt *dtp, bt type, void *p, int kin
 
          /* Set iostat, intent(out).  */
          noiostat = 0;
-         child_iostat = (dtp->common.flags & IOPARM_HAS_IOSTAT) ?
-                         dtp->common.iostat : &noiostat;
+         child_iostat = ((dtp->common.flags & IOPARM_HAS_IOSTAT)
+                         ? dtp->common.iostat : &noiostat);
 
          /* Set iomsg, intent(inout).  */
          if (dtp->common.flags & IOPARM_HAS_IOMSG)
index 00c8fd2e288e982e081a63479f982f1917ad951c..f94e180ba3307e2be43c6c194a5d41cd99305d41 100644 (file)
@@ -1952,14 +1952,14 @@ list_formatted_write_scalar (st_parameter_dt *dtp, bt type, void *p, int kind,
       break;
     case BT_CLASS:
       {
-         int unit = dtp->u.p.current_unit->unit_number;
+         GFC_INTEGER_4 unit = dtp->u.p.current_unit->unit_number;
          char iotype[] = "LISTDIRECTED";
          gfc_charlen_type iotype_len = 12;
          char tmp_iomsg[IOMSG_LEN] = "";
          char *child_iomsg;
          gfc_charlen_type child_iomsg_len;
-         int noiostat;
-         int *child_iostat = NULL;
+         GFC_INTEGER_4 noiostat;
+         GFC_INTEGER_4 *child_iostat = NULL;
          gfc_full_array_i4 vlist;
 
          GFC_DESCRIPTOR_DATA(&vlist) = NULL;
@@ -1967,8 +1967,8 @@ list_formatted_write_scalar (st_parameter_dt *dtp, bt type, void *p, int kind,
 
          /* Set iostat, intent(out).  */
          noiostat = 0;
-         child_iostat = (dtp->common.flags & IOPARM_HAS_IOSTAT) ?
-                         dtp->common.iostat : &noiostat;
+         child_iostat = ((dtp->common.flags & IOPARM_HAS_IOSTAT)
+                         ? dtp->common.iostat : &noiostat);
 
          /* Set iomsge, intent(inout).  */
          if (dtp->common.flags & IOPARM_HAS_IOMSG)
@@ -2277,14 +2277,14 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info *obj, index_type offset,
              /* First ext_name => get length of all possible components  */
              if (obj->dtio_sub != NULL)
                {
-                 int unit = dtp->u.p.current_unit->unit_number;
+                 GFC_INTEGER_4 unit = dtp->u.p.current_unit->unit_number;
                  char iotype[] = "NAMELIST";
                  gfc_charlen_type iotype_len = 8;
                  char tmp_iomsg[IOMSG_LEN] = "";
                  char *child_iomsg;
                  gfc_charlen_type child_iomsg_len;
-                 int noiostat;
-                 int *child_iostat = NULL;
+                 GFC_INTEGER_4 noiostat;
+                 GFC_INTEGER_4 *child_iostat = NULL;
                  gfc_full_array_i4 vlist;
                  formatted_dtio dtio_ptr = (formatted_dtio)obj->dtio_sub;
 
@@ -2292,8 +2292,8 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info *obj, index_type offset,
 
                  /* Set iostat, intent(out).  */
                  noiostat = 0;
-                 child_iostat = (dtp->common.flags & IOPARM_HAS_IOSTAT) ?
-                                 dtp->common.iostat : &noiostat;
+                 child_iostat = ((dtp->common.flags & IOPARM_HAS_IOSTAT)
+                                 ? dtp->common.iostat : &noiostat);
 
                  /* Set iomsg, intent(inout).  */
                  if (dtp->common.flags & IOPARM_HAS_IOMSG)