[v4,4/6] cdefs.h: Enable __errordecl & __warnattr for Clang 14+

Message ID 20230730192605.2423480-5-bugaevc@gmail.com (mailing list archive)
State New
Headers
Series fcntl fortification |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
redhat-pt-bot/TryBot-still_applies warning Patch no longer applies to master

Commit Message

Sergey Bugaev July 30, 2023, 7:25 p.m. UTC
  Clang 14 (released in March 2022) has added support for
attribute ((error)) and attribute ((warning)). Enable their usage when
Clang 14 or later is detected, to get nicer diagnostics.

https://reviews.llvm.org/D106030
https://github.com/llvm/llvm-project/commit/846e562dcc6a9a611d844dc0d123da95629a0567

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 misc/sys/cdefs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Adhemerval Zanella Netto Aug. 2, 2023, 5:23 p.m. UTC | #1
On 30/07/23 16:25, Sergey Bugaev via Libc-alpha wrote:
> Clang 14 (released in March 2022) has added support for
> attribute ((error)) and attribute ((warning)). Enable their usage when
> Clang 14 or later is detected, to get nicer diagnostics.
> 
> https://reviews.llvm.org/D106030
> https://github.com/llvm/llvm-project/commit/846e562dcc6a9a611d844dc0d123da95629a0567
> 
> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  misc/sys/cdefs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
> index 15587848..5c98f393 100644
> --- a/misc/sys/cdefs.h
> +++ b/misc/sys/cdefs.h
> @@ -208,7 +208,7 @@
>        : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))
>  #endif
>  
> -#if __GNUC_PREREQ (4,3)
> +#if __GNUC_PREREQ (4,3) || __glibc_clang_prereq (14,0)
>  # define __warnattr(msg) __attribute__((__warning__ (msg)))
>  # define __errordecl(name, msg) \
>    extern void name (void) __attribute__((__error__ (msg)))
  

Patch

diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 15587848..5c98f393 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -208,7 +208,7 @@ 
       : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))
 #endif
 
-#if __GNUC_PREREQ (4,3)
+#if __GNUC_PREREQ (4,3) || __glibc_clang_prereq (14,0)
 # define __warnattr(msg) __attribute__((__warning__ (msg)))
 # define __errordecl(name, msg) \
   extern void name (void) __attribute__((__error__ (msg)))