[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaTemplate / cxx1z-decomposition.cpp
blob779c4cf75e9db7a3ebcfcfca81f8f3098676cc2a
1 // RUN: %clang_cc1 -std=c++1z -verify %s
3 struct A { int x, y; };
4 typedef int B[2];
5 struct C { template<int> int get(); };
6 struct D { int x, y, z; };
7 struct E { int *p, n; };
9 namespace std {
10 using size_t = decltype(sizeof(0));
11 template<typename> struct tuple_size;
12 template<size_t, typename> struct tuple_element { using type = int; };
15 template<> struct std::tuple_size<C> { enum { value = 2 }; };
17 template<typename T> int decomp(T &t) {
18 auto &[a, b] = t; // expected-error {{type 'D' decomposes into 3 elements, but only 2 names were provided}}
19 return a + b; // expected-error {{cannot initialize return object of type 'int' with an rvalue of type 'int *'}}
22 void test() {
23 A a;
24 B b;
25 C c;
26 D d;
27 E e;
28 decomp(a);
29 decomp(b);
30 decomp(c);
31 decomp(d); // expected-note {{in instantiation of}}
32 decomp(e); // expected-note {{in instantiation of}}