================
@@ -4085,3 +4047,30 @@ void test_loop_cond_bind(bool cond) {
consume_loop_cond_bind(cond ? &x : &y); // no-warning
}
}
+
+// A borrow captured into the implicit object via
+// [[clang::lifetime_capture_by(this)]] that outlives the captured local is
+// caught at the capturing method's exit.
+struct CaptureByThis {
+ int member;
+ const int *p;
+ void store(const int &x [[clang::lifetime_capture_by(this)]]);
+ void captures_dangling_local() {
+ int local = 0;
+ store(local); // expected-warning {{local variable 'local' does not live
long enough}}
+ } // expected-note {{local variable 'local' is destroyed here}}
expected-note {{later used here}}
----------------
NeKon69 wrote:
nit: maybe align the comments?
https://github.com/llvm/llvm-project/pull/204630
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits