================ @@ -1836,7 +1836,19 @@ static TemplateParameterList *GetTemplateParameterList(TemplateDecl *TD) { // Make sure we get the template parameter list from the most // recent declaration, since that is the only one that is guaranteed to // have all the default template argument information. - return cast<TemplateDecl>(TD->getMostRecentDecl())->getTemplateParameters(); + Decl *ND = TD->getMostRecentDecl(); + // Skip past friend Decls because they are not supposed to contain default + // template arguments. Moreover, these declarations may introduce template + // parameters living in different template depths than the corresponding + // template parameters in TD, causing unmatched constraint substitution. + // + // C++23 N4950 [temp.param]p12 ---------------- Sirraide wrote:
> I think the change is probably fine for friend function templates with > default template parameters: they're unique across one TU, and we have > ensured the next declaration we visit is non-null. So in such cases, I think > ND would be equivalent to "the most recent Decl". Judging by the FIXME that’s something we’ll have to come back to anyway, so that’s probably fine for this pr. > Finally, I decided to use N3337 (aka C++11) since I couldn't find any related > words prior to that draft, although gcc and clang don't allow such default > arguments even in 98/03 mode. Er, I’d just write ‘C++11’ then, because I at least honestly wouldn’t know what N3337 was supposed to be off the top of my head if I just saw that somewhere. https://github.com/llvm/llvm-project/pull/86914 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits