Pull compiler attributes updates from Miguel Ojeda: - Fix __has_attribute(__no_sanitize_coverage__) for GCC 4 (Marco Elver) - Add Nick as Reviewer for compiler_attributes.h (Nick Desaulniers) - Move __compiletime_{error|warning} (Nick Desaulniers) * tag 'compiler-attributes-for-linus-v5.15-rc1-v2' of git://github.com/ojeda/linux: compiler_attributes.h: move __compiletime_{error|warning} MAINTAINERS: add Nick as Reviewer for compiler_attributes.h Compiler Attributes: fix __has_attribute(__no_sanitize_coverage__) for GCC 4
Showing the changes to include (3 of 4 files). Show all
Unified · Split
| @@ -43,9 +43,6 @@ · 42 unmodified lines | |||
| 43 | 43 | ||
| 44 | #define __compiletime_object_size(obj) __builtin_object_size(obj, 0) | 44 | #define __compiletime_object_size(obj) __builtin_object_size(obj, 0) |
| 45 | 45 | ||
| 46 | #define __compiletime_warning(message) __attribute__((__warning__(message))) | ||
| 47 | #define __compiletime_error(message) __attribute__((__error__(message))) | ||
| 48 | |||
| 49 | #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) | 46 | #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) |
| 50 | #define __latent_entropy __attribute__((latent_entropy)) | 47 | #define __latent_entropy __attribute__((latent_entropy)) |
| 51 | #endif | 48 | #endif |
| @@ -30,6 +30,7 @@ · 29 unmodified lines | |||
| 30 | # define __GCC4_has_attribute___assume_aligned__ 1 | 30 | # define __GCC4_has_attribute___assume_aligned__ 1 |
| 31 | # define __GCC4_has_attribute___copy__ 0 | 31 | # define __GCC4_has_attribute___copy__ 0 |
| 32 | # define __GCC4_has_attribute___designated_init__ 0 | 32 | # define __GCC4_has_attribute___designated_init__ 0 |
| 33 | # define __GCC4_has_attribute___error__ 1 | ||
| 33 | # define __GCC4_has_attribute___externally_visible__ 1 | 34 | # define __GCC4_has_attribute___externally_visible__ 1 |
| 34 | # define __GCC4_has_attribute___no_caller_saved_registers__ 0 | 35 | # define __GCC4_has_attribute___no_caller_saved_registers__ 0 |
| 35 | # define __GCC4_has_attribute___noclone__ 1 | 36 | # define __GCC4_has_attribute___noclone__ 1 |
| @@ -37,7 +38,9 @@ · 1 unmodified line | |||
| 37 | # define __GCC4_has_attribute___nonstring__ 0 | 38 | # define __GCC4_has_attribute___nonstring__ 0 |
| 38 | # define __GCC4_has_attribute___no_sanitize_address__ 1 | 39 | # define __GCC4_has_attribute___no_sanitize_address__ 1 |
| 39 | # define __GCC4_has_attribute___no_sanitize_undefined__ 1 | 40 | # define __GCC4_has_attribute___no_sanitize_undefined__ 1 |
| 41 | # define __GCC4_has_attribute___no_sanitize_coverage__ 0 | ||
| 40 | # define __GCC4_has_attribute___fallthrough__ 0 | 42 | # define __GCC4_has_attribute___fallthrough__ 0 |
| 43 | # define __GCC4_has_attribute___warning__ 1 | ||
| 41 | #endif | 44 | #endif |
| 42 | 45 | ||
| 43 | /* | 46 | /* |
| @@ -137,6 +140,17 @@ · 93 unmodified lines | |||
| 137 | # define __designated_init | 140 | # define __designated_init |
| 138 | #endif | 141 | #endif |
| 139 | 142 | ||
| 143 | /* | ||
| 144 | * Optional: only supported since clang >= 14.0 | ||
| 145 | * | ||
| 146 | * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute | ||
| 147 | */ | ||
| 148 | #if __has_attribute(__error__) | ||
| 149 | # define __compiletime_error(msg) __attribute__((__error__(msg))) | ||
| 150 | #else | ||
| 151 | # define __compiletime_error(msg) | ||
| 152 | #endif | ||
| 153 | |||
| 140 | /* | 154 | /* |
| 141 | * Optional: not supported by clang | 155 | * Optional: not supported by clang |
| 142 | * | 156 | * |
| @@ -298,6 +312,17 @@ · 155 unmodified lines | |||
| 298 | */ | 312 | */ |
| 299 | #define __must_check __attribute__((__warn_unused_result__)) | 313 | #define __must_check __attribute__((__warn_unused_result__)) |
| 300 | 314 | ||
| 315 | /* | ||
| 316 | * Optional: only supported since clang >= 14.0 | ||
| 317 | * | ||
| 318 | * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warning-function-attribute | ||
| 319 | */ | ||
| 320 | #if __has_attribute(__warning__) | ||
| 321 | # define __compiletime_warning(msg) __attribute__((__warning__(msg))) | ||
| 322 | #else | ||
| 323 | # define __compiletime_warning(msg) | ||
| 324 | #endif | ||
| 325 | |||
| 301 | /* | 326 | /* |
| 302 | * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute | 327 | * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute |
| 303 | * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute | 328 | * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute |
| @@ -294,12 +294,6 @@ struct ftrace_likely_data { · 293 unmodified lines | |||
| 294 | #ifndef __compiletime_object_size | 294 | #ifndef __compiletime_object_size |
| 295 | # define __compiletime_object_size(obj) -1 | 295 | # define __compiletime_object_size(obj) -1 |
| 296 | #endif | 296 | #endif |
| 297 | #ifndef __compiletime_warning | ||
| 298 | # define __compiletime_warning(message) | ||
| 299 | #endif | ||
| 300 | #ifndef __compiletime_error | ||
| 301 | # define __compiletime_error(message) | ||
| 302 | #endif | ||
| 303 | 297 | ||
| 304 | #ifdef __OPTIMIZE__ | 298 | #ifdef __OPTIMIZE__ |
| 305 | # define __compiletime_assert(condition, msg, prefix, suffix) \ | 299 | # define __compiletime_assert(condition, msg, prefix, suffix) \ |