diff options
| author | Paul Eggert | 2020-05-09 09:10:50 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-05-09 09:11:53 -0700 |
| commit | e59f697cd589e2b68bccb752787ad4a8c9da375d (patch) | |
| tree | be97a85cbd7d8b2ee39405d387ccb26792b9ccbf | |
| parent | ebfb2c4d1bc8f68a75b02a76ec90eb225123c099 (diff) | |
| download | emacs-e59f697cd589e2b68bccb752787ad4a8c9da375d.tar.gz emacs-e59f697cd589e2b68bccb752787ad4a8c9da375d.zip | |
Improve nonnull checking with GCC in emacs-module
* src/emacs-module.h.in (EMACS_ATTRIBUTE_NONNULL):
Also do the nonnull check with GCC. (The old code did the
check with Clang but not with GCC.)
| -rw-r--r-- | src/emacs-module.h.in | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in index cd75c0907e4..6a39d507c84 100644 --- a/src/emacs-module.h.in +++ b/src/emacs-module.h.in | |||
| @@ -48,10 +48,14 @@ information how to write modules and use this header file. | |||
| 48 | # define EMACS_NOEXCEPT_TYPEDEF | 48 | # define EMACS_NOEXCEPT_TYPEDEF |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | #ifdef __has_attribute | 51 | #if 3 < __GNUC__ + (3 <= __GNUC_MINOR__) |
| 52 | #if __has_attribute(__nonnull__) | 52 | # define EMACS_ATTRIBUTE_NONNULL(...) \ |
| 53 | # define EMACS_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__))) | 53 | __attribute__ ((__nonnull__ (__VA_ARGS__))) |
| 54 | #endif | 54 | #elif defined __has_attribute |
| 55 | # if __has_attribute (__nonnull__) | ||
| 56 | # define EMACS_ATTRIBUTE_NONNULL(...) \ | ||
| 57 | __attribute__ ((__nonnull__ (__VA_ARGS__))) | ||
| 58 | # endif | ||
| 55 | #endif | 59 | #endif |
| 56 | #ifndef EMACS_ATTRIBUTE_NONNULL | 60 | #ifndef EMACS_ATTRIBUTE_NONNULL |
| 57 | # define EMACS_ATTRIBUTE_NONNULL(...) | 61 | # define EMACS_ATTRIBUTE_NONNULL(...) |
| @@ -81,7 +85,7 @@ struct emacs_runtime | |||
| 81 | 85 | ||
| 82 | /* Return an environment pointer. */ | 86 | /* Return an environment pointer. */ |
| 83 | emacs_env *(*get_environment) (struct emacs_runtime *runtime) | 87 | emacs_env *(*get_environment) (struct emacs_runtime *runtime) |
| 84 | EMACS_ATTRIBUTE_NONNULL(1); | 88 | EMACS_ATTRIBUTE_NONNULL (1); |
| 85 | }; | 89 | }; |
| 86 | 90 | ||
| 87 | /* Type aliases for function pointer types used in the module API. | 91 | /* Type aliases for function pointer types used in the module API. |
| @@ -166,7 +170,7 @@ struct emacs_env_28 | |||
| 166 | /* Every module should define a function as follows. */ | 170 | /* Every module should define a function as follows. */ |
| 167 | extern int emacs_module_init (struct emacs_runtime *runtime) | 171 | extern int emacs_module_init (struct emacs_runtime *runtime) |
| 168 | EMACS_NOEXCEPT | 172 | EMACS_NOEXCEPT |
| 169 | EMACS_ATTRIBUTE_NONNULL(1); | 173 | EMACS_ATTRIBUTE_NONNULL (1); |
| 170 | 174 | ||
| 171 | #ifdef __cplusplus | 175 | #ifdef __cplusplus |
| 172 | } | 176 | } |