================
@@ -4272,3 +4272,92 @@ void test_cyclic_cfg(int n) {
} // expected-note {{local variable 'a' is destroyed here}}
v.use(); // expected-note {{later used here}}
}
+
+namespace member_capture_by_param {
+struct S {
+ S(int *p [[clang::lifetime_capture_by(c)]], int *&c);
+ void cap(int *p [[clang::lifetime_capture_by(c)]], int *&c);
+ void cap_const(int *p [[clang::lifetime_capture_by(c)]], int *&c) const;
+ static void cap_static(int *p [[clang::lifetime_capture_by(c)]], int *&c);
+
+ template <typename T>
+ void cap_template(T *p [[clang::lifetime_capture_by(c)]], T *&c);
+
+ void cap_overload(int *p [[clang::lifetime_capture_by(c)]], int *&c);
+ void cap_overload(double *p [[clang::lifetime_capture_by(c)]], double *&c);
+
+ void cap_multi(int *p [[clang::lifetime_capture_by(c1, c2)]], int *&c1,
+ int *&c2);
+ void cap_reordered(int *&c, int *p [[clang::lifetime_capture_by(c)]]);
+};
+
+namespace ns {
+void cap_ns(int *p [[clang::lifetime_capture_by(c)]], int *&c);
+} // namespace ns
+
+void use(int*);
+void test_member_capture_by() {
+ int *c1;
+ {
+ int i;
+ S s;
+ s.cap(&i, c1); // expected-warning {{local variable 'i' does not live long
enough}}
+ } // expected-note {{local variable 'i' is destroyed here}}
+ use(c1); // expected-note {{later used here}}
----------------
usx95 wrote:
Could you please match the indents of `//` in expectations to match the style
in rest of the file. Similar for all the tests below.
https://github.com/llvm/llvm-project/pull/212264
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits