diff options
author | Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> | 2018-08-30 13:25:14 -0400 |
---|---|---|
committer | Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> | 2018-09-30 14:14:03 -0400 |
commit | ec0bbef66f867854691d5af18c2231d746958e0e (patch) | |
tree | baa398e99bc2f6d864f838200e207acbb5bcd097 /include/linux/compiler.h | |
parent | c2c640aa04cc4e6caf0ff17ff18b3784e0c99566 (diff) |
Compiler Attributes: homogenize __must_be_array
Different definitions of __must_be_array:
* gcc: disabled for __CHECKER__
* clang: same definition as gcc's, but without __CHECKER__
* intel: the comment claims __builtin_types_compatible_p()
is unsupported; but icc seems to support it since 13.0.1
(released in 2012). See https://godbolt.org/z/S0l6QQ
Therefore, we can remove all of them and have a single definition
in compiler.h
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # on top of v4.19-rc5, clang 7
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r-- | include/linux/compiler.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index ec4a28bad2c6..165b1d5683ed 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -357,4 +357,11 @@ static inline void *offset_to_ptr(const int *off) | |||
357 | compiletime_assert(__native_word(t), \ | 357 | compiletime_assert(__native_word(t), \ |
358 | "Need native word sized stores/loads for atomicity.") | 358 | "Need native word sized stores/loads for atomicity.") |
359 | 359 | ||
360 | #ifdef __CHECKER__ | ||
361 | #define __must_be_array(a) 0 | ||
362 | #else | ||
363 | /* &a[0] degrades to a pointer: a different type from an array */ | ||
364 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) | ||
365 | #endif | ||
366 | |||
360 | #endif /* __LINUX_COMPILER_H */ | 367 | #endif /* __LINUX_COMPILER_H */ |