From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 33FA0385801A; Thu, 22 Sep 2022 08:26:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33FA0385801A 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 47458300089; Thu, 22 Sep 2022 08:26:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1663835160; bh=usrWgsLbanKk6kiCXY3p/G8YpjvXEFVErTkLJhLkLRE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=L9wjIQJXR+VxIApM8NVK7CAeqBrloMJ1PiupgZFflkOhk3kpq5xOx6tY/gKKLGDg6 OSs4bXosOlbutdECeCA/XJ3A+4K2I9sjEX1JSb+trnniu4ZhiqoiAeDWw/wd+/SPyy B+eYlQle5IYfGWbMv5VgFXjwTrzEguevt/TIZIxQ= From: Tsukasa OI To: Tsukasa OI , Pedro Alves , Joel Brobecker , Enze Li Cc: gdb-patches@sourceware.org, binutils@sourceware.org Subject: [PATCH v2 1/4] include: Add macro to ignore -Wuser-defined-warnings Date: Thu, 22 Sep 2022 08:25:44 +0000 Message-Id: <2ce08418715c662152290077e1bbc92ee1cf0f10.1663835104.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP 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