Skip to content

Commit 2745db0

Browse files
committed
more tests
1 parent bab70e5 commit 2745db0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,27 @@ static_assert(__builtin_structured_binding_size(P1) == 0);
101101
// expected-note@#note-private {{implicitly declared private here}}
102102

103103

104+
void func(int array[14], int x = __builtin_structured_binding_size(decltype(array)));
105+
//expected-error@-1 {{type 'decltype(array)' (aka 'int *') cannot be decomposed}}
106+
107+
struct SM {
108+
static int array[14];
109+
static_assert(__builtin_structured_binding_size(decltype(array)) == 14);
110+
};
111+
112+
template <typename Ty, int N = __builtin_structured_binding_size(Ty)> // #tpl-1
113+
struct T {
114+
static constexpr int value = N;
115+
};
116+
117+
T<int> t1;
118+
// expected-error@#tpl-1 {{type 'int' cannot be decomposed}} \
119+
// expected-error@#tpl-1 {{non-type template argument is not a constant expression}} \
120+
// expected-note@-1 {{in instantiation of default argument for 'T<int>' required here}} \
121+
// expected-note@-1 {{while checking a default template argument used here}} \
122+
123+
static_assert(T<S3>::value == 3);
124+
104125
static_assert(is_destructurable<S0>);
105126
static_assert(is_destructurable<const S0>);
106127
static_assert(is_destructurable<volatile S0>);

0 commit comments

Comments
 (0)