|
| 1 | +// RUN: %clang_cc1 -std=c++26 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s |
| 2 | + |
| 3 | +namespace std { |
| 4 | + using size_t = decltype(sizeof(0)); |
| 5 | + template<typename> struct tuple_size; |
| 6 | + template<size_t, typename> struct tuple_element; |
| 7 | +} |
| 8 | + |
| 9 | +struct Y { int n; }; |
| 10 | +struct X { X(); X(Y); X(const X&); ~X(); }; |
| 11 | + |
| 12 | +struct A { int a : 13; bool b; }; |
| 13 | + |
| 14 | +struct B {}; |
| 15 | +template<> struct std::tuple_size<B> { enum { value = 2 }; }; |
| 16 | +template<> struct std::tuple_element<0,B> { using type = X; }; |
| 17 | +template<> struct std::tuple_element<1,B> { using type = const int&; }; |
| 18 | +template<int N> auto get(B) { |
| 19 | + if constexpr (N == 0) |
| 20 | + return Y(); |
| 21 | + else |
| 22 | + return 0.0; |
| 23 | +} |
| 24 | + |
| 25 | +using C = int[2]; |
| 26 | + |
| 27 | +template<typename T> T &make(); |
| 28 | + |
| 29 | +// CHECK-LABEL: define {{.*}} @_Z8big_testIiEiv() |
| 30 | +template <typename T> |
| 31 | +int big_test() { |
| 32 | + A& a = make<A>(); |
| 33 | +A: |
| 34 | + auto &[...an] = a; |
| 35 | + an...[0] = 5; |
| 36 | + // CHECK: %[[a1:.*]].load = load i16, ptr %[[BITFIELD:.*]], |
| 37 | + // CHECK: %[[a1]].clear = and i16 %[[a1]].load, -8192 |
| 38 | + // CHECK: %[[a1]].set = or i16 %[[a1]].clear, 5 |
| 39 | + // CHECK: store i16 %[[a1]].set, ptr %[[BITFIELD]], |
| 40 | +B: |
| 41 | + auto [b1, ...bn] = make<B>(); |
| 42 | + // CHECK: @_Z4makeI1BERT_v() |
| 43 | + // CHECK: call i32 @_Z3getILi0EEDa1B() |
| 44 | + // CHECK: call void @_ZN1XC1E1Y(ptr {{[^,]*}} %[[b1:.*]], i32 |
| 45 | + // |
| 46 | + // CHECK: call noundef double @_Z3getILi1EEDa1B() |
| 47 | + // CHECK: %[[cvt:.*]] = fptosi double %{{.*}} to i32 |
| 48 | + // CHECK: store i32 %[[cvt]], ptr %[[b2:.*]], |
| 49 | + // CHECK: store ptr %[[b2]], ptr %[[b2ref:.*]], |
| 50 | + int bn2 = bn...[0]; |
| 51 | + // CHECK load ptr, ptr %[[b2ref]] |
| 52 | + |
| 53 | + return 0; |
| 54 | +} |
| 55 | + |
| 56 | +int g = big_test<int>(); |
0 commit comments