From b717625aacdf2badd592f1e2e8714a343464e2a5 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Wed, 21 May 2014 21:23:39 +0000 Subject: [PATCH] Provide an aka for the C++ operator name macro diagnostic git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209322 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticLexKinds.td | 2 +- lib/Lex/PPDirectives.cpp | 2 +- test/Preprocessor/cxx_oper_keyword.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 5d3a4be61a..cb9236b67f 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/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>; 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< diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 5f80f4487f..a7a4bbcc45 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -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); } diff --git a/test/Preprocessor/cxx_oper_keyword.cpp b/test/Preprocessor/cxx_oper_keyword.cpp index 5a4653f1a7..03e2a661b9 100644 --- a/test/Preprocessor/cxx_oper_keyword.cpp +++ b/test/Preprocessor/cxx_oper_keyword.cpp @@ -11,12 +11,12 @@ // 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 -- 2.40.0