From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BC8AF385E444; Mon, 19 Oct 2020 23:49:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC8AF385E444 From: "matthewp515 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/97498] New: #pragma GCC diagnostic ignored "-Wunused-function" inconsistent Date: Mon, 19 Oct 2020 23:49:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: 9.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: matthewp515 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2020 23:49:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97498 Bug ID: 97498 Summary: #pragma GCC diagnostic ignored "-Wunused-function" inconsistent Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: matthewp515 at gmail dot com Target Milestone: --- Ubuntu Linux 20.04 #define STR(x) #x #define WIGNORE(x, instrs) \ _Pragma("GCC diagnostic push") \ _Pragma(STR(GCC diagnostic ignored #x)) \ instrs \ _Pragma("GCC diagnostic pop") // REPLACE int main(void) {return 1;} When REPLACE is replaced with: WIGNORE(-Wunused-function, static int f(int a) {return a + 1;} ) The command: gcc main.c -Wall -Werror -Wextra fails (-Werror=3Dunused-function). However, breaking up the command into se= parate preprocessing and compilation stages: gcc -E main.c -Wall -Werror -Wextra | gcc -x c - passes. When the macro is unwound by REPLACE being replaced with: _Pragma("GCC diagnostic push"); _Pragma("GCC diagnostic ignored \"-Wunused-function\""); static int f(int p) {return p + 1;} _Pragma("GCC diagnostic pop"); The first command then passes. By adding a single backslash (\) right after= the implementation of f, as is required to keep the WIGNORE macro all as one, t= he command fails. But how else can the macro be constructed?=