Debian Codegraph @

gcc/testsuite/g++.dg/cpp1z/decomp59.C

raw
1 // PR c++/92687
2 // { dg-do compile { target c++11 } }
3 // { dg-options "" }
4
5 namespace std {
6 template<typename T> struct tuple_size;
7 template<int, typename> struct tuple_element;
8 }
9
10 struct A {
11 int i;
12 template <int I> int& get() { return i; }
13 };
14
15 template<> struct std::tuple_size<A> { static const int value = 2; };
16 template<int I> struct std::tuple_element<I,A> { using type = int; };
17
18 template<typename T>
19 struct is_reference {
20 static const bool value = false;
21 };
22
23 template<typename T>
24 struct is_reference<T&>
25 {
26 static const bool value = true;
27 };
28
29 template<typename T>
30 struct is_reference<T&&>
31 {
32 static const bool value = true;
33 };
34
35 template<int N>
36 void
37 foo ()
38 {
39 auto [x, y] = A {}; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
40 static_assert (!is_reference<decltype (x)>::value, "");
41 }
42
43 void
44 bar ()
45 {
46 auto [x, y] = A {}; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
47 static_assert (!is_reference<decltype (x)>::value, "");
48 }
49
50 template<typename T>
51 void
52 baz ()
53 {
54 auto [x, y] = T {}; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
55 static_assert (!is_reference<decltype (x)>::value, "");
56 }
57
58 void
59 qux ()
60 {
61 foo<0> ();
62 baz<A> ();
63 }