Skip to content

Commit 6fc2318

Browse files
authored
[libc++][C++03] Cherry-pick #123236 and #147835 (#163363)
1 parent 0ebcc97 commit 6fc2318

File tree

7 files changed

+15
-24
lines changed

7 files changed

+15
-24
lines changed

libcxx/include/__cxx03/__atomic/atomic.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3434

3535
template <class _Tp>
3636
struct atomic : public __atomic_base<_Tp> {
37-
using __base = __atomic_base<_Tp>;
38-
using value_type = _Tp;
39-
using difference_type = value_type;
37+
using __base = __atomic_base<_Tp>;
4038

4139
_LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;
4240

@@ -59,8 +57,8 @@ struct atomic : public __atomic_base<_Tp> {
5957

6058
template <class _Tp>
6159
struct atomic<_Tp*> : public __atomic_base<_Tp*> {
62-
using __base = __atomic_base<_Tp*>;
63-
using value_type = _Tp*;
60+
using __base = __atomic_base<_Tp*>;
61+
6462
using difference_type = ptrdiff_t;
6563

6664
_LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;

libcxx/include/__cxx03/__atomic/atomic_base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ struct __atomic_base // false
3232
{
3333
mutable __cxx_atomic_impl<_Tp> __a_;
3434

35+
using value_type = _Tp;
36+
3537
_LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT {
3638
return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>));
3739
}
@@ -127,6 +129,8 @@ template <class _Tp>
127129
struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> {
128130
using __base = __atomic_base<_Tp, false>;
129131

132+
using difference_type = typename __base::value_type;
133+
130134
_LIBCPP_HIDE_FROM_ABI __atomic_base() _NOEXCEPT = default;
131135

132136
_LIBCPP_HIDE_FROM_ABI __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}

libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
10-
119
// <atomic>
1210

1311
// template <class T>
@@ -48,12 +46,12 @@ void pointer_to_incomplete_type() {
4846
void function_pointer() {
4947
{
5048
volatile std::atomic<void (*)(int)> fun;
51-
// expected-error-re@*:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
49+
// expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Pointer to function isn't allowed}}
5250
std::atomic_fetch_add(&fun, 0);
5351
}
5452
{
5553
std::atomic<void (*)(int)> fun;
56-
// expected-error-re@*:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
54+
// expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Pointer to function isn't allowed}}
5755
std::atomic_fetch_add(&fun, 0);
5856
}
5957
}

libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
10-
119
// <atomic>
1210

1311
// template <class T>
@@ -51,12 +49,12 @@ void pointer_to_incomplete_type() {
5149
void function_pointer() {
5250
{
5351
volatile std::atomic<void (*)(int)> fun;
54-
// expected-error-re@*:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
52+
// expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Pointer to function isn't allowed}}
5553
std::atomic_fetch_add_explicit(&fun, 0, std::memory_order_relaxed);
5654
}
5755
{
5856
std::atomic<void (*)(int)> fun;
59-
// expected-error-re@*:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
57+
// expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Pointer to function isn't allowed}}
6058
std::atomic_fetch_add_explicit(&fun, 0, std::memory_order_relaxed);
6159
}
6260
}

libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
10-
119
// <atomic>
1210

1311
// template <class T>
@@ -48,12 +46,12 @@ void pointer_to_incomplete_type() {
4846
void function_pointer() {
4947
{
5048
volatile std::atomic<void (*)(int)> fun;
51-
// expected-error-re@*:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
49+
// expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Pointer to function isn't allowed}}
5250
std::atomic_fetch_sub(&fun, 0);
5351
}
5452
{
5553
std::atomic<void (*)(int)> fun;
56-
// expected-error-re@*:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
54+
// expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Pointer to function isn't allowed}}
5755
std::atomic_fetch_sub(&fun, 0);
5856
}
5957
}

libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
10-
119
// <atomic>
1210

1311
// template <class T>
@@ -51,12 +49,12 @@ void pointer_to_incomplete_type() {
5149
void function_pointer() {
5250
{
5351
volatile std::atomic<void (*)(int)> fun;
54-
// expected-error-re@*:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
52+
// expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Pointer to function isn't allowed}}
5553
std::atomic_fetch_sub_explicit(&fun, 0, std::memory_order_relaxed);
5654
}
5755
{
5856
std::atomic<void (*)(int)> fun;
59-
// expected-error-re@*:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
57+
// expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Pointer to function isn't allowed}}
6058
std::atomic_fetch_sub_explicit(&fun, 0, std::memory_order_relaxed);
6159
}
6260
}

libcxx/test/std/atomics/types.pass.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
// typedef T value_type;
1818
// };
1919

20-
// atomic still has a difference_type in the C++03 frozen headers
21-
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
22-
2320
#include <atomic>
2421
#include <chrono>
2522
#include <cstdint>

0 commit comments

Comments
 (0)