1 // Test case reduced from an experimental std modules implementation.
2 // Tests that the compiler don't emit confusing error about the ambiguous ctor
7 // RUN: split-file %s %t
9 // RUN: %clang_cc1 -std=c++20 %t/string.cppm -I%t -emit-module-interface -o %t/std-string.pcm
10 // RUN: %clang_cc1 -std=c++20 %t/algorithm.cppm -I%t -emit-module-interface -o %t/std-algorithm.pcm
11 // RUN: %clang_cc1 -std=c++20 %t/Use.cppm -I%t -fprebuilt-module-path=%t -emit-module-interface -verify -o %t/Use.pcm
13 // Test again with reduced BMI.
16 // RUN: split-file %s %t
18 // RUN: %clang_cc1 -std=c++20 %t/string.cppm -I%t -emit-reduced-module-interface -o %t/std-string.pcm
19 // RUN: %clang_cc1 -std=c++20 %t/algorithm.cppm -I%t -emit-reduced-module-interface -o %t/std-algorithm.pcm
20 // RUN: %clang_cc1 -std=c++20 %t/Use.cppm -I%t -fprebuilt-module-path=%t -emit-reduced-module-interface -verify -o %t/Use.pcm
23 // expected-no-diagnostics
26 # 3 "pair-unambiguous-ctor.cppm" 1 3
28 # 3 "pair-unambiguous-ctor.cppm" 2 3
39 # 28 "pair-unambiguous-ctor.cppm" 1 3
40 export module std:string;
41 export namespace std {
44 # 28 "pair-unambiguous-ctor.cppm" 2 3
48 #include "algorithm.h"
49 # 38 "pair-unambiguous-ctor.cppm" 1 3
50 export module std:algorithm;
51 # 38 "pair-unambiguous-ctor.cppm" 2 3
54 namespace std __attribute__ ((__visibility__ ("default")))
56 typedef long unsigned int size_t;
57 typedef long int ptrdiff_t;
59 typedef decltype(nullptr) nullptr_t;
61 template<typename _Tp, _Tp __v>
62 struct integral_constant
64 static constexpr _Tp value = __v;
65 typedef _Tp value_type;
66 typedef integral_constant<_Tp, __v> type;
67 constexpr operator value_type() const noexcept { return value; }
68 constexpr value_type operator()() const noexcept { return value; }
71 template<typename _Tp, _Tp __v>
72 constexpr _Tp integral_constant<_Tp, __v>::value;
74 typedef integral_constant<bool, true> true_type;
75 typedef integral_constant<bool, false> false_type;
78 using __bool_constant = integral_constant<bool, __v>;
81 template<bool, typename, typename>
84 template<bool _Cond, typename _Iftrue, typename _Iffalse>
86 { typedef _Iftrue type; };
88 template<typename _Iftrue, typename _Iffalse>
89 struct conditional<false, _Iftrue, _Iffalse>
90 { typedef _Iffalse type; };
93 template<bool, typename _Tp = void>
98 template<typename _Tp>
99 struct enable_if<true, _Tp>
100 { typedef _Tp type; };
102 template<typename _Tp, typename... _Args>
103 struct __is_constructible_impl
104 : public __bool_constant<__is_constructible(_Tp, _Args...)>
108 template<typename _Tp, typename... _Args>
109 struct is_constructible
110 : public __is_constructible_impl<_Tp, _Args...>
114 struct __is_void_helper
115 : public false_type { };
118 struct __is_void_helper<void>
119 : public true_type { };
121 template<typename _Tp>
123 : public __is_void_helper<_Tp>::type
126 template<typename...>
129 template<std::size_t...>
132 template <bool, typename _T1, typename _T2>
135 template <typename _U1, typename _U2>
136 static constexpr bool _ConstructiblePair()
138 return is_constructible<_T1, const _U1&>::value;
143 template<typename _T1, typename _T2>
146 typedef _T1 first_type;
147 typedef _T2 second_type;
152 using _PCCP = _PCC<true, _T1, _T2>;
154 template<typename _U1 = _T1, typename _U2=_T2, typename
155 enable_if<_PCCP::template
156 _ConstructiblePair<_U1, _U2>(),
158 constexpr pair(const _T1& __a, const _T2& __b)
159 : first(__a), second(__b) { }
162 operator=(typename conditional<
163 is_constructible<_T2>::value,
164 const pair&, nullptr_t>::type __p)
172 template<typename... _Args1, std::size_t... _Indexes1,
173 typename... _Args2, std::size_t... _Indexes2>
175 pair(tuple<_Args1...>&, tuple<_Args2...>&,
176 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
180 template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
186 namespace std __attribute__ ((__visibility__ ("default")))
190 template<typename _Tp>
191 using __make_not_void
192 = typename conditional<is_void<_Tp>::value, __undefined, _Tp>::type;
194 template <typename Ptr>
195 struct pointer_traits {};
197 template<typename _Tp>
198 struct pointer_traits<_Tp*>
201 typedef _Tp* pointer;
203 typedef _Tp element_type;
205 static constexpr pointer
206 pointer_to(__make_not_void<element_type>& __r) noexcept
207 { return __builtin_addressof(__r); }
210 template<typename _Tp>
213 template<typename _Alloc>
214 struct allocator_traits;
216 template<typename _Tp>
217 struct allocator_traits<allocator<_Tp>>
219 using pointer = _Tp*;
222 template<typename _Alloc>
223 struct __alloc_traits
224 : std::allocator_traits<_Alloc>
226 typedef std::allocator_traits<_Alloc> _Base_type;
227 typedef typename _Base_type::pointer pointer;
230 template<class _CharT>
233 template<typename _CharT, typename _Traits = char_traits<_CharT>,
234 typename _Alloc = allocator<_CharT> >
237 typedef std::__alloc_traits<_Alloc> _Alloc_traits;
240 typedef typename _Alloc_traits::pointer pointer;
244 _CharT _M_local_buf[16];
249 return std::pointer_traits<pointer>::pointer_to(*_M_local_buf);
253 : _M_dataplus(_M_local_data())
258 typedef basic_string<char> string;
264 struct _Power2_rehash_policy
266 std::pair<bool, std::size_t>
267 _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
268 std::size_t __n_ins) noexcept
278 typedef __SIZE_TYPE__ size_t;