Skip to content

Commit b573489

Browse files
committed
union tests
1 parent d7250a7 commit b573489

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clang/test/SemaCXX/builtin-structured-binding-size.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ struct SE1 : S1 { int b;};
1414

1515
class P1 {int a;}; // #note-private
1616

17+
union U1 {};
18+
union U2 {int a;};
1719

1820
template <typename T>
1921
concept is_destructurable = requires {
@@ -33,6 +35,14 @@ static_assert(__builtin_structured_binding_size(SE1) == 1);
3335
// expected-error@-1 {{type 'SE1' is not destructurable}} \
3436
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
3537

38+
static_assert(__builtin_structured_binding_size(U1) == 0);
39+
// expected-error@-1 {{type 'U1' is not destructurable}} \
40+
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
41+
static_assert(__builtin_structured_binding_size(U2) == 0);
42+
// expected-error@-1 {{type 'U2' is not destructurable}} \
43+
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
44+
45+
3646

3747
static_assert(__builtin_structured_binding_size(int[0]) == 0);
3848
static_assert(__builtin_structured_binding_size(int[1]) == 1);

0 commit comments

Comments
 (0)