[all-commits] [llvm/llvm-project] 17f068: [Clang][Sema] Abbreviated function templates do no...

Krystian Stasiowski via All-commits all-commits at lists.llvm.org
Thu Feb 8 10:04:21 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 17f0680f69f44d340fd0205f7763b2830357c0d5
      https://github.com/llvm/llvm-project/commit/17f0680f69f44d340fd0205f7763b2830357c0d5
  Author: Krystian Stasiowski <sdkrystian at gmail.com>
  Date:   2024-02-08 (Thu, 08 Feb 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/DeclTemplate.h
    M clang/lib/AST/DeclPrinter.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/test/AST/ast-print-method-decl.cpp
    A clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp
    M clang/test/OpenMP/for_loop_auto.cpp

  Log Message:
  -----------
  [Clang][Sema] Abbreviated function templates do not append invented parameters to empty template parameter lists (#80864)

According to [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_.

`template<>` is not a _template-head_ -- a _template-head_ must have at
least one _template-parameter_. This patch corrects our current behavior
of appending the invented template parameters to the innermost template
parameter list, regardless of whether it is empty. Example:
```
template<typename T>
struct A 
{ 
    void f(auto); 
};

template<>
void A<int>::f(auto); // ok

template<>
template<> // warning: extraneous template parameter list in template specialization
void A<int>::f(auto);
```




More information about the All-commits mailing list