Fix small bug in compile.exp

Message ID 20231115194513.176487-1-tom@tromey.com
State New
Headers
Series Fix small bug in compile.exp |

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 warning Patch is already merged
linaro-tcwg-bot/tcwg_gdb_check--master-arm warning Patch is already merged

Commit Message

Tom Tromey Nov. 15, 2023, 7:45 p.m. UTC
  compile.exp generally does not work for me on Fedora 38.  However, I
sent a GCC patch to fix the plugin crash.  With that patch, I get this
error from one test in compile.exp:

gdb command line:1:22: warning: initialization of 'int (*)(int)' from incompatible pointer type 'int (*)()' [-Wincompatible-pointer-types]

This patch adds a cast to compile.exp.  This makes the test pass.
---
 gdb/testsuite/gdb.compile/compile.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Keith Seitz Nov. 15, 2023, 8:08 p.m. UTC | #1
On 11/15/23 11:45, Tom Tromey wrote:
> compile.exp generally does not work for me on Fedora 38.  However, I
> sent a GCC patch to fix the plugin crash.  With that patch, I get this
> error from one test in compile.exp: >
> gdb command line:1:22: warning: initialization of 'int (*)(int)' from incompatible pointer type 'int (*)()' [-Wincompatible-pointer-types]
> 
> This patch adds a cast to compile.exp.  This makes the test pass.

Thank you for addressing this. I *may* have it on my TODO to "clean" 
some of this up in the not-too-distant future.

> ---
>   gdb/testsuite/gdb.compile/compile.exp | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp
> index f2ab4fafa93..86521e99dac 100644
> --- a/gdb/testsuite/gdb.compile/compile.exp
> +++ b/gdb/testsuite/gdb.compile/compile.exp
> @@ -307,7 +307,7 @@ gdb_test "compile code globalvar = func_nodebug (75);" \
>       "call func_nodebug"
>   gdb_test "p globalvar" " = -75" "expect -75"
>   gdb_test \
> -    "compile code int (*funcp) (int) = func_nodebug; globalvar = funcp (76);" \
> +    "compile code int (*funcp) (int) = (int (*) (int)) func_nodebug; globalvar = funcp (76);" \
>       "warning: function has unknown return type; assuming int" \
>       "call func_nodebug indirectly"
>   gdb_test "p globalvar" " = -76" "expect -76"

LGTM

Reviewed-by: Keith Seitz <keiths@redhat.com>

Keith
  

Patch

diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp
index f2ab4fafa93..86521e99dac 100644
--- a/gdb/testsuite/gdb.compile/compile.exp
+++ b/gdb/testsuite/gdb.compile/compile.exp
@@ -307,7 +307,7 @@  gdb_test "compile code globalvar = func_nodebug (75);" \
     "call func_nodebug"
 gdb_test "p globalvar" " = -75" "expect -75"
 gdb_test \
-    "compile code int (*funcp) (int) = func_nodebug; globalvar = funcp (76);" \
+    "compile code int (*funcp) (int) = (int (*) (int)) func_nodebug; globalvar = funcp (76);" \
     "warning: function has unknown return type; assuming int" \
     "call func_nodebug indirectly"
 gdb_test "p globalvar" " = -76" "expect -76"