r209962 - Preprocessor: don't exit early in CheckMacroName()
Alp Toker
alp at nuanti.com
Fri May 30 20:38:08 PDT 2014
Author: alp
Date: Fri May 30 22:38:08 2014
New Revision: 209962
URL: http://llvm.org/viewvc/llvm-project?rev=209962&view=rev
Log:
Preprocessor: don't exit early in CheckMacroName()
The checks below can hypothetically apply to converted operator name
identifiers.
In practice there are no builtin macros etc. with those names so there's no
behavioural change to test.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/PPDirectives.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=209962&r1=209961&r2=209962&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri May 30 22:38:08 2014
@@ -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<
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=209962&r1=209961&r2=209962&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri May 30 22:38:08 2014
@@ -140,22 +140,19 @@ bool Preprocessor::CheckMacroName(Token
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) {
More information about the cfe-commits
mailing list