| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target c++11 } */ |
| 3 |
/* { dg-options "-O3 -fnon-call-exceptions -ftracer -march=k8 -Wno-return-type" } */ |
| 4 |
|
| 5 |
|
| 6 |
template <int __v> struct integral_constant { |
| 7 |
|
| 8 |
static constexpr int value = __v; |
| 9 |
|
| 10 |
}; |
| 11 |
|
| 12 |
template <bool __v> using __bool_constant = integral_constant<__v>; |
| 13 |
|
| 14 |
template <typename _Tp, typename _Up> |
| 15 |
|
| 16 |
struct is_same : integral_constant<true> {}; |
| 17 |
|
| 18 |
template <bool, typename _Tp> using __enable_if_t = _Tp; |
| 19 |
|
| 20 |
void *operator new(__SIZE_TYPE__, void *__p) { return __p; } |
| 21 |
|
| 22 |
template <typename _Iterator, typename> class __normal_iterator { |
| 23 |
|
| 24 |
_Iterator _M_current; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public: |
| 29 |
|
| 30 |
__normal_iterator(_Iterator) {} |
| 31 |
|
| 32 |
void operator++() { ++_M_current; } |
| 33 |
|
| 34 |
_Iterator base() { return _M_current; } |
| 35 |
|
| 36 |
}; |
| 37 |
|
| 38 |
template <typename _IteratorL, typename _IteratorR, typename _Container> |
| 39 |
|
| 40 |
bool operator!=(__normal_iterator<_IteratorL, _Container> __lhs, |
| 41 |
|
| 42 |
__normal_iterator<_IteratorR, _Container> __rhs) { |
| 43 |
|
| 44 |
return __lhs.base() != __rhs.base(); |
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
template <typename _Tp> void construct_at(_Tp *__location) noexcept { |
| 49 |
|
| 50 |
new (__location) _Tp; |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
template <typename _Tp> void _Construct(_Tp __p) { construct_at(__p); } |
| 55 |
|
| 56 |
struct _Any_data { |
| 57 |
|
| 58 |
template <typename _Tp> _Tp _M_access(); |
| 59 |
|
| 60 |
}; |
| 61 |
|
| 62 |
enum _Manager_operation {}; |
| 63 |
|
| 64 |
template <typename> class function; |
| 65 |
|
| 66 |
class _Function_base { |
| 67 |
|
| 68 |
public: |
| 69 |
|
| 70 |
template <typename _Functor> class _Base_manager { |
| 71 |
|
| 72 |
public: |
| 73 |
|
| 74 |
static bool _M_manager(_Any_data, _Any_data __source, _Manager_operation) { |
| 75 |
|
| 76 |
_Functor(*__source._M_access<_Functor *>()); |
| 77 |
|
| 78 |
return true; |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
}; |
| 83 |
|
| 84 |
typedef bool (*_Manager_type)(_Any_data &, const _Any_data &, |
| 85 |
|
| 86 |
_Manager_operation); |
| 87 |
|
| 88 |
_Manager_type _M_manager; |
| 89 |
|
| 90 |
}; |
| 91 |
|
| 92 |
template <typename, typename> class _Function_handler; |
| 93 |
|
| 94 |
template <typename _Res, typename _Functor, typename... _ArgTypes> |
| 95 |
|
| 96 |
class _Function_handler<_Res(_ArgTypes...), _Functor> : _Function_base { |
| 97 |
|
| 98 |
public: |
| 99 |
|
| 100 |
static bool _M_manager(_Any_data &__dest, const _Any_data &__source, |
| 101 |
|
| 102 |
_Manager_operation __op) { |
| 103 |
|
| 104 |
_Base_manager<_Functor>::_M_manager(__dest, __source, __op); |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
}; |
| 109 |
|
| 110 |
template <typename _Res, typename... _ArgTypes> |
| 111 |
|
| 112 |
class function<_Res(_ArgTypes...)> : _Function_base { |
| 113 |
|
| 114 |
template <typename, typename _Tp> using _Requires = _Tp; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
public: |
| 119 |
|
| 120 |
template <typename _Functor, |
| 121 |
|
| 122 |
typename = _Requires<__bool_constant<!bool()>, void>, |
| 123 |
|
| 124 |
typename = _Requires<_Functor, void>> |
| 125 |
|
| 126 |
function(_Functor); |
| 127 |
|
| 128 |
}; |
| 129 |
|
| 130 |
template <typename _Res, typename... _ArgTypes> |
| 131 |
|
| 132 |
template <typename _Functor, typename, typename> |
| 133 |
|
| 134 |
function<_Res(_ArgTypes...)>::function(_Functor) { |
| 135 |
|
| 136 |
_M_manager = _Function_handler<_Res(), _Functor>::_M_manager; |
| 137 |
|
| 138 |
} |
| 139 |
|
| 140 |
template <typename _Tp> class new_allocator { |
| 141 |
|
| 142 |
public: |
| 143 |
|
| 144 |
_Tp *allocate(long) { return static_cast<_Tp *>(operator new(sizeof(_Tp))); } |
| 145 |
|
| 146 |
}; |
| 147 |
|
| 148 |
namespace std { |
| 149 |
|
| 150 |
template <typename> struct allocator_traits; |
| 151 |
|
| 152 |
template <typename _Tp> struct allocator_traits<new_allocator<_Tp>> { |
| 153 |
|
| 154 |
using allocator_type = new_allocator<_Tp>; |
| 155 |
|
| 156 |
using pointer = _Tp *; |
| 157 |
|
| 158 |
using const_pointer = _Tp *; |
| 159 |
|
| 160 |
using size_type = long; |
| 161 |
|
| 162 |
template <typename _Up> using rebind_alloc = new_allocator<_Up>; |
| 163 |
|
| 164 |
static pointer allocate(allocator_type __a, size_type __n) { |
| 165 |
|
| 166 |
return __a.allocate(__n); |
| 167 |
|
| 168 |
} |
| 169 |
|
| 170 |
static void deallocate(allocator_type, pointer, size_type); |
| 171 |
|
| 172 |
}; |
| 173 |
|
| 174 |
} |
| 175 |
|
| 176 |
template <typename _Alloc> |
| 177 |
|
| 178 |
struct __alloc_traits : std::allocator_traits<_Alloc> { |
| 179 |
|
| 180 |
template <typename _Tp> struct rebind { |
| 181 |
|
| 182 |
typedef typename std::allocator_traits<_Alloc>::template rebind_alloc<_Tp> other; |
| 183 |
|
| 184 |
}; |
| 185 |
|
| 186 |
}; |
| 187 |
|
| 188 |
namespace std { |
| 189 |
|
| 190 |
struct __uninitialized_copy { |
| 191 |
|
| 192 |
template <typename _InputIterator, typename _ForwardIterator> |
| 193 |
|
| 194 |
static _ForwardIterator __uninit_copy(_InputIterator __first, |
| 195 |
|
| 196 |
_InputIterator __last, |
| 197 |
|
| 198 |
_ForwardIterator __result) { |
| 199 |
|
| 200 |
for (; __first != __last; ++__first, ++__result) |
| 201 |
|
| 202 |
_Construct(__result); |
| 203 |
|
| 204 |
return __result; |
| 205 |
|
| 206 |
} |
| 207 |
|
| 208 |
}; |
| 209 |
|
| 210 |
template <typename _InputIterator, typename _ForwardIterator> |
| 211 |
|
| 212 |
_ForwardIterator uninitialized_copy(_InputIterator __first, |
| 213 |
|
| 214 |
_InputIterator __last, |
| 215 |
|
| 216 |
_ForwardIterator __result) { |
| 217 |
|
| 218 |
return __uninitialized_copy::__uninit_copy(__first, __last, __result); |
| 219 |
|
| 220 |
} |
| 221 |
|
| 222 |
template <typename _InputIterator, typename _ForwardIterator, typename _Tp> |
| 223 |
|
| 224 |
_ForwardIterator __uninitialized_copy_a(_InputIterator __first, |
| 225 |
|
| 226 |
_InputIterator __last, |
| 227 |
|
| 228 |
_ForwardIterator __result, _Tp) { |
| 229 |
|
| 230 |
return uninitialized_copy(__first, __last, __result); |
| 231 |
|
| 232 |
} |
| 233 |
|
| 234 |
template <typename _Tp, typename _Alloc> struct _Vector_base { |
| 235 |
|
| 236 |
typedef typename __alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type; |
| 237 |
|
| 238 |
typedef typename __alloc_traits<_Tp_alloc_type>::pointer pointer; |
| 239 |
|
| 240 |
struct _Vector_impl_data { |
| 241 |
|
| 242 |
pointer _M_start; |
| 243 |
|
| 244 |
pointer _M_finish; |
| 245 |
|
| 246 |
}; |
| 247 |
|
| 248 |
struct _Vector_impl : _Tp_alloc_type, _Vector_impl_data {}; |
| 249 |
|
| 250 |
_Tp_alloc_type _M_get_Tp_allocator(); |
| 251 |
|
| 252 |
_Vector_base(long, _Alloc) { |
| 253 |
|
| 254 |
_M_impl._M_start = _M_allocate(); |
| 255 |
|
| 256 |
_M_impl._M_finish = _M_impl._M_start; |
| 257 |
|
| 258 |
} |
| 259 |
|
| 260 |
~_Vector_base() { _M_deallocate(_M_impl._M_start); } |
| 261 |
|
| 262 |
_Vector_impl _M_impl; |
| 263 |
|
| 264 |
long _M_allocate___n; |
| 265 |
|
| 266 |
pointer _M_allocate() { |
| 267 |
|
| 268 |
typedef __alloc_traits<_Tp_alloc_type> _Tr; |
| 269 |
|
| 270 |
return _M_allocate___n ? _Tr::allocate(_M_impl, _M_allocate___n) |
| 271 |
|
| 272 |
: pointer(); |
| 273 |
|
| 274 |
} |
| 275 |
|
| 276 |
long _M_deallocate___n; |
| 277 |
|
| 278 |
void _M_deallocate(pointer __p) { |
| 279 |
|
| 280 |
typedef __alloc_traits<_Tp_alloc_type> _Tr; |
| 281 |
|
| 282 |
if (__p) |
| 283 |
|
| 284 |
_Tr::deallocate(_M_impl, __p, _M_deallocate___n); |
| 285 |
|
| 286 |
} |
| 287 |
|
| 288 |
}; |
| 289 |
|
| 290 |
template <typename _Tp, typename _Alloc = new_allocator<_Tp>> |
| 291 |
|
| 292 |
class vector : _Vector_base<_Tp, _Alloc> { |
| 293 |
|
| 294 |
typedef _Vector_base<_Tp, _Alloc> _Base; |
| 295 |
|
| 296 |
typedef __normal_iterator< |
| 297 |
|
| 298 |
typename __alloc_traits<typename _Base::_Tp_alloc_type>::const_pointer, |
| 299 |
|
| 300 |
int> |
| 301 |
|
| 302 |
const_iterator; |
| 303 |
|
| 304 |
using _Base::_M_get_Tp_allocator; |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
public: |
| 309 |
|
| 310 |
vector(); |
| 311 |
|
| 312 |
vector(vector &__x) : _Base(0, _M_get_Tp_allocator()) { |
| 313 |
|
| 314 |
this->_M_impl._M_finish = __uninitialized_copy_a(__x.begin(), __x.end(), |
| 315 |
|
| 316 |
this->_M_impl._M_start, 0); |
| 317 |
|
| 318 |
} |
| 319 |
|
| 320 |
const_iterator begin() noexcept { return this->_M_impl._M_start; } |
| 321 |
|
| 322 |
const_iterator end() noexcept { return this->_M_impl._M_finish; } |
| 323 |
|
| 324 |
}; |
| 325 |
|
| 326 |
template <typename _Tp> class __shared_ptr_access { |
| 327 |
|
| 328 |
public: |
| 329 |
|
| 330 |
using element_type = _Tp; |
| 331 |
|
| 332 |
element_type *operator->(); |
| 333 |
|
| 334 |
}; |
| 335 |
|
| 336 |
enum syntax_option_type : int; |
| 337 |
|
| 338 |
template <typename> using _Matcher = function<bool()>; |
| 339 |
|
| 340 |
struct _NFA { |
| 341 |
|
| 342 |
void _M_insert_matcher(_Matcher<int>); |
| 343 |
|
| 344 |
}; |
| 345 |
|
| 346 |
template <typename _TraitsT> class _Compiler { |
| 347 |
|
| 348 |
public: |
| 349 |
|
| 350 |
typedef typename _TraitsT::char_type *_IterT; |
| 351 |
|
| 352 |
_Compiler(_IterT, _IterT, const typename _TraitsT::locale_type &, syntax_option_type); |
| 353 |
|
| 354 |
template <bool> void _M_insert_character_class_matcher(); |
| 355 |
|
| 356 |
syntax_option_type _M_flags; |
| 357 |
|
| 358 |
__shared_ptr_access<_NFA> _M_nfa; |
| 359 |
|
| 360 |
_TraitsT _M_traits; |
| 361 |
|
| 362 |
}; |
| 363 |
|
| 364 |
template <typename, typename> |
| 365 |
|
| 366 |
using __enable_if_contiguous_iter = |
| 367 |
|
| 368 |
__enable_if_t<integral_constant<false>::value, |
| 369 |
|
| 370 |
__shared_ptr_access<_NFA>>; |
| 371 |
|
| 372 |
syntax_option_type __compile_nfa___flags; |
| 373 |
|
| 374 |
struct Trans_NS___cxx11_regex_traits { |
| 375 |
|
| 376 |
typedef char char_type; |
| 377 |
|
| 378 |
typedef int locale_type; |
| 379 |
|
| 380 |
struct _RegexMask { |
| 381 |
|
| 382 |
short _M_base; |
| 383 |
|
| 384 |
char _M_extended; |
| 385 |
|
| 386 |
_RegexMask() : _M_extended() {} |
| 387 |
|
| 388 |
} typedef char_class_type; |
| 389 |
|
| 390 |
}; |
| 391 |
|
| 392 |
template <typename _FwdIter> |
| 393 |
|
| 394 |
__enable_if_contiguous_iter<_FwdIter, char> __compile_nfa(_FwdIter) { |
| 395 |
|
| 396 |
auto __cfirst = nullptr; |
| 397 |
|
| 398 |
using _Cmplr = _Compiler<Trans_NS___cxx11_regex_traits>; |
| 399 |
|
| 400 |
_Cmplr(__cfirst, __cfirst, 0, __compile_nfa___flags); |
| 401 |
|
| 402 |
} |
| 403 |
|
| 404 |
class _RegexTranslatorBase { |
| 405 |
|
| 406 |
public: |
| 407 |
|
| 408 |
_RegexTranslatorBase(Trans_NS___cxx11_regex_traits); |
| 409 |
|
| 410 |
}; |
| 411 |
|
| 412 |
class _RegexTranslator : _RegexTranslatorBase { |
| 413 |
|
| 414 |
typedef _RegexTranslatorBase _Base; |
| 415 |
|
| 416 |
using _Base::_Base; |
| 417 |
|
| 418 |
}; |
| 419 |
|
| 420 |
template <typename _TraitsT, int> struct _BracketMatcher { |
| 421 |
|
| 422 |
_BracketMatcher(bool, _TraitsT __traits) : _M_translator(__traits) {} |
| 423 |
|
| 424 |
vector<typename _TraitsT::char_class_type> _M_neg_class_set; |
| 425 |
|
| 426 |
_RegexTranslator _M_translator; |
| 427 |
|
| 428 |
}; |
| 429 |
|
| 430 |
template <typename _TraitsT> |
| 431 |
|
| 432 |
_Compiler<_TraitsT>::_Compiler(_IterT __b, _IterT __e, |
| 433 |
|
| 434 |
const typename _TraitsT::locale_type &__loc, |
| 435 |
|
| 436 |
syntax_option_type) { |
| 437 |
|
| 438 |
_M_insert_character_class_matcher<false>(); |
| 439 |
|
| 440 |
_M_insert_character_class_matcher<true>(); |
| 441 |
|
| 442 |
} |
| 443 |
|
| 444 |
template <typename _TraitsT> |
| 445 |
|
| 446 |
template <bool __collate> |
| 447 |
|
| 448 |
void _Compiler<_TraitsT>::_M_insert_character_class_matcher() { |
| 449 |
|
| 450 |
_BracketMatcher<_TraitsT, __collate> __matcher(0, _M_traits); |
| 451 |
|
| 452 |
_M_nfa->_M_insert_matcher(__matcher); |
| 453 |
|
| 454 |
} |
| 455 |
|
| 456 |
class Trans_NS___cxx11_basic_regex { |
| 457 |
|
| 458 |
public: |
| 459 |
|
| 460 |
char Trans_NS___cxx11_basic_regex___last; |
| 461 |
|
| 462 |
Trans_NS___cxx11_basic_regex() |
| 463 |
|
| 464 |
: _M_automaton(__compile_nfa(Trans_NS___cxx11_basic_regex___last)) {} /* { dg-error } */ |
| 465 |
|
| 466 |
__shared_ptr_access<_NFA> _M_automaton; |
| 467 |
|
| 468 |
} regex_sanity_check___f; |
| 469 |
|
| 470 |
} |