[clang] [Clang][Sema] Abbreviated function templates do not append invented parameters to empty template parameter lists (PR #80864)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 08:24:00 PST 2024


================
@@ -19294,7 +19294,16 @@ void Sema::ActOnStartFunctionDeclarationDeclarator(
         ExplicitLists, /*IsFriend=*/false, IsMemberSpecialization, IsInvalid,
         /*SuppressDiagnostic=*/true);
   }
-  if (ExplicitParams) {
+  // C++23 [dcl.fct]p23:
+  //   An abbreviated function template can have a template-head. The invented
+  //   template-parameters are appended to the template-parameter-list after
+  //   the explicitly declared template-parameters.
+  //
+  // A template-head must have one or more template-parameters (read:
+  // 'template<>' is *not* a template-head). Only append the invented
+  // template parameters if we matched the nested-name-specifier to a non-empty
+  // TemplateParameterList.
+  if (ExplicitParams && ExplicitParams->size()) {
----------------
erichkeane wrote:

```suggestion
  if (ExplicitParams && !ExplicitParams->empty()) {
```

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


More information about the cfe-commits mailing list