diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-09-12 15:45:24 -0300 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-12-22 13:29:20 +0800 |
commit | b2556550a0f952b2a841a0b4bddc999c2df1b233 (patch) | |
tree | 58b32a4c7b175ba1498a47bc5938b8a0f47d3f60 | |
parent | 6412d8cc46d7e9c8811e6251045fdefb89a5d6aa (diff) | |
download | glibc-b2556550a0f952b2a841a0b4bddc999c2df1b233.zip glibc-b2556550a0f952b2a841a0b4bddc999c2df1b233.tar.gz glibc-b2556550a0f952b2a841a0b4bddc999c2df1b233.tar.bz2 |
Add clang specific warning suppression macros
Four new macros are added:
* DIAG_{PUSH,POP}_NEEDS_COMMENT_CLANG are similar to
DIAG_{PUSH,POP}_NEEDS_COMMENT, but enable clang specific pragmas to
handle warnings for options only supported by clang.
* DIAG_IGNORE_NEEDS_COMMENT_{CLANG,GCC} are similar to
DIAG_IGNORE_NEEDS_COMMENT, but enable the warning suppression only
for the referenced compiler.
Reviewed-by: Sam James <sam@gentoo.org>
-rw-r--r-- | include/libc-diag.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/libc-diag.h b/include/libc-diag.h index 4b1c916..7666a38 100644 --- a/include/libc-diag.h +++ b/include/libc-diag.h @@ -38,6 +38,16 @@ /* Pop diagnostic state. */ #define DIAG_POP_NEEDS_COMMENT _Pragma ("GCC diagnostic pop") +/* These macros are used to push/pop diagnostic states for warnings only + supported by clang. */ +#ifdef __clang__ +# define DIAG_PUSH_NEEDS_COMMENT_CLANG _Pragma ("clang diagnostic push") +# define DIAG_POP_NEEDS_COMMENT_CLANG _Pragma ("clang diagnostic pop") +#else +# define DIAG_PUSH_NEEDS_COMMENT_CLANG +# define DIAG_POP_NEEDS_COMMENT_CLANG +#endif + #define _DIAG_STR1(s) #s #define _DIAG_STR(s) _DIAG_STR1(s) @@ -71,4 +81,16 @@ # define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option) #endif +/* Similar to DIAG_IGNORE_NEEDS_COMMENT, these macros should be used + to suppress warning supported by the specific compiler. */ +#ifndef __clang__ +# define DIAG_IGNORE_NEEDS_COMMENT_GCC(VERSION, WARNING) \ + DIAG_IGNORE_NEEDS_COMMENT (VERSION, WARNING) +# define DIAG_IGNORE_NEEDS_COMMENT_CLANG(version, option) +#else +# define DIAG_IGNORE_NEEDS_COMMENT_GCC(VERSION, WARNING) +# define DIAG_IGNORE_NEEDS_COMMENT_CLANG(version, option) \ + _Pragma (_DIAG_STR (clang diagnostic ignored option)) +#endif + #endif /* libc-diag.h */ |