[clang] [clang] Decay types of function and constant template parameter packs (PR #132189)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 26 04:12:51 PDT 2025
================
@@ -1518,7 +1526,7 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
QualType T = CheckNonTypeTemplateParameterType(TInfo, D.getIdentifierLoc());
if (T.isNull()) {
- T = Context.IntTy; // Recover with an 'int' type.
+ T = TInfo->getType();
----------------
offsetof wrote:
> In what sort of context does this matter? Does the effect of this show up in any test?
In the newly added section of `test/CXX/temp/temp.decls/temp.mem/p1.cpp`, without this change we'd fail to match the various `bad` definitions to their in-class declarations, creating extraneous diagnostics.
More importantly, recovering with `int` in `RebuildTemplateParamsInCurrentInstantiation` would lead to the first invalid definition of `good` being accepted without a diagnostic.
> Is it possible we might recover with something strange which will have weird effects or crash later, like undeduced auto?
The type ultimately comes from `GetTypeForDeclarator`, after substitution of `auto` for dependent `auto`, so it can certainly be "strange" as in semantically invalid in this context (incomplete, non-structural, etc.), but I think that's fine since we mark the decl as invalid (?)
Note that currently `RebuildTemplateParamsInCurrentInstantiation` does not perform this check, so it's already possible to end up with such types on `NonTypeTemplateParmDecl`s that way.
https://github.com/llvm/llvm-project/pull/132189
More information about the cfe-commits
mailing list