Skip to content

Commit b2cd6ea

Browse files
committed
Add a lifetimebound testcase
1 parent aee3d1a commit b2cd6ea

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,12 +815,18 @@ struct S {
815815
struct Q {
816816
const S* get() const [[clang::lifetimebound]];
817817
};
818+
819+
std::string_view foo(std::string_view sv [[clang::lifetimebound]]);
820+
818821
void test1() {
819822
std::string_view k1 = S().sv; // OK
820823
std::string_view k2 = S().s; // expected-warning {{object backing the pointer will}}
821824

822825
std::string_view k3 = Q().get()->sv; // OK
823826
std::string_view k4 = Q().get()->s; // expected-warning {{object backing the pointer will}}
827+
828+
std::string_view lb1 = foo(S().s); // expected-warning {{object backing the pointer will}}
829+
std::string_view lb2 = foo(Q().get()->s); // expected-warning {{object backing the pointer will}}
824830
}
825831

826832
struct Bar {};

0 commit comments

Comments
 (0)