[clang] [Clang] Diagnose classes defined in the type of a variable template (PR #248352)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 3 21:00:41 PST 2026
================
@@ -2005,6 +2005,32 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
} else
TUK = TagUseKind::Reference;
+ bool HasFollowingVariableDeclarator = false;
+ if (TUK == TagUseKind::Definition &&
+ TemplateInfo.Kind == ParsedTemplateKind::Template && !TemplateId &&
+ SS.isEmpty() && Tok.is(tok::l_brace)) {
+ // Check whether the template-head belongs to a variable declarator before
+ // passing the template parameters to ActOnTag.
+ llvm::SaveAndRestore SavedPrevTokLocation(PrevTokLocation);
+ RevertingTentativeParsingAction PA(*this, /*Unannotated=*/true);
+ ConsumeBrace();
+ if (SkipUntil(tok::r_brace, StopAtCodeCompletion)) {
----------------
YzK0741 wrote:
Thanks for the detailed review! I've changed the approach as you suggested and
updated the PR. The tests and the release note have also been updated.
Could you take another look when you have a chance?
https://github.com/llvm/llvm-project/pull/248352
More information about the cfe-commits
mailing list