Skip to content

Commit 19a8748

Browse files
author
git apple-llvm automerger
committed
Merge commit '4d4a4100f68d' from llvm.org/release/19.x into stable/20240723
2 parents e72b935 + 4d4a410 commit 19a8748

File tree

4 files changed

+78
-6
lines changed

4 files changed

+78
-6
lines changed

libcxx/include/complex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ public:
421421

422422
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f) : __re_(__re), __im_(__im) {}
423423

424-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(__from_builtin_tag, _Complex float __v)
424+
template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
425+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex float __v)
425426
: __re_(__real__ __v), __im_(__imag__ __v) {}
426427

427428
_LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
@@ -517,7 +518,8 @@ public:
517518

518519
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0) : __re_(__re), __im_(__im) {}
519520

520-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(__from_builtin_tag, _Complex double __v)
521+
template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
522+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex double __v)
521523
: __re_(__real__ __v), __im_(__imag__ __v) {}
522524

523525
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
@@ -617,7 +619,8 @@ public:
617619
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L)
618620
: __re_(__re), __im_(__im) {}
619621

620-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(__from_builtin_tag, _Complex long double __v)
622+
template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
623+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex long double __v)
621624
: __re_(__real__ __v), __im_(__imag__ __v) {}
622625

623626
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c);

libcxx/include/optional

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ struct __optional_destruct_base<_Tp, false> {
301301

302302
# if _LIBCPP_STD_VER >= 23
303303
template <class _Fp, class... _Args>
304-
_LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base(
304+
_LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(
305305
__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
306306
: __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {}
307307
# endif
@@ -707,8 +707,11 @@ public:
707707
}
708708

709709
# if _LIBCPP_STD_VER >= 23
710-
template <class _Fp, class... _Args>
711-
_LIBCPP_HIDE_FROM_ABI constexpr explicit optional(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
710+
template <class _Tag,
711+
class _Fp,
712+
class... _Args,
713+
__enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0>
714+
_LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args)
712715
: __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {}
713716
# endif
714717

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// <complex>
10+
11+
// Regression test for https://github.com/llvm/llvm-project/issues/101960 where we used to
12+
// trigger an ambiguous constructor.
13+
14+
#include <complex>
15+
#include <cassert>
16+
17+
struct NastyConvertible {
18+
template <class T>
19+
operator T() const {
20+
return T(0);
21+
}
22+
};
23+
24+
template <class T>
25+
void test() {
26+
NastyConvertible nasty;
27+
std::complex<T> x(nasty, nasty);
28+
assert(x.real() == T(0));
29+
assert(x.imag() == T(0));
30+
}
31+
32+
int main(int, char**) {
33+
test<float>();
34+
test<double>();
35+
test<long double>();
36+
37+
return 0;
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03, c++11, c++14
10+
11+
// <optional>
12+
13+
// Regression test for https://github.com/llvm/llvm-project/issues/101960 where a constructor
14+
// of std::optional that should have been private was instead publicly available.
15+
16+
#include <optional>
17+
#include <type_traits>
18+
19+
struct NastyConvertible {
20+
template <class T>
21+
operator T() {
22+
return 0;
23+
}
24+
};
25+
26+
using F = int(int);
27+
28+
static_assert(!std::is_constructible<std::optional<int>, NastyConvertible, int(int), int>::value);

0 commit comments

Comments
 (0)