diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-11 19:57:52 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-11 19:57:52 +0000 |
commit | 4dd85d6fa114bd69e9887a7ba6eacaab515281c8 (patch) | |
tree | 1023fd9e1293ac5fcc0e3759fb7d0e04a3d90800 /clang/lib/Lex/Preprocessor.cpp | |
parent | 6878b1f233dd6de4507f4c8189220d44b7782109 (diff) | |
download | bcm5719-llvm-4dd85d6fa114bd69e9887a7ba6eacaab515281c8.tar.gz bcm5719-llvm-4dd85d6fa114bd69e9887a7ba6eacaab515281c8.zip |
Add a -Wc++0x-compat warning for C++11 keywords used as identifiers when in
C++98 mode. Only the first occurrence of each keyword will produce a warning.
llvm-svn: 141700
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index dee98eac402..31662ad0c11 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -513,6 +513,17 @@ void Preprocessor::HandleIdentifier(Token &Identifier) { } } + // If this identifier is a keyword in C++11, produce a warning. Don't warn if + // we're not considering macro expansion, since this identifier might be the + // name of a macro. + // FIXME: This warning is disabled in cases where it shouldn't be, like + // "#define constexpr constexpr", "int constexpr;" + if (II.isCXX11CompatKeyword() & !DisableMacroExpansion) { + Diag(Identifier, diag::warn_cxx11_keyword) << II.getName(); + // Don't diagnose this keyword again in this translation unit. + II.setIsCXX11CompatKeyword(false); + } + // C++ 2.11p2: If this is an alternative representation of a C++ operator, // then we act as if it is the actual operator and not the textual // representation of it. |