From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id 62B773821FEE; Thu, 15 Sep 2022 03:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 62B773821FEE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id B39BF300089; Thu, 15 Sep 2022 03:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1663211442; bh=usrWgsLbanKk6kiCXY3p/G8YpjvXEFVErTkLJhLkLRE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=czmiAWpAUc476e5UZ09u/ey31lZtkkmJz6rrv/Ju0BQQXwoN1DJXWKeoSVTMBOKL1 03MShEGIgL39ETR1En1MJ27wS380MwJMZBSSAwhWnYKrxMffuvgeqh8j4oKCUR8GgD x0R5gmkuSfguNdq/7OWcsYg7aggAlodhglccjUSo= From: Tsukasa OI To: Tsukasa OI , Pedro Alves , Joel Brobecker , Enze Li Cc: gdb-patches@sourceware.org, binutils@sourceware.org Subject: [PATCH 1/4] include: Add macro to ignore -Wuser-defined-warnings Date: Thu, 15 Sep 2022 03:10:23 +0000 Message-Id: <5b9e49a21f757c68951b5b37c9008e22c0fd1271.1663211419.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: User-defined warnings (on Clang, "-Wuser-defined-warnings") can be harmful if we have specified "-Werror" and we have no control to disable the warning ourself. The particular example is Gnulib. Gnulib generates a warning if the system version of certain functions are used (to redirect the developer to use Gnulib version). However, it can be harmful if we cannot easily replace them (e.g. the target is in the standard C++ library). The new DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS macro can be helpful on such cases. A typical use of this macro is to place this macro before including certain system headers. include/ChangeLog: * diagnostics.h (DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS): New. --- include/diagnostics.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/diagnostics.h b/include/diagnostics.h index 3da88282261..dbe6288d3d6 100644 --- a/include/diagnostics.h +++ b/include/diagnostics.h @@ -63,6 +63,11 @@ # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") +# if __has_warning ("-Wuser-defined-warnings") +# define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS \ + DIAGNOSTIC_IGNORE ("-Wuser-defined-warnings") +# endif + # define DIAGNOSTIC_ERROR_SWITCH \ DIAGNOSTIC_ERROR ("-Wswitch") @@ -121,6 +126,10 @@ # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL #endif +#ifndef DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS +# define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS +#endif + #ifndef DIAGNOSTIC_ERROR_SWITCH # define DIAGNOSTIC_ERROR_SWITCH #endif -- 2.34.1