diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2012-02-29 22:54:43 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2012-02-29 22:54:43 +0000 |
| commit | 2e686205e84ecb1fdfbf82c6a871fda8a2ab14d1 (patch) | |
| tree | 384d495b53085a5b9361dc4eb2cda56d15313015 /clang/lib/Lex | |
| parent | 203ea38085153c7f54d2e572a3932088f0854b00 (diff) | |
| download | bcm5719-llvm-2e686205e84ecb1fdfbf82c6a871fda8a2ab14d1.tar.gz bcm5719-llvm-2e686205e84ecb1fdfbf82c6a871fda8a2ab14d1.zip | |
Allow operator keywords to be #defined in ms-ext mode.
Fixes PR10606.
I'm not sure if this is the best way to go about it, but
I locally enabled this code path without the msext conditional,
and all tests pass, except for test/Preprocessor/cxx_oper_keyword.cpp
which explicitly checks that operator keywords can't be redefined.
I also parsed chromium/win with a clang with and without this patch.
It introduced no new errors, but removes 43 existing errors.
llvm-svn: 151768
Diffstat (limited to 'clang/lib/Lex')
| -rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 748bc38054d..8988e48af55 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -120,8 +120,15 @@ void Preprocessor::ReadMacroName(Token &MacroNameTok, char isDefineUndef) { std::string Spelling = getSpelling(MacroNameTok, &Invalid); if (Invalid) return; - + const IdentifierInfo &Info = Identifiers.get(Spelling); + + // Allow #defining |and| and friends in microsoft mode. + if (Info.isCPlusPlusOperatorKeyword() && getLangOptions().MicrosoftExt) { + MacroNameTok.setIdentifierInfo(getIdentifierInfo(Spelling)); + return; + } + if (Info.isCPlusPlusOperatorKeyword()) // C++ 2.5p2: Alternative tokens behave the same as its primary token // except for their spellings. |

