]> git.ipfire.org Git - thirdparty/gcc.git/commit
libssp: Fix gets-chk.c compilation on Solaris
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 6 Feb 2024 10:45:45 +0000 (11:45 +0100)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 6 Feb 2024 10:45:45 +0000 (11:45 +0100)
commit3cec49119681d43fd613285a5cad43313d27eb3d
tree78661705334f88567686f7606ee27ff8e08cf767
parentca04e7a2e1b08ed02e22e2656ba6032099195856
libssp: Fix gets-chk.c compilation on Solaris

The recent warning patches broke the libssp build on Solaris:

/vol/gcc/src/hg/master/local/libssp/gets-chk.c: In function '__gets_chk':
/vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: implicit
declaration of function 'gets'; did you mean 'getw'?
[-Wimplicit-function-declaration]
   67 |     return gets (s);
      |            ^~~~
      |            getw
/vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: returning
'int' from a function with return type 'char *' makes pointer from integer
without a cast [-Wint-conversion]
   67 |     return gets (s);
      |            ^~~~~~~~
/vol/gcc/src/hg/master/local/libssp/gets-chk.c:74:12: error: returning
'int' from a function with return type 'char *' makes pointer from integer
without a cast [-Wint-conversion]
   74 |     return gets (s);
      |            ^~~~~~~~

The guard around the gets declaration in gets-chk.c is

      || (defined __cplusplus && __cplusplus <= 201103L))
extern char *gets (char *);

where __USE_ISOC11 is glibc-only, while Solaris <iso/stdio_iso.h> declares
gets like

extern char     *gets(char *) __ATTR_DEPRECATED;

Instead of using a target-specific macro, this patch just uses the
canonical autoconf test.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11,
x86_64-pc-linux-gnu, x86_64-apple-darwin23.3.0, and amd64-freebsd14.0.

2023-12-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libssp:
* configure.ac (AC_CHECK_DECLS): Check for gets.
* configure, config.h.in: Regenerate.
* gets-chk.c (gets): Guard declaration with !HAVE_DECL_GETS.
libssp/config.h.in
libssp/configure
libssp/configure.ac
libssp/gets-chk.c