================
@@ -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:

I initially thought this was the same issue as #84052, but I've just realized 
there are differences.

1. A `TemplateParamObjectDecl` of instantiation-dependent type is inserted into 
the cache map.
2. When checking template arguments of a non-dependent template id, we still 
use that `TemplateParamObjectDecl` from the cache map.

(The behavior described above matches #84052 up to this point.)

3. Because of that `TemplateParamObjectDecl`, the constraint is dependent (and 
remains so), so the constraint satisfaction check is deferred.
4. As a result, an invalid template id is accepted.

Possible fixes:
- Bail out if the type is instantiation-dependent, or
- Create a `TemplateParamObjectDecl` of the canonical type:
  - if the type is instantiation-dependent, or
  - always.

https://github.com/llvm/llvm-project/pull/193754
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to