[clang] [Clang][Sema] Reject template arguments not equivalent to their copies (part of P2308R1) (PR #193754)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 28 06:33:57 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() &&
----------------
zwuis wrote:

Removing this condition and the optimization (early exit if the selected copy constructor is trivial) causes regression on the test GH84052. I don't know why but I find the comment:

https://github.com/llvm/llvm-project/blob/a6cf1aa076d240ca54797e47d9a45d3be6062829/clang/lib/AST/TemplateBase.cpp#L221-L225

So I added this condition and the assertion in ASTContext.cpp.

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


More information about the cfe-commits mailing list