__attribute__(returns_nonnull)

Refine commit 4885653014.

> I'm not sure whether gcc 3 is really the right test for whether the
> returns_nonnull attribute setting is available.

The gcc.gnu.org website only goes back to 5.1, and searching the
documentation of that version for returns_nonnull finds it.  I used
ftp to get gcc-core-3.0.0 and gcc-core-4.0.0 and their doc files don't
mention this attribute.  It might have been added for some later 4.x
but that really doesn't matter for nethack's purposes.

Use __GNUC__ >= 5 instead of __GNUC__ >= 3 when testing whether
__attribute__(returns_nonnull) is available.
This commit is contained in:
PatR
2022-09-26 15:49:42 -07:00
parent fdd7b0c0b9
commit a9436f1311

View File

@@ -389,7 +389,7 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
#ifdef __clang__
/* clang's gcc emulation is sufficient for nethack's usage */
#ifndef __GNUC__
#define __GNUC__ 4
#define __GNUC__ 5 /* high enough for returns_nonnull */
#endif
#endif
@@ -404,7 +404,6 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
#if __GNUC__ >= 3
#define UNUSED __attribute__((unused))
#define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((returns_nonnull))
#if !defined(__linux__) || defined(GCC_URWARN)
/* disable gcc's __attribute__((__warn_unused_result__)) since explicitly
discarding the result by casting to (void) is not accepted as a 'use' */
@@ -412,6 +411,9 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
#define warn_unused_result /*empty*/
#endif
#endif
#if __GNUC__ >= 5
#define NONNULL __attribute__((returns_nonnull))
#endif
#endif
#ifndef PRINTF_F