[Bug preprocessor/91037] New: #pragma GCC diagnostic ignored "-Wunused-macros" ignored for doubly-defined macro with g++
f.heckenbach@fh-soft.de
gcc-bugzilla@gcc.gnu.org
Sat Jun 29 23:51:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91037
Bug ID: 91037
Summary: #pragma GCC diagnostic ignored "-Wunused-macros"
ignored for doubly-defined macro with g++
Product: gcc
Version: 9.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: f.heckenbach@fh-soft.de
Target Milestone: ---
% cat unused.cpp
#pragma GCC diagnostic ignored "-Wunused-macros"
#define YYUSE
#define YYUSE
YYUSE
% g++ -Wunused-macros unused.cpp
unused.c:2: warning: macro "YYUSE" is not used [-Wunused-macros]
Notably, this only seems to happen in C++, not in C.
It not's like the pragma doesn't work at all. In this program, it correctly
suppresses the warning:
#pragma GCC diagnostic ignored "-Wunused-macros"
#define YYUSE
It also doesn't matter if I omit the last line of the original program. AIUI,
the warning regarding the 2nd definition is correctly suppressed, but regarding
the 1st definition is not.
More information about the Gcc-bugs
mailing list