If __builtin_is_lvalue() is available, use it with __is_lvalue(). There is patch to Clang to provide this builtin now[1]. Link: https://github.com/kees/llvm-project/commits/builtin_is_lvalue/ [1] Signed-off-by: Kees Cook <kees@xxxxxxxxxx> --- Cc: Miguel Ojeda <ojeda@xxxxxxxxxx> Cc: Nathan Chancellor <nathan@xxxxxxxxxx> Cc: Marco Elver <elver@xxxxxxxxxx> Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> Cc: Przemek Kitszel <przemyslaw.kitszel@xxxxxxxxx> --- include/linux/compiler_types.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index e09d323be845..eb016808dfa8 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -468,6 +468,16 @@ struct ftrace_likely_data { #define __annotated(var, attr) __builtin_has_attribute(var, attr) #endif +/* + * Determine if a given expression is an lvalue for potential + * assignment. Without the builtin, report nothing is an lvalue. + */ +#if __has_builtin(__builtin_is_lvalue) +#define __is_lvalue(expr) __builtin_is_lvalue(expr) +#else +#define __is_lvalue(expr) false +#endif + /* * Some versions of gcc do not mark 'asm goto' volatile: * -- 2.34.1