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/Basic/IdentifierTable.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/Basic/IdentifierTable.cpp')
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 2419f9bb6c3..38f09a08af3 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -32,6 +32,7 @@ IdentifierInfo::IdentifierInfo() { ObjCOrBuiltinID = 0; HasMacro = false; IsExtension = false; + IsCXX11CompatKeyword = false; IsPoisoned = false; IsCPPOperatorKeyword = false; NeedsHandleIdentifier = false; @@ -102,10 +103,10 @@ namespace { /// identifiers because they are language keywords. This causes the lexer to /// automatically map matching identifiers to specialized token codes. /// -/// The C90/C99/CPP/CPP0x flags are set to 2 if the token should be -/// enabled in the specified langauge, set to 1 if it is an extension -/// in the specified language, and set to 0 if disabled in the -/// specified language. +/// The C90/C99/CPP/CPP0x flags are set to 3 if the token is a keyword in a +/// future language standard, set to 2 if the token should be enabled in the +/// specified langauge, set to 1 if it is an extension in the specified +/// language, and set to 0 if disabled in the specified language. static void AddKeyword(StringRef Keyword, tok::TokenKind TokenCode, unsigned Flags, const LangOptions &LangOpts, IdentifierTable &Table) { @@ -123,12 +124,15 @@ static void AddKeyword(StringRef Keyword, else if (!LangOpts.CPlusPlus && (Flags & KEYNOCXX)) AddResult = 2; else if (LangOpts.C1X && (Flags & KEYC1X)) AddResult = 2; else if (LangOpts.ObjCAutoRefCount && (Flags & KEYARC)) AddResult = 2; - + else if (LangOpts.CPlusPlus && (Flags & KEYCXX0X)) AddResult = 3; + // Don't add this keyword if disabled in this language. if (AddResult == 0) return; - IdentifierInfo &Info = Table.get(Keyword, TokenCode); + IdentifierInfo &Info = + Table.get(Keyword, AddResult == 3 ? tok::identifier : TokenCode); Info.setIsExtensionToken(AddResult == 1); + Info.setIsCXX11CompatKeyword(AddResult == 3); } /// AddCXXOperatorKeyword - Register a C++ operator keyword alternative @@ -493,4 +497,3 @@ const char *clang::getOperatorSpelling(OverloadedOperatorKind Operator) { return 0; } - |