-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstructureal_binding.cpp
More file actions
74 lines (59 loc) · 1.88 KB
/
structureal_binding.cpp
File metadata and controls
74 lines (59 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <tuple>
struct Dummy {
int a = 0;
double* b = nullptr;
};
template <class T> void __lifetime_pset(T&&) {}
Dummy get1();
Dummy& get2(Dummy&);
int main()
{
double b{};
Dummy d{.b = &b};
{
auto [x1, y1] = d;
__lifetime_pset(x1); // expected-warning {{(unknown)}}
__lifetime_pset(y1); // expected-warning {{(b)}}
auto [x3, y3] = get1();
__lifetime_pset(x3); // expected-warning {{(unknown)}}
__lifetime_pset(y3); // expected-warning {{(unknown)}}
auto [x4, y4] = get2(d);
__lifetime_pset(x4); // expected-warning {{(unknown)}}
__lifetime_pset(y4); // expected-warning {{(b)}}
}
{
auto& [x2, y2] = d;
__lifetime_pset(x2); // expected-warning {{(unknown)}}
__lifetime_pset(y2); // expected-warning {{(b)}}
const auto& [x3, y3] = get1();
__lifetime_pset(x3); // expected-warning {{(unknown)}}
__lifetime_pset(y3); // expected-warning {{(global)}}
auto& [x4, y4] = get2(d);
__lifetime_pset(x4); // expected-warning {{(unknown)}}
__lifetime_pset(y4); // expected-warning {{(b)}}
}
}
std::tuple<int*, double*> get3();
void test_tuple()
{
int x;
double y;
std::tuple<int*, double*> t(&x, &y);
{
auto [a, b] = t;
__lifetime_pset(a); // expected-warning {{((global))}}
__lifetime_pset(b); // expected-warning {{((global))}}
__lifetime_pset(t); // expected-warning {{(t)}}
}
{
auto& [a, b] = t;
__lifetime_pset(a); // expected-warning {{((global))}}
__lifetime_pset(b); // expected-warning {{((global))}}
__lifetime_pset(t); // expected-warning {{(t)}}
}
{
auto [a, b] = get3();
__lifetime_pset(a); // expected-warning {{((global))}}
__lifetime_pset(b); // expected-warning {{((global))}}
}
}