Skip to content

Commit c3e4687

Browse files
committed
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
2 parents d41adc4 + b83a908 commit c3e4687

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4684,6 +4684,7 @@ F: drivers/platform/x86/compal-laptop.c
46844684

46854685
COMPILER ATTRIBUTES
46864686
M: Miguel Ojeda <[email protected]>
4687+
R: Nick Desaulniers <[email protected]>
46874688
S: Maintained
46884689
F: include/linux/compiler_attributes.h
46894690

include/linux/compiler-gcc.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@
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
3637
# define __GCC4_has_attribute___no_profile_instrument_function__ 0
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 @@
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 @@
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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,6 @@ struct ftrace_likely_data {
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) \

0 commit comments

Comments
 (0)