1 // RUN: %clang_cc1 -verify -std=c++11 -Wdangling-assignment-gsl %s
6 int *p
= &(int&)(int&&)0; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
7 p
= &(int&)(int&&)0; // expected-warning {{object backing the pointer p will be destroyed at the end of the full-expression}}
9 int *q
= (int *const &)T
{1, 2, 3}; // expected-warning {{temporary whose address is used as value of local variable 'q' will be destroyed at the end of the full-expression}}
10 q
= (int *const &)T
{1, 2, 3}; // expected-warning {{object backing the pointer q will be destroyed at the end of the full-expression}}
12 // FIXME: We don't warn here because the 'int*' temporary is not const, but
13 // it also can't have actually changed since it was created, so we could
15 int *r
= (int *&&)T
{1, 2, 3};
17 // FIXME: The wording of this warning is not quite right. There are two
18 // temporaries here: an 'int* const' temporary that points to the array, and
19 // is lifetime-extended, and an array temporary that the pointer temporary
20 // points to, which doesn't live long enough.
21 int *const &s
= (int *const &)T
{1, 2, 3}; // expected-warning {{temporary bound to local reference 's' will be destroyed at the end of the full-expression}}
26 const int a
[] = {a
[0]};
27 const int b
[] = {a
[0]};
31 // std::basic_string has a hard-coded gsl::owner attr.
36 void test(const char* a
) {
37 // verify we're emitting the `-Wdangling-assignment-gsl` warning.
38 a
= std::basic_string().c_str(); // expected-warning {{object backing the pointer a will be destroyed at the end of the full-expression}}