Subject: bug#76816: Issues in testgluse.c

From: Jan Dubiec <[email-masked]>
Date: Fri, 7 Mar 2025 15:22:54 +0100

Hello,

When I tried to run newlib tests on the GNU arm simulator, development version of gcc complained about a few issues in testgluse.c. The suggested patch is in the attachment.

Excerpt from the log:

Test run by jdx on Thu Mar  6 22:00:01 2025
Target is arm-unknown-eabi
Host   is x86_64-pc-linux-gnu

		=== newlib tests ===

Schedule of variations:
     arm-sim

Running target arm-sim
Using /usr/share/dejagnu/baseboards/arm-sim.exp as board description file for target.
Using /usr/share/dejagnu/config/sim.exp as generic interface file for target.
Using /usr/share/dejagnu/baseboards/basic-sim.exp as board description file for target.
Using /mnt/Works/testgcc/combosrc/newlib/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /mnt/Works/testgcc/combosrc/newlib/testsuite/newlib.elix/elix.exp ...
Executing on host: /mnt/Works/testgcc/build-arm-linux/gcc/xgcc -B/mnt/Works/testgcc/build-arm-linux/gcc/    -c   -isystem /mnt/Works/testgcc/build-arm-linux/arm-eabi/./newlib/targ-include -isystem /mnt/Works/testgcc/combosrc/newlib/libc/include -o /mnt/Works/testgcc/build-arm-linux/arm-eabi/newlib/testsuite/testglue.o /usr/share/dejagnu/testglue.c    (timeout = 300)
spawn -ignore SIGHUP /mnt/Works/testgcc/build-arm-linux/gcc/xgcc -B/mnt/Works/testgcc/build-arm-linux/gcc/ -c -isystem /mnt/Works/testgcc/build-arm-linux/arm-eabi/./newlib/targ-include -isystem /mnt/Works/testgcc/combosrc/newlib/libc/include -o /mnt/Works/testgcc/build-arm-linux/arm-eabi/newlib/testsuite/testglue.o /usr/share/dejagnu/testglue.c
/usr/share/dejagnu/testglue.c: In function 'write_int':
/usr/share/dejagnu/testglue.c:67:1: warning: old-style function definition []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-old-style-definition-Wold-style-definition]8;;]
    67 | write_int(val, ptr)
       | ^~~~~~~~~
/usr/share/dejagnu/testglue.c: In function '__wrap_exit':
/usr/share/dejagnu/testglue.c:38:19: warning: old-style function definition []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-old-style-definition-Wold-style-definition]8;;]
    38 | #define ORIG_EXIT __wrap_exit
       |                   ^~~~~~~~~~~
/usr/share/dejagnu/testglue.c:85:1: note: in expansion of macro 'ORIG_EXIT'
    85 | ORIG_EXIT (code)
       | ^~~~~~~~~
/usr/share/dejagnu/testglue.c:32:19: error: too many arguments to function '__real_exit'; expected 0, have 1
    32 | #define REAL_EXIT __real_exit
       |                   ^~~~~~~~~~~
/usr/share/dejagnu/testglue.c:99:3: note: in expansion of macro 'REAL_EXIT'
    99 |   REAL_EXIT (code);
       |   ^~~~~~~~~
/usr/share/dejagnu/testglue.c:32:19: note: declared here
    32 | #define REAL_EXIT __real_exit
       |                   ^~~~~~~~~~~
/usr/share/dejagnu/testglue.c:51:13: note: in expansion of macro 'REAL_EXIT'
    51 | extern void REAL_EXIT ();
       |             ^~~~~~~~~
/usr/share/dejagnu/testglue.c: In function '__wrap__exit':
/usr/share/dejagnu/testglue.c:39:20: warning: old-style function definition []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-old-style-definition-Wold-style-definition]8;;]
    39 | #define ORIG__EXIT __wrap__exit
       |                    ^~~~~~~~~~~~
/usr/share/dejagnu/testglue.c:105:1: note: in expansion of macro 'ORIG__EXIT'
   105 | ORIG__EXIT (code)
       | ^~~~~~~~~~
/usr/share/dejagnu/testglue.c:34:20: error: too many arguments to function '__real__exit'; expected 0, have 1
    34 | #define REAL__EXIT __real__exit
       |                    ^~~~~~~~~~~~
/usr/share/dejagnu/testglue.c:120:3: note: in expansion of macro 'REAL__EXIT'
   120 |   REAL__EXIT (code);
       |   ^~~~~~~~~~
/usr/share/dejagnu/testglue.c:34:20: note: declared here
    34 | #define REAL__EXIT __real__exit
       |                    ^~~~~~~~~~~~
/usr/share/dejagnu/testglue.c:56:13: note: in expansion of macro 'REAL__EXIT'
    56 | extern void REAL__EXIT ();
       |             ^~~~~~~~~~
/usr/share/dejagnu/testglue.c: In function '__wrap_main':
/usr/share/dejagnu/testglue.c:41:19: warning: old-style function definition []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-old-style-definition-Wold-style-definition]8;;]
    41 | #define ORIG_MAIN __wrap_main
       |                   ^~~~~~~~~~~
/usr/share/dejagnu/testglue.c:136:1: note: in expansion of macro 'ORIG_MAIN'
   136 | ORIG_MAIN (argc, argv, envp)
       | ^~~~~~~~~
compiler exited with status 1

Compiler version:

jdx@jdxpc:/mnt/Works/testgcc/build-arm-linux$ ./gcc/xgcc -v
Using built-in specs.
COLLECT_GCC=./gcc/xgcc
Target: arm-eabi
Configured with: ../combosrc/configure --prefix=/mnt/Works/testgcc/install-linux --target=arm-eabi --disable-werror --disable-nls --disable-threads --disable-tls --enable-checking=release --enable-languages=c --with-newlib --disable-multilib --enable-lto --disable-shared --enable-static --disable-libstdcxx-pch --without-libstdcxx-zoneinfo --with-system-zlib --with-pkgversion='GNU Toolchain for the ARM Architecture [Built by jdx]' --enable-tui --with-curses --enable-sim --with-expat
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 15.0.1 20250227 (experimental) (GNU Toolchain for the ARM Architecture [Built by jdx])

Best regards,
Jan

 testglue.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/testglue.c b/testglue.c
index 06f4a90..d0f7c40 100644
--- a/testglue.c
+++ b/testglue.c
@@ -48,12 +48,12 @@ extern void exit (int);
 #endif
 
 #ifdef REAL_MAIN
-extern void REAL_EXIT ();
+extern void REAL_EXIT (int code);
 extern void REAL_ABORT ();
 extern int REAL_MAIN (int argc, char **argv, char **envp);
 #endif
 #ifdef REAL__EXIT
-extern void REAL__EXIT ();
+extern void REAL__EXIT (int code);
 #endif
 
 static int done_exit_message = 0;
@@ -64,9 +64,7 @@ static void __runexit();
 #endif
 
 static char *
-write_int(val, ptr)
-     int val;
-     char *ptr;
+write_int(int val, char *ptr)
 {
   char c;
   if (val<0) {
@@ -82,8 +80,7 @@ write_int(val, ptr)
 }
 
 void
-ORIG_EXIT (code)
-     int code;
+ORIG_EXIT (int code)
 {
   char buf[30];
   char *ptr;
@@ -102,8 +99,7 @@ ORIG_EXIT (code)
 
 #ifdef ORIG__EXIT
 void
-ORIG__EXIT (code)
-     int code;
+ORIG__EXIT (int code)
 {
   char buf[30];
   char *ptr;
@@ -133,10 +129,7 @@ ORIG_ABORT ()
 
 #ifdef REAL_MAIN
 int
-ORIG_MAIN (argc, argv, envp)
-     int argc;
-     char **argv;
-     char **envp;
+ORIG_MAIN (int argc, char **argv, char **envp)
 {
 #ifdef WRAP_FILE_ARGS
   extern int __argc;
@@ -152,8 +145,7 @@ ORIG_MAIN (argc, argv, envp)
 
 #ifdef VXWORKS
 void
-_exit (status)
-     int status;
+_exit (int status)
 {
   REAL_EXIT (status);
 }