brintos

brintos / llvm-project-archived public Read only

0
0
Text · 804 B · 21b4bf0 Raw
36 lines · cpp
1// RUN: %clang_cc1 -emit-pch -std=c++23 -o %t %s2// RUN: %clang_cc1 -include-pch %t -verify -fsyntax-only -DTEST -std=c++23 %s3 4// Test that dependence of 'this' and DREs due to by-value capture by a5// lambda with an explicit object parameter is serialised/deserialised6// properly.7 8#ifndef HEADER9#define HEADER10struct S {11  int x;12  auto f() {13    return [*this] (this auto&&) {14      int y;15      x = 42;16 17      const auto l = [y] (this auto&&) { y = 42; };18      l();19    };20  }21};22#endif23 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}}27 28#ifdef TEST29void f() {30  const auto l = S{}.f();31  l(); // expected-note {{in instantiation of}}32}33#endif34 35 36