diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d558705f16ca3..e9bfefd40bbbf 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -283,6 +283,10 @@ Bug Fixes to C++ Support - Clang now properly handles out of line template specializations when there is a non-template inner-class between the function and the class template. (`#65810 `_) + +- Clang now properly converts static lambda call operator to function + pointer on win32. + (`#62594 `_) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index ffd29446b4f2e..d13a5564e9ad6 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -4095,8 +4095,9 @@ static CallingConv getCCForDeclaratorChunk( D.getTypeObject(I).Kind == DeclaratorChunk::MemberPointer; } else if (D.getContext() == DeclaratorContext::LambdaExpr) { // This can only be a call operator for a lambda, which is an instance - // method. - IsCXXInstanceMethod = true; + // method, unless explicitly specified as 'static'. + IsCXXInstanceMethod = + D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static; } else { // We're the innermost decl chunk, so must be a function declarator. assert(D.isFunctionDeclarator()); diff --git a/clang/test/SemaCXX/cxx23-static-callop-lambda-expression.cpp b/clang/test/SemaCXX/cxx23-static-callop-lambda-expression.cpp new file mode 100644 index 0000000000000..fab76ffc423a3 --- /dev/null +++ b/clang/test/SemaCXX/cxx23-static-callop-lambda-expression.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s + + +namespace ns1 { + auto lstatic = []() static { return 3; }; + int (*f2)(void) = lstatic; + +} + +namespace ns1_1 { + + auto lstatic = []() static consteval //expected-error{{cannot take address of consteval call}} \ + expected-note {{declared here}} + { return 3; }; + + // FIXME: the above error should indicate that it was triggered below. + int (*f2)(void) = lstatic; + +} + + +namespace ns2 { + auto lstatic = []() static { return 3; }; + constexpr int (*f2)(void) = lstatic; + static_assert(lstatic() == f2()); +} + +namespace ns3 { + void main() { + static int x = 10; + auto L = []() static { return x; }; + } +}