[PATCH] D154368: [Clang] Fix constraint checking of non-generic lambdas.

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 3 10:09:20 PDT 2023


cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154368

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaTemplate/concepts.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154368.536818.patch
Type: text/x-patch
Size: 12563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230703/a1900b78/attachment-0001.bin>


More information about the cfe-commits mailing list