diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index c00759893b0c4..2df1e941452f0 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -837,7 +837,7 @@ StmtResult Parser::ParseCaseStatement(ParsedStmtContext StmtCtx, Diag(ExpectedLoc, diag::err_expected_after) << "'case'" << tok::colon << FixItHint::CreateInsertion(ExpectedLoc, - tok::getTokenName(tok::colon)); + tok::getPunctuatorSpelling(tok::colon)); ColonLoc = ExpectedLoc; } diff --git a/clang/test/FixIt/fixit-macro-expansion-recovery.cpp b/clang/test/FixIt/fixit-macro-expansion-recovery.cpp new file mode 100644 index 0000000000000..ba63088e6115f --- /dev/null +++ b/clang/test/FixIt/fixit-macro-expansion-recovery.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s +// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -std=c++23 %s 2>&1 | FileCheck %s + +#define C(x) case x + +void t1(int a) { + switch (a) { + C(10) // expected-error {{expected ':' after 'case'}} + } +} +// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:":"