diff options
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index a7a4bbcc45f..78b84e2d469 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -140,22 +140,19 @@ bool Preprocessor::CheckMacroName(Token &MacroNameTok, char isDefineUndef) { std::string Spelling = getSpelling(MacroNameTok, &Invalid); if (Invalid) return Diag(MacroNameTok, diag::err_pp_macro_not_identifier); + II = getIdentifierInfo(Spelling); - const IdentifierInfo &Info = Identifiers.get(Spelling); - - // Allow #defining |and| and friends in microsoft mode. - if (Info.isCPlusPlusOperatorKeyword() && getLangOpts().MSVCCompat) { - MacroNameTok.setIdentifierInfo(getIdentifierInfo(Spelling)); - return false; - } + if (!II->isCPlusPlusOperatorKeyword()) + return Diag(MacroNameTok, diag::err_pp_macro_not_identifier); - if (Info.isCPlusPlusOperatorKeyword()) + if (!getLangOpts().MSVCCompat) // C++ 2.5p2: Alternative tokens behave the same as its primary token // except for their spellings. return Diag(MacroNameTok, diag::err_pp_operator_used_as_macro_name) - << Spelling << MacroNameTok.getKind(); + << II << MacroNameTok.getKind(); - return Diag(MacroNameTok, diag::err_pp_macro_not_identifier); + // Allow #defining |and| and friends for Microsoft compatibility. + MacroNameTok.setIdentifierInfo(II); } if (isDefineUndef && II->getPPKeywordID() == tok::pp_defined) { |