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