User account creation filtered due to spam.

Bug 48914 - #pragma GCC diagnostic ignored "-Wc++0x-compat" doesn't work
Summary: #pragma GCC diagnostic ignored "-Wc++0x-compat" doesn't work
Status: RESOLVED DUPLICATE of bug 53431
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2011-05-06 09:40 UTC by bero
Modified: 2014-09-05 16:59 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-07-24 20:12:48


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bero 2011-05-06 09:40:00 UTC
$ cat test.cpp
#pragma GCC diagnostic ignored "-Wc++0x-compat"
namespace std {
        class nullptr_t { };
}
extern std::nullptr_t nullptr;

$ g++ -Wc++0x-compat -c test.cpp
test.cpp:5:1: warning: identifier ‘nullptr’ will become a keyword in C++0x [-Wc++0x-compat]

$ g++ -Wc++0x-compat -Werror -c test.cpp
test.cpp:5:1: error: identifier ‘nullptr’ will become a keyword in C++0x [-Werror=c++0x-compat]
cc1plus: all warnings being treated as errors
Comment 1 Andrew Pinski 2011-07-24 20:12:48 UTC
Confirmed.
Comment 2 Paolo Carlini 2011-09-28 17:34:44 UTC
So far have been able to figure out that diagnostic_classify_diagnostic apparently sets correctly context->n_classification_history to 1 when the pragma is parsed, but then is found == 0 in diagnostic_report_diagnostic.
Comment 3 Paolo Carlini 2011-09-29 15:31:03 UTC
It seems, the warning is emitted *before* the pragma is actually processed in diagnostic_classify_diagnostic...
Comment 4 asmwarrior 2012-08-02 06:41:33 UTC
We are Code::Blocks' developers, we see the same annoying warnings, hope it will be fixed. Thanks.
See: http://forums.codeblocks.org/index.php/topic,16670.msg113169.html#msg113169
Comment 5 asmwarrior 2012-08-02 08:28:10 UTC
(In reply to comment #4)
> We are Code::Blocks' developers, we see the same annoying warnings, hope it
> will be fixed. Thanks.
> See:
> http://forums.codeblocks.org/index.php/topic,16670.msg113169.html#msg113169

Sorry, I post a wrong link, the link is only accessed by C::B developers, so it is a private link. But we just discuss the same issue.
Comment 6 Roger Jarrett 2013-01-01 18:04:49 UTC
Confirmed present in GCC 4.7.1 
g++ foo.cpp -Wall -std=c++98

 our use case is that we have a code base in transition to C++0x and have created our own nullptr_t for the platform that have not yet transitioned to C++0x we would like to acknowledge/suppress this warning in the file that implements the nullptr_t without resorting to -Wno-c++0x-compat on the commmand line.

--Roger
Comment 7 Roger Jarrett 2013-01-02 18:51:12 UTC
Additional workaround (big hammer) 
#pragma GCC system_header

Best used when the code generating the warning is in an isolated header file
--Roger
Comment 8 Manuel López-Ibáñez 2013-01-04 10:51:22 UTC
Indeed, handle_pragma_diagnostic is called too late after lexing because pragmas are only parsed during the parsing phase but warnings can be emitted way earlier (and even earlier than lexing, during command-line setup).

Bah, this doesn't look easy to fix at all.
Comment 9 Manuel López-Ibáñez 2013-11-16 20:44:43 UTC
If this warning is given by the preprocessor during lexing, then this is a dup of bug 53431.
Comment 10 Manuel López-Ibáñez 2014-09-05 16:59:33 UTC
(In reply to Manuel López-Ibáñez from comment #9)
> If this warning is given by the preprocessor during lexing, then this is a
> dup of bug 53431.

It is.

*** This bug has been marked as a duplicate of bug 53431 ***