[clang] [Clang][Parse] Fix assertion when annotating a failed decltype-specifier (PR #211221)

Akash Agrawal via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 23 22:27:25 PDT 2026


================
@@ -1136,6 +1136,20 @@ void Parser::AnnotateExistingDecltypeSpecifier(const DeclSpec &DS,
   // make sure we have a token we can turn into an annotation token
   if (PP.isBacktrackEnabled()) {
     PP.RevertCachedTokens(1);
+    if (DS.getTypeSpecType() == TST_error && PP.hasCachedTokenLocation()) {
----------------
akashagrwl wrote:

Reworked it — the fix now drops the invalid decltype-specifier right in ParseOptionalCXXScopeSpecifier, with an early return false on TST_error immediately after ParseDecltypeSpecifier, before any annotation happens. The hasCachedTokenLocation() helper and the AnnotateExistingDecltypeSpecifier special-casing are both removed — there's no longer a code path that annotates an errored DeclSpec, so the stale-EndLoc problem this was patching around can't occur. This mirrors the adjacent pack-indexing branch, which already bails out the same way on TST_error. Also added a release note.

https://github.com/llvm/llvm-project/pull/211221


More information about the cfe-commits mailing list