| 1 |
// { dg-require-effective-target c++20 } |
| 2 |
// { dg-options "-O2 -fdump-tree-dce7" } |
| 3 |
|
| 4 |
template <typename> struct __new_allocator { |
| 5 |
void deallocate(int *, int) { operator delete(0); } |
| 6 |
}; |
| 7 |
template <typename _Tp> using __allocator_base = __new_allocator<_Tp>; |
| 8 |
template <typename> struct allocator : __allocator_base<int> { |
| 9 |
[[__gnu__::__always_inline__]] void deallocate(int *__p, int __n) { |
| 10 |
__allocator_base<int>::deallocate(__p, __n); |
| 11 |
} |
| 12 |
}; |
| 13 |
template <typename> struct allocator_traits; |
| 14 |
template <typename _Tp> struct allocator_traits<allocator<_Tp>> { |
| 15 |
using allocator_type = allocator<_Tp>; |
| 16 |
using pointer = _Tp *; |
| 17 |
using size_type = int; |
| 18 |
template <typename _Up> using rebind_alloc = allocator<_Up>; |
| 19 |
static void deallocate(allocator_type &__a, pointer __p, size_type __n) { |
| 20 |
__a.deallocate(__p, __n); |
| 21 |
} |
| 22 |
}; |
| 23 |
template <typename _Alloc> struct __alloc_traits : allocator_traits<_Alloc> { |
| 24 |
typedef allocator_traits<_Alloc> _Base_type; |
| 25 |
template <typename _Tp> struct rebind { |
| 26 |
typedef _Base_type::template rebind_alloc<_Tp> other; |
| 27 |
}; |
| 28 |
}; |
| 29 |
long _M_deallocate___n; |
| 30 |
struct _Vector_base { |
| 31 |
typedef __alloc_traits<allocator<int>>::rebind<int>::other _Tp_alloc_type; |
| 32 |
typedef __alloc_traits<_Tp_alloc_type>::pointer pointer; |
| 33 |
struct _Vector_impl_data { |
| 34 |
pointer _M_start; |
| 35 |
}; |
| 36 |
struct _Vector_impl : _Tp_alloc_type, _Vector_impl_data {}; |
| 37 |
~_Vector_base() { _M_deallocate(_M_impl._M_start); } |
| 38 |
_Vector_impl _M_impl; |
| 39 |
void _M_deallocate(pointer __p) { |
| 40 |
if (__p) |
| 41 |
__alloc_traits<_Tp_alloc_type>::deallocate(_M_impl, __p, |
| 42 |
_M_deallocate___n); |
| 43 |
} |
| 44 |
}; |
| 45 |
struct vector : _Vector_base {}; |
| 46 |
struct aligned_storage { |
| 47 |
int dummy_; |
| 48 |
int *ptr_ref0; |
| 49 |
vector &ref() { |
| 50 |
vector *__trans_tmp_2; |
| 51 |
void *__trans_tmp_1 = &dummy_; |
| 52 |
union { |
| 53 |
void *ap_pvoid; |
| 54 |
vector *as_ptype; |
| 55 |
} caster{__trans_tmp_1}; |
| 56 |
__trans_tmp_2 = caster.as_ptype; |
| 57 |
return *__trans_tmp_2; |
| 58 |
} |
| 59 |
}; |
| 60 |
struct optional_base { |
| 61 |
optional_base operator=(optional_base &) { |
| 62 |
bool __trans_tmp_3 = m_initialized; |
| 63 |
if (__trans_tmp_3) |
| 64 |
m_initialized = false; |
| 65 |
return *this; |
| 66 |
} |
| 67 |
~optional_base() { |
| 68 |
if (m_initialized) |
| 69 |
m_storage.ref().~vector(); |
| 70 |
} |
| 71 |
bool m_initialized; |
| 72 |
aligned_storage m_storage; |
| 73 |
}; |
| 74 |
struct optional : optional_base { |
| 75 |
optional() : optional_base() {} |
| 76 |
}; |
| 77 |
template <class> using Optional = optional; |
| 78 |
struct Trans_NS___cxx11_basic_stringstream {}; |
| 79 |
void operator<<(Trans_NS___cxx11_basic_stringstream, int); |
| 80 |
int testfunctionfoo_myStructs[10]; |
| 81 |
void testfunctionfoo() { |
| 82 |
Optional<char> external, internal; |
| 83 |
for (auto myStruct : testfunctionfoo_myStructs) { |
| 84 |
Trans_NS___cxx11_basic_stringstream address_stream; |
| 85 |
address_stream << myStruct; |
| 86 |
external = internal; |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
// { dg-final { scan-tree-dump-not "m_initialized" "dce7" } } |