From patchwork Sat Dec 21 22:23:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 852744 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2744019wrq; Sat, 21 Dec 2024 14:23:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6vS2t9xAmDo8PO8Du/iy57XxuHHdp3ul09ck1u9aieZDF+mVOB2jLcKb4rmU2Zo/9spwGXg==@linaro.org X-Google-Smtp-Source: AGHT+IG2iduQO3MOA7/Bgf/8laxPwaQlWFJmS7iYhYE43hIIO2a/48daZOISwapRAJE5ygVV+LEK X-Received: by 2002:a05:620a:4096:b0:7b6:672d:7fc7 with SMTP id af79cd13be357-7b9ba7f5e27mr1308465085a.46.1734819802435; Sat, 21 Dec 2024 14:23:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1734819802; cv=pass; d=google.com; s=arc-20240605; b=cHTTaGXDcM+AkQHod07ISDQtU9mw/D83RJfpg22xECilpEieIEw+zrblrFTuvBpauZ 7+MrocKVaPsndEIA45PPsTTznEzKws1l7qWBPVhAOVpg8oyMKBkS/wDL6uG8kyOYT75q UtBp9qENisAhFL6T756Ra45W26+weL43Vg1LurkAs6sFZ064iWjE8nXawXwEPgCzFIbH hJFYH91Zrc3lMJZ1Qvyl5ykSqjqeOGp2hmjCHc30NLXf40mbVsYW7UzReuPeItyiFRPd wcIv4BR8ZGB+3tAm90xK3Vs5yx7AilUKNBeI1PFjnb8AsW3mxeMY3+BoSsbCTQufGqqI uAEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter:arc-filter:dmarc-filter:delivered-to:dkim-filter; bh=pwrrHyujSS4Myl2i2NgXhGJUi/gyp4PWMg+knDULkbE=; fh=rJtIiWzkCr5V2GvQGQWdJX+wkLY3kEXmUtQZbZqt0f0=; b=GXJDvPq7HCHRK+Crsg66VHbwVmdmDm5WzIWTxVyHwDtoo5LBcIRu4NfhZwrscWzJuS oTFFLluZ0YFCxh6yQF+LJhPsj+5Hli4G7p7XKEmnL3jugzaOrlp6QSzOpXiMDALFvHwJ HNfE6h8Qn4F1kVM/UQlaMQjTcdlUjseoaMSjQ8fZDLUgRCL8gGpjZErGg9ABSKPvZqLG ArMlw6WU3HyD/4WWu2MbOu+nLzwUgfbY9Jjx/F36mLKWKXkoZOBkchMuzcX4S7YbW4eM t0OyBlJ36W6pd3uEOb+eyDVRAEZyyifVXrC49jQBwGBbECkkfLJtIKJcse2ArQe2zgoy yk6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=K5if0vR9; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac52fc4esi746403485a.607.2024.12.21.14.23.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 14:23:22 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=K5if0vR9; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CF64385841D for ; Sat, 21 Dec 2024 22:23:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CF64385841D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=K5if0vR9 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id B1DF43858D3C for ; Sat, 21 Dec 2024 22:23:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1DF43858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B1DF43858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734819787; cv=none; b=JOEdBCLqPH6+qoqMYje1VXymGn5OOVoldd153J2BB+d4pk5ofzFF6kKd4GRjBxg5K8XXWWXs5qd1CjoxrOKqQx9yfJiKbQZtkIN4dA5rRtCqCz6hyuZF0gDDdosFfsiCU9XhgQtFcPXnYEEnpT93kykCAZoVT50Ap8GpHs5mHmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734819787; c=relaxed/simple; bh=8SVyivs9vqtv8qzMUALBsbSzGRRMOV2z+J19fsFCvIs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IdjcfHV0ScB+qcNFlIJ0LlX5FOrBh344X35NbMT66t44YOZdRrODQqzkRCujjEhUwemtNk/IuHgMJYbZD5bftpOBdoMsI2MoRNH2b98y4D2XqyPPVUpCd96/7hwe80PdTIGzXOmzRFDygCqMAvSc3u6VBxr8zprsrcDW/L85Rcc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1DF43858D3C Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2156e078563so27536885ad.2 for ; Sat, 21 Dec 2024 14:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734819787; x=1735424587; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pwrrHyujSS4Myl2i2NgXhGJUi/gyp4PWMg+knDULkbE=; b=K5if0vR9mH+S3bMiAHqm+7MoaCPum1KG+mFI8onirFTtoDJopla1N6hWIc+MFFjdQT R+d19YSN682K7qYe5ra0L0ntNjvw5utkUpMVxranxcWl5delCqUrinWsYcybuVWAtJ+z I6/0of4je39/xOacrZiF6hCUlCItYZKy0uX/GzsVztKKhA2ZK5KtSEMiXsp5fHHsosBe n9fFg2uH6BRZp3yzC3jbGm8mdl3ugfz6ZwBsdNZP7C1BEa1AzJZ5AaOhE7B3SqK6/MBb sXC4gpSZh0Zgn2ZpfUy+j2BMF24qb9u+Ma+LA3vo1cc1N7b/j03vtmIqS2nA04usl5L0 fccQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734819787; x=1735424587; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pwrrHyujSS4Myl2i2NgXhGJUi/gyp4PWMg+knDULkbE=; b=OOWatbbtzBxuel+TBpHBePVtXcNrol7zCNDZ3gLSbYGgkeR3J/pn9XDYBoW+Df9JIw oQysvnSUCvvg/FX+8BpGTCqpllke+wP797KyXnBQhz9xa2hMbg0agtfhZ+w9kC1Hjl2W bsq1SfOkLoHaio2VBT/pRjAx1sJBsKQ3zxQYznB2ipkYKNVnRnXZtoaFnwLiXvb7q7iy DMkQaVy+WdUpFlLU+FwjH/Fk/KTqJJ3iRqwN8An9ZGplMikplR4hkQjIlrx3YPyiaBil B8z4rB8gZ5kYHbXs9tG+pBMqqufEOXN7YPufJ2QjF/gm4be2PFCmba1cC2tIQifzG/Ra ZeLg== X-Gm-Message-State: AOJu0YxCFg6X9CxKxeojL4RJBHquambgbpgsTYiHucMC8t6/TEAEdSWR +jfkJXhSi/vlNqnKaV9ZtDsbd+f2CJBF+6/uaeantq7hxsoL0G08Hm9NLKOWhZrfkw== X-Gm-Gg: ASbGncutmZri/eZYzsml+JbCCbz190DkhocuP4grtfyFU9tm7SDClMRKzEo8/dIIpW2 GDrz2RIifF5B4CJltheI4oLSd1A7KAL3MWAcvWnmMsXZbqqEOrq7+7/H2txbe4Hhi7+iDRfsZif mjyycp1yPVOoBRzczGIsmq06HIDnpJL12VaHukbKGCKxi6SGqoI2RuX4WhChL9ES2Nb7PPmkb+7 zUE2FEWfhaz78X0qFOVxaJ0WsI9utEBRnCimhtrPPLKCc8+ChpAnsQuSsFu9Vlyv2b1+SE= X-Received: by 2002:a17:902:d4cf:b0:216:7761:cc4d with SMTP id d9443c01a7336-219e6f2703amr88999215ad.55.1734819786567; Sat, 21 Dec 2024 14:23:06 -0800 (PST) Received: from gnu-tgl-3.localdomain ([120.204.185.181]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9d4c89sm47246635ad.124.2024.12.21.14.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 14:23:06 -0800 (PST) Received: from gnu-tgl-3.lan (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 89E9AC028A; Sun, 22 Dec 2024 06:23:03 +0800 (CST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH] Add clang specific warnings suppress macros Date: Sun, 22 Dec 2024 06:23:00 +0800 Message-ID: <20241221222300.753331-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org From: Adhemerval Zanella 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. --- include/libc-diag.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/libc-diag.h b/include/libc-diag.h index 4b1c916756..7666a386f3 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 */