diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticLexKinds.td | 2 | ||||
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 17 |
2 files changed, 8 insertions, 11 deletions
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index cb9236b67f2..2d584f1c340 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -500,7 +500,7 @@ def ext_pp_bad_paste_ms : ExtWarn< "pasting formed '%0', an invalid preprocessing token">, DefaultError, InGroup<DiagGroup<"invalid-token-paste">>; def err_pp_operator_used_as_macro_name : Error< - "C++ operator '%0' (aka %1) cannot be used as a macro name">; + "C++ operator %0 (aka %1) cannot be used as a macro name">; def err_pp_illegal_floating_literal : Error< "floating point literal in preprocessor expression">; def err_pp_line_requires_integer : Error< 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) { |