brintos

brintos / llvm-project-archived public Read only

0
0
Text · 869 B · b0cc4e6 Raw
34 lines · cpp
1// RUN: %clang_cc1 -std=c++1z -verify %s2 3struct A { int x, y; };4typedef int B[2];5struct C { template<int> int get(); };6struct D { int x, y, z; };7struct E { int *p, n; };8 9namespace 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; };13}14 15template<> struct std::tuple_size<C> { enum { value = 2 }; };16 17template<typename T> int decomp(T &t) { 18  auto &[a, b] = t; // expected-error {{type 'D' binds to 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 *'}}20}21 22void 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}}33}34