Bring back magic constants in the digraph diagnostic
This backs out changes in commit r198605 and part of r198604, replacing the
original tok::kw_template with a slightly more obvious placeholder
tok::unknown.
llvm-svn: 198666
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index f5d5454..9fd6d2a 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -24,6 +24,20 @@
using namespace clang;
+static int SelectDigraphErrorMessage(tok::TokenKind Kind) {
+ switch (Kind) {
+ // template name
+ case tok::unknown: return 0;
+ // casts
+ case tok::kw_const_cast: return 1;
+ case tok::kw_dynamic_cast: return 2;
+ case tok::kw_reinterpret_cast: return 3;
+ case tok::kw_static_cast: return 4;
+ default:
+ llvm_unreachable("Unknown type for digraph error message.");
+ }
+}
+
// Are the two tokens adjacent in the same source file?
bool Parser::areTokensAdjacent(const Token &First, const Token &Second) {
SourceManager &SM = PP.getSourceManager();
@@ -44,7 +58,8 @@
Range.setBegin(DigraphToken.getLocation());
Range.setEnd(ColonToken.getLocation());
P.Diag(DigraphToken.getLocation(), diag::err_missing_whitespace_digraph)
- << Kind << FixItHint::CreateReplacement(Range, "< ::");
+ << SelectDigraphErrorMessage(Kind)
+ << FixItHint::CreateReplacement(Range, "< ::");
// Update token information to reflect their change in token type.
ColonToken.setKind(tok::coloncolon);
@@ -80,8 +95,8 @@
Template, MemberOfUnknownSpecialization))
return;
- FixDigraph(*this, PP, Next, SecondToken, tok::annot_template_id,
- /*AtDigraph*/ false);
+ FixDigraph(*this, PP, Next, SecondToken, tok::unknown,
+ /*AtDigraph*/false);
}
/// \brief Emits an error for a left parentheses after a double colon.