================
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-lifetimebound-violation
-verify %s
+
+#include "Inputs/lifetime-analysis.h"
+
+struct [[gsl::Owner]] MyObj {
+ int id;
+ ~MyObj() {} // Non-trivial destructor
+};
+
+struct [[gsl::Pointer()]] View {
+ View(const MyObj &); // Borrows from MyObj
+ View();
+ void use() const;
+};
+
+bool cond();
+
+View not_lb(const MyObj &obj);
+
+View lb(const MyObj &obj [[clang::lifetimebound]]);
+
+View return_through_unannotated_passthrough(
+ const MyObj &obj [[clang::lifetimebound]]) { // expected-warning {{could
not verify that the return value can be lifetime bound to 'obj'}}
+ return not_lb(obj);
+}
----------------
NeKon69 wrote:
Oh, actually, that code does not compile. I suspected that might happen (I
remember running into this a few times). So I guess my code should not account
for that? Or maybe it is a bug that such code should compile?
https://github.com/llvm/llvm-project/pull/196144
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits