================
@@ -2126,3 +2125,243 @@ void indexing_with_static_operator() {
}
} // namespace static_call_operator
+
+namespace track_origins_for_lifetimebound_record_type {
+
+template <class T> void use(T);
+
+struct S {
+ S();
+ S(const std::string &s [[clang::lifetimebound]]);
+
+ S return_self_after_registration() const;
+};
+
+S getS(const std::string &s [[clang::lifetimebound]]);
+
+void from_free_function() {
+ S s = getS(std::string("temp")); // expected-warning {{object whose
reference is captured does not live long enough}} \
+ // expected-note {{destroyed here}}
+ use(s); // expected-note {{later used here}}
+}
+
+void from_constructor() {
+ S s(std::string("temp")); // expected-warning {{object whose reference is
captured does not live long enough}} \
+ // expected-note {{destroyed here}}
+ use(s); // expected-note {{later used here}}
----------------
usx95 wrote:
nit: match indentation of the assertions/
https://github.com/llvm/llvm-project/pull/187917
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits