================
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++23 -verify %s
+
+struct S {
+  const int *x;
+  void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x 
= &x; }
+};
+
+///////////////////////////
+// Test for valid usages.
+///////////////////////////
+[[clang::lifetime_capture_by(unknown)]] // expected-error 
{{'lifetime_capture_by' attribute only applies to parameters and implicit 
object parameters}}
+void nonMember(
+    const int &x1 [[clang::lifetime_capture_by(s, t)]],
+    S &s,
+    S &t,
+    const int &x2 [[clang::lifetime_capture_by(12345 + 12)]], // 
expected-error {{'lifetime_capture_by' attribute argument 12345 + 12 is not a 
known function parameter. Must be a function parameter of one of 'this', 
'global' or 'unknown'}}
+    const int &x3 [[clang::lifetime_capture_by(abcdefgh)]],   // 
expected-error {{'lifetime_capture_by' attribute argument 'abcdefgh' is not a 
known function parameter. Must be a function parameter of one of 'this', 
'global' or 'unknown'}}
+    const int &x4 [[clang::lifetime_capture_by("abcdefgh")]], // 
expected-error {{'lifetime_capture_by' attribute argument "abcdefgh" is not a 
known function parameter. Must be a function parameter of one of 'this', 
'global' or 'unknown'}}
----------------
usx95 wrote:

Done.

https://github.com/llvm/llvm-project/pull/111499
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to