================
@@ -4126,7 +4126,11 @@ static bool isTemplateArgumentTemplateParameter(const 
TemplateArgument &Arg,
       return false;
     const NonTypeTemplateParmDecl *NTTP =
         dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl());
-    return NTTP && NTTP->getDepth() == Depth && NTTP->getIndex() == Index;
+    if (!NTTP || NTTP->getDepth() != Depth || NTTP->getIndex() != Index)
+      return false;
+    QualType ParamType = cast<NonTypeTemplateParmDecl>(Param)->getType();
+    QualType NTTPType = NTTP->getType();
+    return ParamType.getCanonicalType() == NTTPType.getCanonicalType();
----------------
keinflue wrote:

(Assuming my understanding is correct) `Param` is here supposed to be the 
(non-type) template parameter of the primary template and `NTTP` the non-type 
template parameter of the partial specialization, i.e. they are not the same 
template parameter.

The intent is to test whether the template arguments/parameters of the primary 
template and specialization are "identical" for the purpose of 
https://timsong-cpp.github.io/cppwp/n4140/temp.class.spec#8.3 (which since has 
been removed since from the standard because 
https://timsong-cpp.github.io/cppwp/n4140/temp.class.spec#8.4 which was added 
later covers it).

This is done only to give a more user-friendly error message in case the user 
intended to declare a primary template instead of a specialization, the 
relevant check for p8.4 is done elsewhere. So I think it is ok if the function 
incorrectly returns `true`, but it must not return `false` incorrectly.

https://github.com/llvm/llvm-project/pull/152864
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to