Skip to content

[clang] Update string and string_view in lifetimebound tests #111737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions clang/test/SemaCXX/attr-lifetimebound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,26 @@ namespace usage_ok {
}
}

# 1 "<std>" 1 3
namespace std {
using size_t = __SIZE_TYPE__;
struct string {
string();
string(const char*);
template<typename T>
struct basic_string {
basic_string();
basic_string(const T*);

char &operator[](size_t) const [[clang::lifetimebound]];
};
string operator""s(const char *, size_t);

struct string_view {
string_view();
string_view(const char *p [[clang::lifetimebound]]);
string_view(const string &s [[clang::lifetimebound]]);
using string = basic_string<char>;
string operator""s(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved}}

template<typename T>
struct basic_string_view {
basic_string_view();
basic_string_view(const T *p);
basic_string_view(const string &s [[clang::lifetimebound]]);
};
string_view operator""sv(const char *, size_t);
using string_view = basic_string_view<char>;
string_view operator""sv(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved}}

struct vector {
int *data();
Expand All @@ -100,7 +103,6 @@ namespace std {

template<typename K, typename V> struct map {};
}
# 68 "attr-lifetimebound.cpp" 2

using std::operator""s;
using std::operator""sv;
Expand All @@ -112,7 +114,7 @@ namespace p0936r0_examples {
void f() {
std::string_view sv = "hi";
std::string_view sv2 = sv + sv; // expected-warning {{temporary}}
sv2 = sv + sv; // FIXME: can we infer that we should warn here too?
sv2 = sv + sv; // expected-warning {{object backing the pointer}}
}

struct X { int a, b; };
Expand Down Expand Up @@ -238,11 +240,6 @@ template <class T> T *addressof(T &arg) {
&const_cast<char &>(reinterpret_cast<const volatile char &>(arg)));
}

template<typename T>
struct basic_string_view {
basic_string_view(const T *);
};

template <class T> struct span {
template<size_t _ArrayExtent>
span(const T (&__arr)[_ArrayExtent]) noexcept;
Expand Down
Loading