public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "matthewp515 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-97498-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97498

            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=unused-function). However, breaking up the command into separate
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, the
command fails. But how else can the macro be constructed?

             reply	other threads:[~2020-10-19 23:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 23:49 matthewp515 at gmail dot com [this message]
2022-07-07 14:00 ` [Bug preprocessor/97498] " lhyatt at gcc dot gnu.org
2022-07-09 20:53 ` lhyatt at gcc dot gnu.org
2022-07-10 20:50 ` cvs-commit at gcc dot gnu.org
2022-07-10 20:51 ` lhyatt at gcc dot gnu.org
2022-07-12  9:47 ` marxin at gcc dot gnu.org
2022-07-12  9:48 ` marxin at gcc dot gnu.org
2022-07-12  9:55 ` marxin at gcc dot gnu.org
2022-07-17 15:12 ` lhyatt at gmail dot com
2022-08-01 23:15 ` cvs-commit at gcc dot gnu.org
2022-08-02 22:25 ` cvs-commit at gcc dot gnu.org
2022-08-02 22:26 ` cvs-commit at gcc dot gnu.org
2022-10-19 20:51 ` lhyatt at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-97498-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).