================
@@ -0,0 +1,348 @@
+// RUN: %clang_cc1 --std=c++20 -fsyntax-only -Wdangling -Wdangling-field
-Wreturn-stack-address -verify %s
+
+#include "Inputs/lifetime-analysis.h"
+
+struct X {
+ const int *x;
+};
+X x;
+
+// ****************************************************************************
+// Capture an integer
+// ****************************************************************************
+namespace capture_int {
+void captureInt(const int &i [[clang::lifetime_capture_by(x)]], X &x);
+void captureRValInt(int &&i [[clang::lifetime_capture_by(x)]], X &x);
+void noCaptureInt(int i [[clang::lifetime_capture_by(x)]], X &x);
+
+void use() {
+ int local;
+ captureInt(1, // expected-warning {{object whose reference is captured by
'x' will be destroyed at the end of the full-expression}}
+ x);
+ captureRValInt(1, x); // expected-warning {{object whose reference is
captured by 'x'}}
----------------
usx95 wrote:
I do not think it makes sense to test the static content of the diagnostic more
than once.
I replaced `{{captured}}` with `{{captured by 'x'}}` which includes the dynamic
part of the diagnostic.
https://github.com/llvm/llvm-project/pull/115921
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits