[clang] [Clang][Sema] Reject template arguments not equivalent to their copies (part of P2308R1) (PR #193754)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 5 12:55:50 PDT 2026
================
@@ -7417,6 +7477,12 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
if (Value.isAddrLabelDiff())
return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
+ if (ParamType->isRecordType() &&
+ !ParamType->isInstantiationDependentType() &&
----------------
mizvekov wrote:
I see.
In general, the only difference between an instantiation-dependent-only type and one which is not (but is still the same type as the former), is that the former still needs to be substituted later, and that might turn out to become an invalid type (and then trigger SFINAE or the program being rejected).
The reason we defer constraint checking in those cases is that it captures such a failure and turns that into a 'false' evaluation.
So we can gloss-over instantiation-dependence-only as long as we remember that original type, and will try to substitute it later, and will correctly deal with any subsequent failures.
So I'd expect we would create a `TemplateParamObjectDecl` with such a type, and then later substitute that, producing another `TemplateParamObjectDecl`. So any changes to the `Profile` function would not really be necessary, if I haven't misunderstood anything. Likewise, creating a `TemplateParamObjectDecl` with the canonical type would be unnecessary.
https://github.com/llvm/llvm-project/pull/193754
More information about the cfe-commits
mailing list