[clang] [clang][Sema] Fix a CTAD regression after 42239d2e9 (PR #86914)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 29 08:48:31 PDT 2024


================
@@ -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 found people tend not to spell out the standard file number throughout the codebase

Probably beacuse most people don’t have all of them memorised (at least I don’t), whereas e.g. ‘C++11’ makes it pretty clear what we’re actually talking about.

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


More information about the cfe-commits mailing list