[Clang] Fix a crash when taking the address of a consteval lambda
authorCorentin Jabot <corentinjabot@gmail.com>
Thu, 23 Feb 2023 10:04:23 +0000 (11:04 +0100)
committerCorentin Jabot <corentinjabot@gmail.com>
Thu, 23 Feb 2023 14:26:37 +0000 (15:26 +0100)
commit34abc5b75d9d995ded56a9534c230300b06f1439
tree0f8c1bb18cb9bf51a30f9e626d5193d0f72ab543
parent0eb45cd081e4ad8c496aa8358082ef2644c6a50f
[Clang] Fix a crash when taking the address of a consteval lambda

The `_invoke` function of lambdas was not respecting
the constexpr/consteval specifier of the call operator, so it was possible
to take its address in a non-immmediately invoked context,
even if the call operator was itself consteval.

In addition, we improve the diagnostic emmited in the lambda case
not to show that `invoke` method.

Fixes #57682

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

Differential Revision: https://reviews.llvm.org/D144627
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLambda.cpp
clang/test/AST/ast-dump-expr-json.cpp
clang/test/AST/ast-dump-expr.cpp
clang/test/AST/ast-dump-lambda.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp