History

Merge tag 'compiler-attributes-for-linus-v5.15-rc1-v2' of git://github.com/ojeda/linux

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

Linus Torvalds committed 5 years ago

Commit c3e46872 parents d41adc4 b83a9084 files · +26 −9Browse files

Showing the changes to include (3 of 4 files). Show all

Unified · Split

3 files
  1. include/linux/compiler-gcc.h +0 −3
  2. include/linux/compiler_attributes.h +25 −0
  3. include/linux/compiler_types.h +0 −6
include/linux/compiler-gcc.h+0−3
@@ -43,9 +43,6 @@ · 42 unmodified lines
4343
4444 #define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
4545
46−#define __compiletime_warning(message) __attribute__((__warning__(message)))
47−#define __compiletime_error(message) __attribute__((__error__(message)))
48−
4946 #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
5047 #define __latent_entropy __attribute__((latent_entropy))
5148 #endif
include/linux/compiler_attributes.h+25−0
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 # define __GCC4_has_attribute___assume_aligned__ 1
3131 # define __GCC4_has_attribute___copy__ 0
3232 # define __GCC4_has_attribute___designated_init__ 0
33+# define __GCC4_has_attribute___error__ 1
3334 # define __GCC4_has_attribute___externally_visible__ 1
3435 # define __GCC4_has_attribute___no_caller_saved_registers__ 0
3536 # define __GCC4_has_attribute___noclone__ 1
@@ -37,7 +38,9 @@ · 1 unmodified line
3738 # define __GCC4_has_attribute___nonstring__ 0
3839 # define __GCC4_has_attribute___no_sanitize_address__ 1
3940 # define __GCC4_has_attribute___no_sanitize_undefined__ 1
41+# define __GCC4_has_attribute___no_sanitize_coverage__ 0
4042 # define __GCC4_has_attribute___fallthrough__ 0
43+# define __GCC4_has_attribute___warning__ 1
4144 #endif
4245
4346 /*
@@ -137,6 +140,17 @@ · 93 unmodified lines
137140 # define __designated_init
138141 #endif
139142
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+
140154 /*
141155 * Optional: not supported by clang
142156 *
@@ -298,6 +312,17 @@ · 155 unmodified lines
298312 */
299313 #define __must_check __attribute__((__warn_unused_result__))
300314
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+
301326 /*
302327 * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute
303328 * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute
include/linux/compiler_types.h+0−6
@@ -294,12 +294,6 @@ struct ftrace_likely_data { · 293 unmodified lines
294294 #ifndef __compiletime_object_size
295295 # define __compiletime_object_size(obj) -1
296296 #endif
297−#ifndef __compiletime_warning
298−# define __compiletime_warning(message)
299−#endif
300−#ifndef __compiletime_error
301−# define __compiletime_error(message)
302−#endif
303297
304298 #ifdef __OPTIMIZE__
305299 # define __compiletime_assert(condition, msg, prefix, suffix) \