[all-commits] [llvm/llvm-project] f9caa1: [Clang] Fix constraint checking of non-generic lam...

cor3ntin via All-commits all-commits at lists.llvm.org
Fri Jul 21 01:59:50 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f9caa12328b265b77221fe7a310d4504673d814a
      https://github.com/llvm/llvm-project/commit/f9caa12328b265b77221fe7a310d4504673d814a
  Author: Corentin Jabot <corentinjabot at gmail.com>
  Date:   2023-07-21 (Fri, 21 Jul 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaConcept.cpp
    M clang/lib/Sema/SemaLambda.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/test/SemaTemplate/concepts.cpp

  Log Message:
  -----------
  [Clang] Fix constraint checking of non-generic lambdas.

A lambda call operator can be a templated entity -
and therefore have constraints while not being a function template

   template<class T> void f() {
     []() requires false { }();
   }

In that case, we would check the constraints of the call operator
which is non-viable. However, we would find a viable candidate:
the conversion operator to function pointer, and use it to
perform a surrogate call.
These constraints were not checked because:
 * We never check the constraints of surrogate functions
 * The lambda conversion operator has non constraints.

>From the wording, it is not clear what the intent is but
it seems reasonable to expect the constraints of the lambda conversion
operator to be checked and it is consistent with GCC and MSVC.

This patch also improve the diagnostics for constraint failure
on surrogate calls.

Fixes #63181

Reviewed By: #clang-language-wg, aaron.ballman

Differential Revision: https://reviews.llvm.org/D154368




More information about the All-commits mailing list