sim: Fix -Wincompatible-pointer-types in frv/sem.c

Message ID 20240121230620.575972-1-mark@klomp.org
State New
Headers
Series sim: Fix -Wincompatible-pointer-types in frv/sem.c |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Mark Wielaard Jan. 21, 2024, 11:06 p.m. UTC
  GCC errors on -Wincompatible-pointer-types

sim/frv/sem.c: In function ‘frvbf_sem_mmachu’:
sim/frv/sem.c:24345:41: error: passing argument 2 of ‘sim_queue_fn_di_write’ from incompatible pointer type [-Wincompatible-pointer-types]
24345 |     sim_queue_fn_di_write (current_cpu, frvbf_h_acc40U_set, FLD (f_ACC40Uk), opval);
      |                                         ^~~~~~~~~~~~~~~~~~
      |                                         |
      |                                         void (*)(SIM_CPU *, UINT,  UDI) {aka void (*)(struct _sim_cpu *, unsigned int,  long unsigned int)}
In file included from ../../binutils-gdb/sim/common/cgen-cpu.h:25,
                 from ../../binutils-gdb/sim/common/sim-cpu.h:32,
                 from ../../binutils-gdb/sim/common/sim-base.h:90,
                 from ../../binutils-gdb/sim/frv/sim-main.h:41,
                 from ../../binutils-gdb/sim/frv/sem.c:28:
../../binutils-gdb/sim/common/cgen-par.h:195:47: note: expected ‘void (*)(SIM_CPU *, UINT,  DI)’ {aka ‘void (*)(struct _sim_cpu *, unsigned int,  long int)’} but argument is of type ‘void (*)(SIM_CPU *, UINT,  UDI)’ {aka ‘void (*)(struct _sim_cpu *, unsigned int,  long unsigned int)’}
  195 | extern void sim_queue_fn_di_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, DI), UINT, DI);
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The issue is that sim_queue_fn_di_write takes a function with a DI argument
but frvbf_h_acc40U_set takes a UDI. Since there is no sim_queue_fn that
takes a UDI just define frvbf_h_acc40U_set as if it takes a DI.
---
 sim/frv/cpu.c | 2 +-
 sim/frv/cpu.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

Mike Frysinger Jan. 22, 2024, 3:45 a.m. UTC | #1
On 22 Jan 2024 00:06, Mark Wielaard wrote:
> GCC errors on -Wincompatible-pointer-types
> 
> sim/frv/sem.c: In function ‘frvbf_sem_mmachu’:
> sim/frv/sem.c:24345:41: error: passing argument 2 of ‘sim_queue_fn_di_write’ from incompatible pointer type [-Wincompatible-pointer-types]
> 24345 |     sim_queue_fn_di_write (current_cpu, frvbf_h_acc40U_set, FLD (f_ACC40Uk), opval);
>       |                                         ^~~~~~~~~~~~~~~~~~
>       |                                         |
>       |                                         void (*)(SIM_CPU *, UINT,  UDI) {aka void (*)(struct _sim_cpu *, unsigned int,  long unsigned int)}
> In file included from ../../binutils-gdb/sim/common/cgen-cpu.h:25,
>                  from ../../binutils-gdb/sim/common/sim-cpu.h:32,
>                  from ../../binutils-gdb/sim/common/sim-base.h:90,
>                  from ../../binutils-gdb/sim/frv/sim-main.h:41,
>                  from ../../binutils-gdb/sim/frv/sem.c:28:
> ../../binutils-gdb/sim/common/cgen-par.h:195:47: note: expected ‘void (*)(SIM_CPU *, UINT,  DI)’ {aka ‘void (*)(struct _sim_cpu *, unsigned int,  long int)’} but argument is of type ‘void (*)(SIM_CPU *, UINT,  UDI)’ {aka ‘void (*)(struct _sim_cpu *, unsigned int,  long unsigned int)’}
>   195 | extern void sim_queue_fn_di_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, DI), UINT, DI);
>       |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> The issue is that sim_queue_fn_di_write takes a function with a DI argument
> but frvbf_h_acc40U_set takes a UDI. Since there is no sim_queue_fn that
> takes a UDI just define frvbf_h_acc40U_set as if it takes a DI.
> ---
>  sim/frv/cpu.c | 2 +-
>  sim/frv/cpu.h | 2 +-

unfortunately this doesn't work as cpu.[ch] is generated.

https://sourceware.org/pipermail/gdb-patches/2023-December/205492.html
https://sourceware.org/PR29752
-mike
  
Mark Wielaard Jan. 22, 2024, 11:30 a.m. UTC | #2
Hi Mike,

On Sun, 2024-01-21 at 22:45 -0500, Mike Frysinger wrote:
> On 22 Jan 2024 00:06, Mark Wielaard wrote:
> > GCC errors on -Wincompatible-pointer-types
> > 
> > sim/frv/sem.c: In function ‘frvbf_sem_mmachu’:
> > sim/frv/sem.c:24345:41: error: passing argument 2 of ‘sim_queue_fn_di_write’ from incompatible pointer type [-Wincompatible-pointer-types]
> > 24345 |     sim_queue_fn_di_write (current_cpu, frvbf_h_acc40U_set, FLD (f_ACC40Uk), opval);
> >       |                                         ^~~~~~~~~~~~~~~~~~
> >       |                                         |
> >       |                                         void (*)(SIM_CPU *, UINT,  UDI) {aka void (*)(struct _sim_cpu *, unsigned int,  long unsigned int)}
> > In file included from ../../binutils-gdb/sim/common/cgen-cpu.h:25,
> >                  from ../../binutils-gdb/sim/common/sim-cpu.h:32,
> >                  from ../../binutils-gdb/sim/common/sim-base.h:90,
> >                  from ../../binutils-gdb/sim/frv/sim-main.h:41,
> >                  from ../../binutils-gdb/sim/frv/sem.c:28:
> > ../../binutils-gdb/sim/common/cgen-par.h:195:47: note: expected ‘void (*)(SIM_CPU *, UINT,  DI)’ {aka ‘void (*)(struct _sim_cpu *, unsigned int,  long int)’} but argument is of type ‘void (*)(SIM_CPU *, UINT,  UDI)’ {aka ‘void (*)(struct _sim_cpu *, unsigned int,  long unsigned int)’}
> >   195 | extern void sim_queue_fn_di_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, DI), UINT, DI);
> >       |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > The issue is that sim_queue_fn_di_write takes a function with a DI argument
> > but frvbf_h_acc40U_set takes a UDI. Since there is no sim_queue_fn that
> > takes a UDI just define frvbf_h_acc40U_set as if it takes a DI.
> > ---
> >  sim/frv/cpu.c | 2 +-
> >  sim/frv/cpu.h | 2 +-
> 
> unfortunately this doesn't work as cpu.[ch] is generated.
> 
> https://sourceware.org/pipermail/gdb-patches/2023-December/205492.html
> https://sourceware.org/PR29752

O, that is unfortunate. I admit to not know how to actually regenerate
these files. Also it seems PR29752 does include a solution. What kind
of testing would you like to see to make sure it is correct?

Thanks,

Mark
  
Mike Frysinger Jan. 22, 2024, 1:15 p.m. UTC | #3
On 22 Jan 2024 12:30, Mark Wielaard wrote:
> On Sun, 2024-01-21 at 22:45 -0500, Mike Frysinger wrote:
> > On 22 Jan 2024 00:06, Mark Wielaard wrote:
> > > The issue is that sim_queue_fn_di_write takes a function with a DI argument
> > > but frvbf_h_acc40U_set takes a UDI. Since there is no sim_queue_fn that
> > > takes a UDI just define frvbf_h_acc40U_set as if it takes a DI.
> > > ---
> > >  sim/frv/cpu.c | 2 +-
> > >  sim/frv/cpu.h | 2 +-
> > 
> > unfortunately this doesn't work as cpu.[ch] is generated.
> > 
> > https://sourceware.org/pipermail/gdb-patches/2023-December/205492.html
> > https://sourceware.org/PR29752
> 
> O, that is unfortunate. I admit to not know how to actually regenerate
> these files.

`make frv/cgen` would do it for frv

> Also it seems PR29752 does include a solution. What kind
> of testing would you like to see to make sure it is correct?

i don't understand frv internals/whatever well enough to know if my proposal
is reasonable.  although if we don't get a response, i guess there isn't much
choice as things fail to build with newer compilers.
-mike
  

Patch

diff --git a/sim/frv/cpu.c b/sim/frv/cpu.c
index b28bcd72d66..2aaa3f22953 100644
--- a/sim/frv/cpu.c
+++ b/sim/frv/cpu.c
@@ -631,7 +631,7 @@  frvbf_h_acc40U_get (SIM_CPU *current_cpu, UINT regno)
 /* Set a value for h-acc40U.  */
 
 void
-frvbf_h_acc40U_set (SIM_CPU *current_cpu, UINT regno, UDI newval)
+frvbf_h_acc40U_set (SIM_CPU *current_cpu, UINT regno, DI newval)
 {
   SET_H_ACC40U (regno, newval);
 }
diff --git a/sim/frv/cpu.h b/sim/frv/cpu.h
index ab5f2d1b539..a099e975d8e 100644
--- a/sim/frv/cpu.h
+++ b/sim/frv/cpu.h
@@ -352,7 +352,7 @@  void frvbf_h_accg_set (SIM_CPU *, UINT, USI);
 DI frvbf_h_acc40S_get (SIM_CPU *, UINT);
 void frvbf_h_acc40S_set (SIM_CPU *, UINT, DI);
 UDI frvbf_h_acc40U_get (SIM_CPU *, UINT);
-void frvbf_h_acc40U_set (SIM_CPU *, UINT, UDI);
+void frvbf_h_acc40U_set (SIM_CPU *, UINT, DI);
 DI frvbf_h_iacc0_get (SIM_CPU *, UINT);
 void frvbf_h_iacc0_set (SIM_CPU *, UINT, DI);
 UQI frvbf_h_iccr_get (SIM_CPU *, UINT);