You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Clang][Diagnostics] Use "structured binding" instead of "decomposition"
P0615R0 changed the term "decomposition" to "structured binding".
Some diagnostic messages were created before this paper.
These messages should be updated using "structured binding" to avoid making users confused.
See for context:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0615r0.html
voidno_tuple_size_3() { auto [x, y] = Bad1(); } // ok, omitting value is valid after DR2386
16
16
17
17
structBad2 {};
18
18
template<> structstd::tuple_size<Bad2> { constint value = 5; };
19
-
voidno_tuple_size_4() { auto [x, y] = Bad2(); } // expected-error {{cannot decompose this type; 'std::tuple_size<Bad2>::value' is not a valid integral constant expression}}
19
+
voidno_tuple_size_4() { auto [x, y] = Bad2(); } // expected-error {{cannot bind this type; 'std::tuple_size<Bad2>::value' is not a valid integral constant expression}}
20
20
21
21
template<> structstd::tuple_size<A> { staticconstint value = 3; };
22
22
template<> structstd::tuple_size<B> { enum { value = 3 }; };
23
23
24
24
voidno_get_1() {
25
25
{
26
-
auto [a0, a1] = A(); // expected-error {{decomposes into 3 elements}}
27
-
auto [b0, b1] = B(); // expected-error {{decomposes into 3 elements}}
26
+
auto [a0, a1] = A(); // expected-error {{binds to 3 elements}}
27
+
auto [b0, b1] = B(); // expected-error {{binds to 3 elements}}
28
28
}
29
29
auto [a0, a1, a2] = A(); // expected-error {{undeclared identifier 'get'}} expected-note {{in implicit initialization of binding declaration 'a0'}}
Copy file name to clipboardExpand all lines: clang/test/CXX/dcl.decl/dcl.decomp/p4.cpp
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -25,10 +25,10 @@ namespace NonPublicMembers {
25
25
structNonPublic4 : NonPublic2 {};
26
26
27
27
voidtest() {
28
-
auto [a1] = NonPublic1(); // expected-error {{cannot decompose protected member 'a' of 'NonPublicMembers::NonPublic1'}}
29
-
auto [a2] = NonPublic2(); // expected-error {{cannot decompose private member 'a' of 'NonPublicMembers::NonPublic2'}}
30
-
auto [a3] = NonPublic3(); // expected-error {{cannot decompose members of inaccessible base class 'A' of 'NonPublicMembers::NonPublic3'}}
31
-
auto [a4] = NonPublic4(); // expected-error {{cannot decompose private member 'a' of 'NonPublicMembers::NonPublic2'}}
28
+
auto [a1] = NonPublic1(); // expected-error {{cannot bind protected member 'a' of 'NonPublicMembers::NonPublic1'}}
29
+
auto [a2] = NonPublic2(); // expected-error {{cannot bind private member 'a' of 'NonPublicMembers::NonPublic2'}}
30
+
auto [a3] = NonPublic3(); // expected-error {{cannot bind members of inaccessible base class 'A' of 'NonPublicMembers::NonPublic3'}}
31
+
auto [a4] = NonPublic4(); // expected-error {{cannot bind private member 'a' of 'NonPublicMembers::NonPublic2'}}
32
32
}
33
33
}
34
34
@@ -46,8 +46,8 @@ namespace AnonymousMember {
46
46
};
47
47
48
48
voidtest() {
49
-
auto [a1] = Struct(); // expected-error {{cannot decompose class type 'Struct' because it has an anonymous struct member}}
50
-
auto [a2] = Union(); // expected-error {{cannot decompose class type 'Union' because it has an anonymous union member}}
49
+
auto [a1] = Struct(); // expected-error {{cannot bind class type 'Struct' because it has an anonymous struct member}}
50
+
auto [a2] = Union(); // expected-error {{cannot bind class type 'Union' because it has an anonymous union member}}
51
51
}
52
52
}
53
53
@@ -73,12 +73,12 @@ namespace MultipleClasses {
73
73
structM : virtual J, L {};
74
74
75
75
voidtest() {
76
-
auto [b] = B(); // expected-error {{cannot decompose class type 'B': both it and its base class 'A' have non-static data members}}
77
-
auto [d] = D(); // expected-error {{cannot decompose class type 'D': its base classes 'A' and 'C' have non-static data members}}
76
+
auto [b] = B(); // expected-error {{cannot bind class type 'B': both it and its base class 'A' have non-static data members}}
77
+
auto [d] = D(); // expected-error {{cannot bind class type 'D': its base classes 'A' and 'C' have non-static data members}}
78
78
auto [e] = E();
79
-
auto [f] = F(); // expected-error-re {{cannot decompose members of ambiguous base class 'A' of 'F':{{.*}}struct MultipleClasses::F -> A{{.*}}struct MultipleClasses::F -> E -> A}}
79
+
auto [f] = F(); // expected-error-re {{cannot bind members of ambiguous base class 'A' of 'F':{{.*}}struct MultipleClasses::F -> A{{.*}}struct MultipleClasses::F -> E -> A}}
80
80
auto [h] = H(); // ok, only one (virtual) base subobject even though there are two paths to it
81
-
auto [k] = K(); // expected-error {{cannot decompose members of ambiguous base class 'I'}}
81
+
auto [k] = K(); // expected-error {{cannot bind members of ambiguous base class 'I'}}
82
82
auto [m] = M(); // ok, all paths to I are through the same virtual base subobject J
83
83
84
84
same<decltype(m), int>();
@@ -214,7 +214,7 @@ namespace p0969r0 {
214
214
auto &[x, y] = b;
215
215
}
216
216
voidtest_external(B b) {
217
-
auto &[x, y] = b; // expected-error {{cannot decompose members of inaccessible base class 'A' of 'p0969r0::B'}}
217
+
auto &[x, y] = b; // expected-error {{cannot bind members of inaccessible base class 'A' of 'p0969r0::B'}}
218
218
}
219
219
220
220
structC {
@@ -229,13 +229,13 @@ namespace p0969r0 {
229
229
structD : C {
230
230
staticvoidtest_member(D d, C c) {
231
231
auto &[x1, y1] = d;
232
-
auto &[x2, y2] = c; // expected-error {{cannot decompose protected member 'y' of 'p0969r0::C'}}
232
+
auto &[x2, y2] = c; // expected-error {{cannot bind protected member 'y' of 'p0969r0::C'}}
233
233
}
234
234
};
235
235
voidtest_friend(D d) {
236
236
auto &[x, y] = d;
237
237
}
238
238
voidtest_external(D d) {
239
-
auto &[x, y] = d; // expected-error {{cannot decompose protected member 'y' of 'p0969r0::C'}}
239
+
auto &[x, y] = d; // expected-error {{cannot bind protected member 'y' of 'p0969r0::C'}}
0 commit comments