aboutsummaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode/libcxx/end-primitive-array-root-lifetime.cpp
blob: f5ba94d4299607da18040a32cfdb5635d5769eb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// RUN: %clang_cc1 -std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both %s
// RUN: %clang_cc1 -std=c++2c  -verify=ref,both %s

// both-no-diagnostics

namespace std {
inline namespace {
template <bool, class _IfRes, class> using conditional_t = _IfRes;
template <class _Ip>
concept input_iterator = requires { typename _Ip; };
auto end = int{};
namespace ranges {
template <class>
concept range = requires { end; };
template <class _Tp>
concept input_range = input_iterator<_Tp>;
template <class>
concept forward_range = false;
template <range _Rp> struct owning_view {
  _Rp __r_;
};
} // namespace ranges
template <int _Size> struct array {
  int __elems_[_Size];
};
template <class> struct allocator {
  constexpr array<2> *allocate(decltype(sizeof(int))) {
    return static_cast<array<2> *>(operator new(sizeof(array<2>)));
  }
};
namespace ranges {
template <input_range _View, forward_range _Pattern> struct join_with_view {
  join_with_view(_View, _Pattern);
};
} // namespace ranges
template <class> struct vector {
  constexpr ~vector() {
    (__end_ - 1)->~array<2>();
  }
  constexpr vector() {
    __end_ = __alloc_.allocate(0);
    _ConstructTransaction __tx(*this);
    ++__tx.__pos_;
  }
  array<2>* __end_;
  allocator<array<2>> __alloc_;
  struct _ConstructTransaction {
    constexpr _ConstructTransaction(vector &__v)
        : __v_(__v), __pos_(__v.__end_) {}
    constexpr ~_ConstructTransaction() { __v_.__end_ = __pos_; }
    vector __v_;
    array<2>* __pos_;
  };
};
} // namespace
} // namespace std
template <bool RefIsGlvalue, class Inner>
using VRange = std::conditional_t<RefIsGlvalue, std::vector<Inner>, Inner>;
template <int RefIsGlvalue> void test_pre_increment() {
  using V = VRange<RefIsGlvalue, std::array<2>>;
  using Pattern = std::array<2>;
  using JWV = std::ranges::join_with_view<std::ranges::owning_view<V>,
                                          std::ranges::owning_view<Pattern>>;
  JWV jwv({}, {});
}