canonical.cpp revision 762bb9d0ad20320b9f97a841dce57ba5e8e48b07
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2
3// PR10087: Make sure that we don't conflate exception specifications
4// from different functions in the canonical type system.
5namespace std
6{
7
8template <class _Tp> _Tp&& declval() noexcept;
9
10template <class _Tp, class... _Args>
11struct __is_nothrow_constructible
12{
13  static const bool value = noexcept(_Tp(declval<_Args>()...));
14};
15
16template<class, class _Traits, class _Allocator>
17class basic_string
18{
19public:
20  typedef typename _Traits::char_type value_type;
21  typedef _Allocator allocator_type;
22
23  basic_string()
24      noexcept(__is_nothrow_constructible<allocator_type>::value);
25};
26
27template <class, class, class _Compare>
28struct __map_value_compare
29{
30public:
31  __map_value_compare()
32      noexcept(__is_nothrow_constructible<_Compare>::value);
33};
34
35struct less
36{
37};
38
39struct map
40{
41  typedef __map_value_compare<int, short, less> __vc;
42  __vc vc_;
43};
44
45
46template<class T, class _Traits, class _Allocator>
47basic_string<T, _Traits, _Allocator>::basic_string() noexcept(__is_nothrow_constructible<allocator_type>::value) {}
48
49template <class T, class Value, class _Compare>
50__map_value_compare<T, Value, _Compare>::__map_value_compare()
51  noexcept(__is_nothrow_constructible<_Compare>::value) {}
52
53}  // std
54