This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53469] New: #pragma GCC diagnostic works, but using _Pragma doesn't for -Wunused-local-typedefs
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 May 2012 09:30:53 +0000
- Subject: [Bug c++/53469] New: #pragma GCC diagnostic works, but using _Pragma doesn't for -Wunused-local-typedefs
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53469
Bug #: 53469
Summary: #pragma GCC diagnostic works, but using _Pragma
doesn't for -Wunused-local-typedefs
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: dodji@gcc.gnu.org
Since GCC 4.7, the new warning -Wunused-local-typedefs is supported (PR
c++/33255, 2011-09-08); since GCC 4.8 (2012-05-04) it is enabled by -Wall and
-Wunused.
A typedef was used in a compile-time check whether an expression is constant
(compile-time assert). To allow for the new check but selectively disable the
warning for that line, I tried a pragma.
While using #pragma directly works, using _Pragma fails. The following example
shows no warning for "foo" but for "bar" it fails with:
test.cc:19:14: error: typedef âmyintâ locally defined but not used
[-Werror=unused-local-typedefs]
Expected: _Pragma has the same result as writing #pragma.
#pragma GCC diagnostic error "-Wunused-local-typedefs"
// Works:
void foo ()
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
typedef int myint;
#pragma GCC diagnostic pop
}
// Fails:
#define STRINGIFY(x) #x
#define TEST(x) \
_Pragma(STRINGIFY(GCC diagnostic ignored "-Wunused-local-typedefs")) \
typedef int myint;
// _Pragma(STRINGIFY(GCC diagnostic pop))
void bar ()
{
TEST(myint)
}