r209322 - Provide an aka for the C++ operator name macro diagnostic

Alp Toker alp at nuanti.com
Wed May 21 14:23:39 PDT 2014


Author: alp
Date: Wed May 21 16:23:39 2014
New Revision: 209322

URL: http://llvm.org/viewvc/llvm-project?rev=209322&view=rev
Log:
Provide an aka for the C++ operator name macro diagnostic

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=209322&r1=209321&r2=209322&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Wed May 21 16:23:39 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' 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=209322&r1=209321&r2=209322&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed May 21 16:23:39 2014
@@ -153,7 +153,7 @@ bool Preprocessor::CheckMacroName(Token
       // 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;
+             << Spelling << MacroNameTok.getKind();
 
     return Diag(MacroNameTok, diag::err_pp_macro_not_identifier);
   }

Modified: cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp?rev=209322&r1=209321&r2=209322&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp (original)
+++ cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp Wed May 21 16:23:39 2014
@@ -11,12 +11,12 @@
 // Not valid in C++ unless -fno-operator-names is passed:
 
 #ifdef OPERATOR_NAMES
-//expected-error at +2 {{C++ operator 'and' cannot be used as a macro name}}
+//expected-error at +2 {{C++ operator 'and' (aka '&&') cannot be used as a macro name}}
 #endif
 #define and foo
 
 #ifdef OPERATOR_NAMES
-//expected-error at +2 {{C++ operator 'and' cannot be used as a macro name}}
+//expected-error at +2 {{C++ operator 'xor' (aka '^') cannot be used as a macro name}}
 #endif
-#if defined and
+#if defined xor
 #endif





More information about the cfe-commits mailing list