mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
func-attr: add some extra handy function attrs
The attributes in question are: - nonnull: specify whether a function argument cannot/may not be null - returns_nonnull: specify whether a function will not return a null pointer (example: xmalloc can't return null, so it should be annotated as such). Only available from gcc 4.9 onwards. Currently these attributes are only supported by gcc.
This commit is contained in:
parent
f5db0d01ba
commit
22e17e25f1
@ -40,9 +40,18 @@
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
// intel only
|
||||
#else
|
||||
#define GCC_VERSION \
|
||||
(__GNUC__ * 10000 + \
|
||||
__GNUC_MINOR__ * 100 + \
|
||||
__GNUC_PATCHLEVEL__)
|
||||
// gcc only
|
||||
#define FUNC_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
|
||||
#define FUNC_ATTR_ALLOC_SIZE_PROD(x,y) __attribute__((alloc_size(x,y)))
|
||||
#define FUNC_ATTR_NONNULL_ALL __attribute__((nonnull))
|
||||
#define FUNC_ATTR_NONNULL_ARG(...) __attribute__((nonnull(__VA_ARGS__)))
|
||||
#if GCC_VERSION >= 40900
|
||||
#define FUNC_ATTR_NONNULL_RET __attribute__((returns_nonnull))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -81,4 +90,16 @@
|
||||
#define FUNC_ATTR_ALWAYS_INLINE
|
||||
#endif
|
||||
|
||||
#ifndef FUNC_ATTR_NONNULL_ALL
|
||||
#define FUNC_ATTR_NONNULL_ALL
|
||||
#endif
|
||||
|
||||
#ifndef FUNC_ATTR_NONNULL_ARG
|
||||
#define FUNC_ATTR_NONNULL_ARG(...)
|
||||
#endif
|
||||
|
||||
#ifndef FUNC_ATTR_NONNULL_RET
|
||||
#define FUNC_ATTR_NONNULL_RET
|
||||
#endif
|
||||
|
||||
#endif // NEOVIM_FUNC_ATTR_H
|
||||
|
Loading…
Reference in New Issue
Block a user