diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -4057,8 +4057,9 @@ 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 --- /dev/null +++ b/clang/test/SemaCXX/cxx23-static-callop-lambda-expression.cpp @@ -0,0 +1,32 @@ +// 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-note {{declared here}} expected-error{{cannot take address of consteval call}} + { 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; }; + } +} \ No newline at end of file