public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/97498] New: #pragma GCC diagnostic ignored "-Wunused-function" inconsistent
@ 2020-10-19 23:49 matthewp515 at gmail dot com
  2022-07-07 14:00 ` [Bug preprocessor/97498] " lhyatt at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: matthewp515 at gmail dot com @ 2020-10-19 23:49 UTC (permalink / raw)
  To: gcc-bugs

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?

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-10-19 20:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 23:49 [Bug preprocessor/97498] New: #pragma GCC diagnostic ignored "-Wunused-function" inconsistent matthewp515 at gmail dot com
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

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).