[all-commits] [llvm/llvm-project] 51a301: [Clang][Sema] Implement proposed resolution for CW...

Krystian Stasiowski via All-commits all-commits at lists.llvm.org
Tue Feb 6 13:06:50 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 51a3019e4d096d93820f921af20d7a0bf3fffc48
      https://github.com/llvm/llvm-project/commit/51a3019e4d096d93820f921af20d7a0bf3fffc48
  Author: Krystian Stasiowski <sdkrystian at gmail.com>
  Date:   2024-02-06 (Tue, 06 Feb 2024)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaDecl.cpp
    A clang/test/CXX/drs/dr28xx.cpp

  Log Message:
  -----------
  [Clang][Sema] Implement proposed resolution for CWG2847 (#80899)

Per the approved resolution for CWG2847, [temp.expl.spec] p8 will state:
> An explicit specialization shall not have a trailing _requires-clause_ unless it declares a function template.

We already implement this _partially_ insofar that a diagnostic is issued upon instantiation of `A<int>` in the following example:
```
template<typename>
struct A
{
    template<typename>
    void f();

    template<>
    void f<int>() requires true; // error: non-templated function cannot have a requires clause
};
template struct A<int>;  // note: in instantiation of template class 'A<int>' requested here
```

This patch adds a bespoke diagnostic for such declarations, and moves the point of diagnosis for non-templated functions with trailing requires-clauses from `CheckFunctionDeclaration` to `ActOnFunctionDeclarator` (there is no point in diagnosing this during instantiation since we already have all the necessary information when parsing the declaration).




More information about the All-commits mailing list