]> granicus.if.org Git - clang/commitdiff
Provide an aka for the C++ operator name macro diagnostic
authorAlp Toker <alp@nuanti.com>
Wed, 21 May 2014 21:23:39 +0000 (21:23 +0000)
committerAlp Toker <alp@nuanti.com>
Wed, 21 May 2014 21:23:39 +0000 (21:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209322 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticLexKinds.td
lib/Lex/PPDirectives.cpp
test/Preprocessor/cxx_oper_keyword.cpp

index 5d3a4be61a3fc6567107b90e20929741a999fa59..cb9236b67f27b41890ebd6b2fe55b9a5804ab906 100644 (file)
@@ -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<
index 5f80f4487fb4d1d53a02696ddf1b3c3b1c9c7372..a7a4bbcc45f890a4cf1c2130ab9980d21190225b 100644 (file)
@@ -153,7 +153,7 @@ bool Preprocessor::CheckMacroName(Token &MacroNameTok, char isDefineUndef) {
       // 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);
   }
index 5a4653f1a7abd08651b0079235915b5902da3252..03e2a661b972c3f2a844e0da24a898c87270bb33 100644 (file)
 // Not valid in C++ unless -fno-operator-names is passed:
 
 #ifdef OPERATOR_NAMES
-//expected-error@+2 {{C++ operator 'and' cannot be used as a macro name}}
+//expected-error@+2 {{C++ operator 'and' (aka '&&') cannot be used as a macro name}}
 #endif
 #define and foo
 
 #ifdef OPERATOR_NAMES
-//expected-error@+2 {{C++ operator 'and' cannot be used as a macro name}}
+//expected-error@+2 {{C++ operator 'xor' (aka '^') cannot be used as a macro name}}
 #endif
-#if defined and
+#if defined xor
 #endif