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 | f4fb07ed4dfd144a39d904fc77b3b0bab580eb2e (patch) | |
tree | 7691901b68d3535b3fedfc8e401e41f8747a7574 /lib/Lex | |
parent | bab0d39dbc417c9ea093df66b8134fb85a95f843 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151768 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 748bc38054..8988e48af5 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/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. |