Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / PCH / cxx23-deducing-this-lambda.cpp
blob21b4bf0d633f2bbef2001030c6859febf583573c
1 // RUN: %clang_cc1 -emit-pch -std=c++23 -o %t %s
2 // RUN: %clang_cc1 -include-pch %t -verify -fsyntax-only -DTEST -std=c++23 %s
4 // Test that dependence of 'this' and DREs due to by-value capture by a
5 // lambda with an explicit object parameter is serialised/deserialised
6 // properly.
8 #ifndef HEADER
9 #define HEADER
10 struct S {
11 int x;
12 auto f() {
13 return [*this] (this auto&&) {
14 int y;
15 x = 42;
17 const auto l = [y] (this auto&&) { y = 42; };
18 l();
22 #endif
24 // expected-error@* {{read-only variable is not assignable}}
25 // expected-error@* {{cannot assign to a variable captured by copy in a non-mutable lambda}}
26 // expected-note@* 2 {{in instantiation of}}
28 #ifdef TEST
29 void f() {
30 const auto l = S{}.f();
31 l(); // expected-note {{in instantiation of}}
33 #endif