Add -fdelete-null-pointer-checks to more new C++ testcases.
[gcc.git] / gcc / testsuite / g++.dg / pr57878.C
1 /* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
2 // { dg-require-effective-target c++11 }
3 /* { dg-options "-O2 -fno-omit-frame-pointer -fPIC" } */
4
5 typedef int int32;
6 typedef long long int64;
7 typedef unsigned int uint32;
8 typedef unsigned long long uint64;
9 namespace std {
10 typedef __SIZE_TYPE__ size_t;
11 template<class _CharT>
12 struct char_traits;
13 template<typename _Tp>
14 inline _Tp* __addressof(_Tp& __r) noexcept {
15 return reinterpret_cast<_Tp*> (&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
16 }
17 template<typename _Tp>
18 struct remove_reference {
19 typedef _Tp type;
20 };
21 template<typename _Tp>
22 constexpr _Tp&& forward(typename std::remove_reference<_Tp>::type& __t) noexcept {
23 return static_cast<_Tp&&>(__t);
24 }
25 }
26 typedef __SIZE_TYPE__ size_t;
27 extern "C++" {
28 inline void* operator new(std::size_t, void* __p) noexcept {
29 return __p;
30 }
31 }
32 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
33 template<typename _Tp>
34 class new_allocator {
35 public:
36 typedef size_t size_type;
37 typedef _Tp* pointer;
38 };
39 }
40 namespace std {
41 template<typename _Tp>
42 using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
43 template<typename _Tp>
44 class allocator
45 : public __allocator_base<_Tp> {
46 public:
47 typedef size_t size_type;
48 template<typename _Tp1>
49 struct rebind {
50 typedef allocator<_Tp1> other;
51 };
52 };
53 }
54 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
55 template<typename _CharT, typename _Traits, typename _Alloc>
56 class __sso_string_base;
57 template<typename _CharT, typename _Traits = std::char_traits<_CharT>, typename _Alloc = std::allocator<_CharT>, template <typename, typename, typename> class _Base = __sso_string_base>
58 class __versa_string;
59 template<typename _CharT, typename _Traits, typename _Alloc>
60 struct __vstring_utility {
61 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
62 template<typename _Alloc1>
63 struct _Alloc_hider
64 : public _Alloc1 {
65 _Alloc_hider(const _Alloc1& __a, _CharT* __ptr)
66 : _Alloc1(__a), _M_p(__ptr) {
67 }
68 _CharT* _M_p;
69 };
70 };
71 template<typename _CharT, typename _Traits, typename _Alloc>
72 class __sso_string_base
73 : protected __vstring_utility<_CharT, _Traits, _Alloc> {
74 typedef __vstring_utility<_CharT, _Traits, _Alloc> _Util_Base;
75 typedef typename _Util_Base::_CharT_alloc_type _CharT_alloc_type;
76 typedef typename _CharT_alloc_type::size_type size_type;
77 private:
78 typename _Util_Base::template _Alloc_hider<_CharT_alloc_type>
79 _M_dataplus;
80 size_type _M_string_length;
81 enum {
82 _S_local_capacity = 15 };
83 union {
84 _CharT _M_local_data[_S_local_capacity + 1];
85 };
86 template<typename _InIterator>
87 void _M_construct(_InIterator __beg, _InIterator __end);
88 public:
89 size_type _M_max_size() const;
90 _CharT* _M_data() const {
91 return _M_dataplus._M_p;
92 }
93 size_type _M_length() const {
94 return _M_string_length;
95 }
96 __sso_string_base(const __sso_string_base& __rcs);
97 const _CharT_alloc_type& _M_get_allocator() const {
98 static _CharT_alloc_type c;
99 return c;
100 }
101 };
102 template<typename _CharT, typename _Traits, typename _Alloc>
103 __sso_string_base<_CharT, _Traits, _Alloc>:: __sso_string_base(const __sso_string_base& __rcs)
104 : _M_dataplus(__rcs._M_get_allocator(), _M_local_data) {
105 _M_construct(__rcs._M_data(), __rcs._M_data() + __rcs._M_length());
106 }
107 template<typename _CharT, typename _Traits, typename _Alloc, template <typename, typename, typename> class _Base>
108 class __versa_string
109 : private _Base<_CharT, _Traits, _Alloc> {
110 };
111 }
112 template<typename _CharT, typename _Traits = std::char_traits<_CharT>, typename _Alloc = std::allocator<_CharT> >
113 class basic_string
114 : public __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc> {
115 };
116 typedef basic_string<char> string;
117 namespace std __attribute__ ((__visibility__ ("default"))) {
118 template<typename _Alloc, typename _Tp>
119 class __alloctr_rebind_helper {
120 public:
121 static const bool __value = true;
122 };
123 template<typename _Alloc, typename _Tp, bool = __alloctr_rebind_helper<_Alloc, _Tp>::__value>
124 struct __alloctr_rebind;
125 template<typename _Alloc, typename _Tp> struct __alloctr_rebind<_Alloc, _Tp, true>
126 {
127 typedef typename _Alloc::template rebind<_Tp>::other __type;
128 };
129 template<typename _Alloc>
130 struct allocator_traits {
131 private:
132 template<typename _Tp>
133 static typename _Tp::pointer _S_pointer_helper(_Tp*);
134 typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer;
135 public:
136 typedef __pointer pointer;
137 template<typename _Tp>
138 using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;
139 };
140 }
141 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
142 template<typename _Alloc> struct __alloc_traits
143 : std::allocator_traits<_Alloc>
144 {
145 typedef std::allocator_traits<_Alloc> _Base_type;
146 template<typename _Tp>
147 struct rebind {
148 typedef typename _Base_type::template rebind_alloc<_Tp>
149 other;
150 };
151 };
152 }
153 namespace std __attribute__ ((__visibility__ ("default"))) {
154 template<typename _T1, typename... _Args>
155 inline void _Construct(_T1* __p, _Args&&... __args) {
156 ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...);
157 }
158 template<typename _Tp, typename _Alloc>
159 struct _Vector_base {
160 typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type;
161 typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer pointer;
162 struct _Vector_impl
163 : public _Tp_alloc_type {
164 pointer _M_start;
165 pointer _M_finish;
166 };
167 public:
168 _Vector_impl _M_impl;
169 };
170 template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
171 class vector
172 : protected _Vector_base<_Tp, _Alloc> {
173 typedef _Vector_base<_Tp, _Alloc> _Base;
174 public:
175 typedef _Tp value_type;
176 typedef typename _Base::pointer pointer;
177 typedef size_t size_type;
178 size_type size() const;
179 void push_back(const value_type& __x) {
180 _M_emplace_back_aux(__x);
181 }
182 template<typename... _Args>
183 void _M_emplace_back_aux(_Args&&... __args);
184 size_type _M_check_len();
185 };
186 template<typename _Tp, typename _Alloc> template<typename... _Args>
187 void vector<_Tp, _Alloc>:: _M_emplace_back_aux(_Args&&... __args) {
188 const size_type __len = _M_check_len();
189 pointer __new_start(static_cast<pointer>(::operator new(__len * sizeof(_Tp))));
190 pointer __new_temp(__new_start + size());
191 ::new((void *)__new_temp) _Tp(std::forward<_Args>(__args)...);
192 pointer __cur = __new_start;
193 pointer __first = this->_M_impl._M_start;
194 pointer __last = this->_M_impl._M_finish;
195 for (;
196 __first != __last;
197 ++__first, ++__cur) std::_Construct(std::__addressof(*__cur), *__first);
198 }
199 }
200 using std::vector;
201 class DL {
202 public:
203 struct ChunkId {
204 int64 disk_id;
205 uint64 handle;
206 uint64 version;
207 string capability;
208 ChunkId();
209 };
210 struct ChunkInfo {
211 ChunkId id;
212 uint64 mtime;
213 uint32 length;
214 int32 space_used;
215 };
216 };
217 class FDB {
218 void CollectChunk(const DL::ChunkInfo& chunk, const int& location);
219 private:
220 struct ChunkData {
221 int location;
222 DL::ChunkInfo chunk_info;
223 };
224 vector<ChunkData> chunk_data_;
225 };
226 void FDB::CollectChunk(const DL::ChunkInfo& chunk, const int& location) {
227 ChunkData chunk_data;
228 chunk_data_.push_back( chunk_data);
229 }