[clang] [clang][Sema] fix crash on __type_pack_element with dependent packs (GH180307) (PR #180407)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 16 00:46:54 PST 2026
================
@@ -3406,25 +3406,39 @@ static QualType checkBuiltinTemplateIdType(
Sema &SemaRef, ElaboratedTypeKeyword Keyword, BuiltinTemplateDecl *BTD,
ArrayRef<TemplateArgument> Converted, SourceLocation TemplateLoc,
TemplateArgumentListInfo &TemplateArgs) {
+ TemplateParameterList *Params = BTD->getTemplateParameters();
+ unsigned RequiredArgs = Params->size();
+ if (Params->hasParameterPack()) {
+ if (Converted.size() < RequiredArgs)
+ return QualType();
+ } else {
+ if (Converted.size() != RequiredArgs)
+ return QualType();
+ }
----------------
Serosh-commits wrote:
> @mizvekov what would be the correct way to do this check? I could write a bunch of code to do it manually of course, but it seems like something that must surely need to be done elsewhere? (though I guess the "elsewhere" would be user defined functions where the code would have an actual TemplateArgumentList or similar it was checking against)
@ojhunt let me try to find something or do u have some ideas for the correct check let me know
https://github.com/llvm/llvm-project/pull/180407
More information about the cfe-commits
mailing list