public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors
       [not found]     ` <87zfypvv6t.fsf@oldenburg.str.redhat.com>
@ 2023-12-05 10:33       ` Jakub Jelinek
  2023-12-05 10:47         ` Richard Earnshaw
  2023-12-05 13:35         ` Tobias Burnus
  0 siblings, 2 replies; 8+ messages in thread
From: Jakub Jelinek @ 2023-12-05 10:33 UTC (permalink / raw)
  To: Tobias Burnus, Florian Weimer; +Cc: Richard Earnshaw, gcc-patches, fortran

Hi!

On Tue, Dec 05, 2023 at 10:46:02AM +0100, Florian Weimer wrote:
> Presumably the fixes will look like this?
> 
> diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
> index db3330060ce..4fcc77dbf83 100644
> --- a/libgfortran/io/list_read.c
> +++ b/libgfortran/io/list_read.c
> @@ -2987,13 +2987,13 @@ 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;
> +		GFC_INTEGER_4 noiostat;
>  		int *child_iostat = NULL;
>  		gfc_full_array_i4 vlist;
>  		formatted_dtio dtio_ptr = (formatted_dtio)nl->dtio_sub;

That seems insufficient.

The following patch makes libgfortran build on i686-linux after hacking up
--- kinds.h.xx	2023-12-05 00:23:00.133365064 +0100
+++ kinds.h	2023-12-05 11:19:24.409679808 +0100
@@ -10,8 +10,8 @@ typedef GFC_INTEGER_2 GFC_LOGICAL_2;
 #define HAVE_GFC_LOGICAL_2
 #define HAVE_GFC_INTEGER_2
 
-typedef int32_t GFC_INTEGER_4;
-typedef uint32_t GFC_UINTEGER_4;
+typedef long GFC_INTEGER_4;
+typedef unsigned long GFC_UINTEGER_4;
 typedef GFC_INTEGER_4 GFC_LOGICAL_4;
 #define HAVE_GFC_LOGICAL_4
 #define HAVE_GFC_INTEGER_4
in the build dir to emulate what newlib aarch64 is doing:

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.jj	2023-05-09 00:07:26.161168737 +0200
+++ libgfortran/io/list_read.c	2023-12-05 11:25:31.837426653 +0100
@@ -2189,14 +2189,14 @@ list_formatted_read_scalar (st_parameter
       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
 
 	  /* 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, name
 	    /* 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, name
 
 		/* 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)
--- libgfortran/io/write.c.jj	2023-09-28 21:49:38.632795791 +0200
+++ libgfortran/io/write.c	2023-12-05 11:26:27.763627070 +0100
@@ -1952,14 +1952,14 @@ list_formatted_write_scalar (st_paramete
       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_paramete
 
 	  /* 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, nam
 	      /* 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, nam
 
 		  /* 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)
--- libgfortran/io/transfer.c.jj	2023-05-09 00:07:26.162168723 +0200
+++ libgfortran/io/transfer.c	2023-12-05 11:25:15.756656561 +0100
@@ -1092,17 +1092,17 @@ unformatted_read (st_parameter_dt *dtp,
 
   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,
 	  /* 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,
 
   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,
 	  /* 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_param
 	    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_param
 
 	  /* 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_para
 	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_para
 
 	  /* 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)


	Jakub


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors
  2023-12-05 10:33       ` [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors Jakub Jelinek
@ 2023-12-05 10:47         ` Richard Earnshaw
  2023-12-05 10:51           ` Jakub Jelinek
  2023-12-05 13:35         ` Tobias Burnus
  1 sibling, 1 reply; 8+ messages in thread
From: Richard Earnshaw @ 2023-12-05 10:47 UTC (permalink / raw)
  To: Jakub Jelinek, Tobias Burnus, Florian Weimer; +Cc: gcc-patches, fortran



On 05/12/2023 10:33, Jakub Jelinek wrote:
> Hi!
> 
> On Tue, Dec 05, 2023 at 10:46:02AM +0100, Florian Weimer wrote:
>> Presumably the fixes will look like this?
>>
>> diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
>> index db3330060ce..4fcc77dbf83 100644
>> --- a/libgfortran/io/list_read.c
>> +++ b/libgfortran/io/list_read.c
>> @@ -2987,13 +2987,13 @@ 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;
>> +		GFC_INTEGER_4 noiostat;
>>   		int *child_iostat = NULL;
>>   		gfc_full_array_i4 vlist;
>>   		formatted_dtio dtio_ptr = (formatted_dtio)nl->dtio_sub;
> 
> That seems insufficient.
> 
> The following patch makes libgfortran build on i686-linux after hacking up
> --- kinds.h.xx	2023-12-05 00:23:00.133365064 +0100
> +++ kinds.h	2023-12-05 11:19:24.409679808 +0100
> @@ -10,8 +10,8 @@ typedef GFC_INTEGER_2 GFC_LOGICAL_2;
>   #define HAVE_GFC_LOGICAL_2
>   #define HAVE_GFC_INTEGER_2
>   
> -typedef int32_t GFC_INTEGER_4;
> -typedef uint32_t GFC_UINTEGER_4;
> +typedef long GFC_INTEGER_4;
> +typedef unsigned long GFC_UINTEGER_4;

That doesn't look right for a 64-bit processor.  Presumably 4 means 4 
bytes, but long will generally be 8 on such targets.

R.

>   typedef GFC_INTEGER_4 GFC_LOGICAL_4;
>   #define HAVE_GFC_LOGICAL_4
>   #define HAVE_GFC_INTEGER_4
> in the build dir to emulate what newlib aarch64 is doing:
> 
> 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.jj	2023-05-09 00:07:26.161168737 +0200
> +++ libgfortran/io/list_read.c	2023-12-05 11:25:31.837426653 +0100
> @@ -2189,14 +2189,14 @@ list_formatted_read_scalar (st_parameter
>         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
>   
>   	  /* 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, name
>   	    /* 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, name
>   
>   		/* 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)
> --- libgfortran/io/write.c.jj	2023-09-28 21:49:38.632795791 +0200
> +++ libgfortran/io/write.c	2023-12-05 11:26:27.763627070 +0100
> @@ -1952,14 +1952,14 @@ list_formatted_write_scalar (st_paramete
>         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_paramete
>   
>   	  /* 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, nam
>   	      /* 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, nam
>   
>   		  /* 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)
> --- libgfortran/io/transfer.c.jj	2023-05-09 00:07:26.162168723 +0200
> +++ libgfortran/io/transfer.c	2023-12-05 11:25:15.756656561 +0100
> @@ -1092,17 +1092,17 @@ unformatted_read (st_parameter_dt *dtp,
>   
>     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,
>   	  /* 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,
>   
>     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,
>   	  /* 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_param
>   	    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_param
>   
>   	  /* 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_para
>   	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_para
>   
>   	  /* 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)
> 
> 
> 	Jakub
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors
  2023-12-05 10:47         ` Richard Earnshaw
@ 2023-12-05 10:51           ` Jakub Jelinek
  2023-12-05 10:57             ` Richard Earnshaw
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2023-12-05 10:51 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Tobias Burnus, Florian Weimer, gcc-patches, fortran

On Tue, Dec 05, 2023 at 10:47:34AM +0000, Richard Earnshaw wrote:
> > The following patch makes libgfortran build on i686-linux after hacking up
> > --- kinds.h.xx	2023-12-05 00:23:00.133365064 +0100
> > +++ kinds.h	2023-12-05 11:19:24.409679808 +0100
> > @@ -10,8 +10,8 @@ typedef GFC_INTEGER_2 GFC_LOGICAL_2;
> >   #define HAVE_GFC_LOGICAL_2
> >   #define HAVE_GFC_INTEGER_2
> > -typedef int32_t GFC_INTEGER_4;
> > -typedef uint32_t GFC_UINTEGER_4;
> > +typedef long GFC_INTEGER_4;
> > +typedef unsigned long GFC_UINTEGER_4;
> 
> That doesn't look right for a 64-bit processor.  Presumably 4 means 4 bytes,

i686-linux is an ILP32 target, which I chose exactly because I regularly build
it, had a tree with it around and because unlike 64-bit targets there are 2
standard 32-bit signed integer types.  Though, normally int32_t there is
int rather than long int and so the errors only appeared after this hack.

	Jakub


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors
  2023-12-05 10:51           ` Jakub Jelinek
@ 2023-12-05 10:57             ` Richard Earnshaw
  2023-12-05 10:59               ` Jakub Jelinek
  2023-12-05 11:00               ` Florian Weimer
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Earnshaw @ 2023-12-05 10:57 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Tobias Burnus, Florian Weimer, gcc-patches, fortran



On 05/12/2023 10:51, Jakub Jelinek wrote:
> On Tue, Dec 05, 2023 at 10:47:34AM +0000, Richard Earnshaw wrote:
>>> The following patch makes libgfortran build on i686-linux after hacking up
>>> --- kinds.h.xx	2023-12-05 00:23:00.133365064 +0100
>>> +++ kinds.h	2023-12-05 11:19:24.409679808 +0100
>>> @@ -10,8 +10,8 @@ typedef GFC_INTEGER_2 GFC_LOGICAL_2;
>>>    #define HAVE_GFC_LOGICAL_2
>>>    #define HAVE_GFC_INTEGER_2
>>> -typedef int32_t GFC_INTEGER_4;
>>> -typedef uint32_t GFC_UINTEGER_4;
>>> +typedef long GFC_INTEGER_4;
>>> +typedef unsigned long GFC_UINTEGER_4;
>>
>> That doesn't look right for a 64-bit processor.  Presumably 4 means 4 bytes,
> 
> i686-linux is an ILP32 target, which I chose exactly because I regularly build
> it, had a tree with it around and because unlike 64-bit targets there are 2
> standard 32-bit signed integer types.  Though, normally int32_t there is
> int rather than long int and so the errors only appeared after this hack.
> 

My point is that on aarch64/x86_64 etc, this will make GFC_INTEGER_4 a 
64-bit type, whereas previously it was 32-bit.

R.

> 	Jakub
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors
  2023-12-05 10:57             ` Richard Earnshaw
@ 2023-12-05 10:59               ` Jakub Jelinek
  2023-12-05 17:35                 ` Richard Earnshaw
  2023-12-05 11:00               ` Florian Weimer
  1 sibling, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2023-12-05 10:59 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Tobias Burnus, Florian Weimer, gcc-patches, fortran

On Tue, Dec 05, 2023 at 10:57:50AM +0000, Richard Earnshaw wrote:
> On 05/12/2023 10:51, Jakub Jelinek wrote:
> > On Tue, Dec 05, 2023 at 10:47:34AM +0000, Richard Earnshaw wrote:
> > > > The following patch makes libgfortran build on i686-linux after hacking up
> > > > --- kinds.h.xx	2023-12-05 00:23:00.133365064 +0100
> > > > +++ kinds.h	2023-12-05 11:19:24.409679808 +0100
> > > > @@ -10,8 +10,8 @@ typedef GFC_INTEGER_2 GFC_LOGICAL_2;
> > > >    #define HAVE_GFC_LOGICAL_2
> > > >    #define HAVE_GFC_INTEGER_2
> > > > -typedef int32_t GFC_INTEGER_4;
> > > > -typedef uint32_t GFC_UINTEGER_4;
> > > > +typedef long GFC_INTEGER_4;
> > > > +typedef unsigned long GFC_UINTEGER_4;
> > > 
> > > That doesn't look right for a 64-bit processor.  Presumably 4 means 4 bytes,
> > 
> > i686-linux is an ILP32 target, which I chose exactly because I regularly build
> > it, had a tree with it around and because unlike 64-bit targets there are 2
> > standard 32-bit signed integer types.  Though, normally int32_t there is
> > int rather than long int and so the errors only appeared after this hack.
> > 
> 
> My point is that on aarch64/x86_64 etc, this will make GFC_INTEGER_4 a
> 64-bit type, whereas previously it was 32-bit.

Sure.  The above patch is a hack for a generated header.  I'm not proposing
that as a change, just explaining how I've verified the actual patch on
i686-linux with such a hack.

	Jakub


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors
  2023-12-05 10:57             ` Richard Earnshaw
  2023-12-05 10:59               ` Jakub Jelinek
@ 2023-12-05 11:00               ` Florian Weimer
  1 sibling, 0 replies; 8+ messages in thread
From: Florian Weimer @ 2023-12-05 11:00 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Jakub Jelinek, Tobias Burnus, gcc-patches, fortran

* Richard Earnshaw:

> On 05/12/2023 10:51, Jakub Jelinek wrote:
>> On Tue, Dec 05, 2023 at 10:47:34AM +0000, Richard Earnshaw wrote:
>>>> The following patch makes libgfortran build on i686-linux after hacking up
>>>> --- kinds.h.xx	2023-12-05 00:23:00.133365064 +0100
>>>> +++ kinds.h	2023-12-05 11:19:24.409679808 +0100
>>>> @@ -10,8 +10,8 @@ typedef GFC_INTEGER_2 GFC_LOGICAL_2;
>>>>    #define HAVE_GFC_LOGICAL_2
>>>>    #define HAVE_GFC_INTEGER_2
>>>> -typedef int32_t GFC_INTEGER_4;
>>>> -typedef uint32_t GFC_UINTEGER_4;
>>>> +typedef long GFC_INTEGER_4;
>>>> +typedef unsigned long GFC_UINTEGER_4;
>>>
>>> That doesn't look right for a 64-bit processor.  Presumably 4 means 4 bytes,
>> i686-linux is an ILP32 target, which I chose exactly because I
>> regularly build
>> it, had a tree with it around and because unlike 64-bit targets there are 2
>> standard 32-bit signed integer types.  Though, normally int32_t there is
>> int rather than long int and so the errors only appeared after this hack.
>> 
>
> My point is that on aarch64/x86_64 etc, this will make GFC_INTEGER_4 a
> 64-bit type, whereas previously it was 32-bit.

I think it's not part of the submission, it was for local testing only.
It confused me as well. 8-)

Thanks,
Florian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors
  2023-12-05 10:33       ` [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors Jakub Jelinek
  2023-12-05 10:47         ` Richard Earnshaw
@ 2023-12-05 13:35         ` Tobias Burnus
  1 sibling, 0 replies; 8+ messages in thread
From: Tobias Burnus @ 2023-12-05 13:35 UTC (permalink / raw)
  To: Jakub Jelinek, Florian Weimer; +Cc: Richard Earnshaw, gcc-patches, fortran

Hi all,

the patch submission looks confusing as the context is a bit unclear
(aarch64 having two integer types?) and the slightly unmotivated 'long'
change (as explained in later emails: used as trick to find all
locations that should be changed and not being part of actually proposed
patch).

However, once this has been disentangled, the patch LGTM, assuming and
being positive that no aarch64 maintainer sees a problem.

Tobias

On 05.12.23 11:33, Jakub Jelinek wrote:
> On Tue, Dec 05, 2023 at 10:46:02AM +0100, Florian Weimer wrote:
>> Presumably the fixes will look like this?
>>
>> diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
>> index db3330060ce..4fcc77dbf83 100644
>> --- a/libgfortran/io/list_read.c
>> +++ b/libgfortran/io/list_read.c
>> @@ -2987,13 +2987,13 @@ 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;
>> +            GFC_INTEGER_4 noiostat;
>>              int *child_iostat = NULL;
>>              gfc_full_array_i4 vlist;
>>              formatted_dtio dtio_ptr = (formatted_dtio)nl->dtio_sub;
> That seems insufficient.
>
> The following patch makes libgfortran build on i686-linux after hacking up
> --- kinds.h.xx        2023-12-05 00:23:00.133365064 +0100
> +++ kinds.h   2023-12-05 11:19:24.409679808 +0100
> @@ -10,8 +10,8 @@ typedef GFC_INTEGER_2 GFC_LOGICAL_2;
>   #define HAVE_GFC_LOGICAL_2
>   #define HAVE_GFC_INTEGER_2
>
> -typedef int32_t GFC_INTEGER_4;
> -typedef uint32_t GFC_UINTEGER_4;
> +typedef long GFC_INTEGER_4;
> +typedef unsigned long GFC_UINTEGER_4;
>   typedef GFC_INTEGER_4 GFC_LOGICAL_4;
>   #define HAVE_GFC_LOGICAL_4
>   #define HAVE_GFC_INTEGER_4
> in the build dir to emulate what newlib aarch64 is doing:
>
> 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.jj     2023-05-09 00:07:26.161168737 +0200
> +++ libgfortran/io/list_read.c        2023-12-05 11:25:31.837426653 +0100
> @@ -2189,14 +2189,14 @@ list_formatted_read_scalar (st_parameter
>         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
>
>         /* 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, name
>           /* 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, name
>
>               /* 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)
> --- libgfortran/io/write.c.jj 2023-09-28 21:49:38.632795791 +0200
> +++ libgfortran/io/write.c    2023-12-05 11:26:27.763627070 +0100
> @@ -1952,14 +1952,14 @@ list_formatted_write_scalar (st_paramete
>         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_paramete
>
>         /* 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, nam
>             /* 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, nam
>
>                 /* 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)
> --- libgfortran/io/transfer.c.jj      2023-05-09 00:07:26.162168723 +0200
> +++ libgfortran/io/transfer.c 2023-12-05 11:25:15.756656561 +0100
> @@ -1092,17 +1092,17 @@ unformatted_read (st_parameter_dt *dtp,
>
>     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,
>         /* 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,
>
>     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,
>         /* 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_param
>           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_param
>
>         /* 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_para
>       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_para
>
>         /* 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)
>
>
>       Jakub
>
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors
  2023-12-05 10:59               ` Jakub Jelinek
@ 2023-12-05 17:35                 ` Richard Earnshaw
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Earnshaw @ 2023-12-05 17:35 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Tobias Burnus, Florian Weimer, gcc-patches, fortran



On 05/12/2023 10:59, Jakub Jelinek wrote:
> On Tue, Dec 05, 2023 at 10:57:50AM +0000, Richard Earnshaw wrote:
>> On 05/12/2023 10:51, Jakub Jelinek wrote:
>>> On Tue, Dec 05, 2023 at 10:47:34AM +0000, Richard Earnshaw wrote:
>>>>> The following patch makes libgfortran build on i686-linux after hacking up
>>>>> --- kinds.h.xx	2023-12-05 00:23:00.133365064 +0100
>>>>> +++ kinds.h	2023-12-05 11:19:24.409679808 +0100
>>>>> @@ -10,8 +10,8 @@ typedef GFC_INTEGER_2 GFC_LOGICAL_2;
>>>>>     #define HAVE_GFC_LOGICAL_2
>>>>>     #define HAVE_GFC_INTEGER_2
>>>>> -typedef int32_t GFC_INTEGER_4;
>>>>> -typedef uint32_t GFC_UINTEGER_4;
>>>>> +typedef long GFC_INTEGER_4;
>>>>> +typedef unsigned long GFC_UINTEGER_4;
>>>>
>>>> That doesn't look right for a 64-bit processor.  Presumably 4 means 4 bytes,
>>>
>>> i686-linux is an ILP32 target, which I chose exactly because I regularly build
>>> it, had a tree with it around and because unlike 64-bit targets there are 2
>>> standard 32-bit signed integer types.  Though, normally int32_t there is
>>> int rather than long int and so the errors only appeared after this hack.
>>>
>>
>> My point is that on aarch64/x86_64 etc, this will make GFC_INTEGER_4 a
>> 64-bit type, whereas previously it was 32-bit.
> 
> Sure.  The above patch is a hack for a generated header.  I'm not proposing
> that as a change, just explaining how I've verified the actual patch on
> i686-linux with such a hack.
> 
> 	Jakub
> 

Ah, I understand now.

I've successfully built arm and aarch64 cross toolchains with this patch 
(newlib).  So LGTM, thanks.

R.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-12-05 17:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1700473918.git.fweimer@redhat.com>
     [not found] ` <9e40a64880a14cf27d788ecbaf23365b9a5ac069.1700473918.git.fweimer@redhat.com>
     [not found]   ` <c1c981c8-d6a1-4c45-a5e4-3a392035061e@foss.arm.com>
     [not found]     ` <87zfypvv6t.fsf@oldenburg.str.redhat.com>
2023-12-05 10:33       ` [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors Jakub Jelinek
2023-12-05 10:47         ` Richard Earnshaw
2023-12-05 10:51           ` Jakub Jelinek
2023-12-05 10:57             ` Richard Earnshaw
2023-12-05 10:59               ` Jakub Jelinek
2023-12-05 17:35                 ` Richard Earnshaw
2023-12-05 11:00               ` Florian Weimer
2023-12-05 13:35         ` Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).