https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124240
Bug ID: 124240
Summary: Warning shown with -Wno-error=* -Wno-* and preceding
pragma push/pop
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: diagnostics
Assignee: dmalcolm at redhat dot com
Reporter: aaron.puchert at sap dot com
Target Milestone: ---
Compile the following code with "-Wall -Wextra -Werror
-Wno-error=unused-variable -Wno-unused-variable":
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wunused-variable"
#pragma GCC diagnostic pop
static const char* s = "abc";
This emits:
<source>:5:20: warning: 's' defined but not used [-Wunused-variable]
5 | static const char* s = "abc";
| ^
Even though -Wno-unused-variable should take precedence. Removing
-Wno-error=unused-variable makes the warning disappear. So does removing the
pragmas.