From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 9A4FD3947407; Thu, 28 Sep 2023 17:49:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A4FD3947407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695923345; bh=D+n1ZiqqNmHrjmlXk26UKso1f/i/t+jXGRq4P5lr6P0=; h=From:To:Subject:Date:From; b=sx53djYxK88aRL8oGpd3pmt84oRNma/0XPIy7RzIgSiA1QdjajG4ddvVmtAdeXrWl Ic90SRbdNTaXzJ2CN6lY6vHLmcnEamEwTONZHhErwjMHk0UwTAUtb0T6m+VWnJYhz2 c2LcN3SKlOEHRFRSm4/YmntN0vYXL/mYEJqZU7Eg= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] Add clang specific warnings suppress macros X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 7a6632a72ce1d2a4a037e04884b4662e7b80f9dd X-Git-Newrev: 9175344b69f63546b020cc150cf1805a3ecbf5e9 Message-Id: <20230928174905.9A4FD3947407@sourceware.org> Date: Thu, 28 Sep 2023 17:49:05 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9175344b69f63546b020cc150cf1805a3ecbf5e9 commit 9175344b69f63546b020cc150cf1805a3ecbf5e9 Author: Adhemerval Zanella Date: Tue Sep 12 15:45:24 2023 -0300 Add clang specific warnings suppress 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. Diff: --- include/libc-diag.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/libc-diag.h b/include/libc-diag.h index dada76a51d..a82e9775dd 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 */