| 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: no-threads |
| 10 |
|
| 11 |
// This test verifies that <stdatomic.h> DOES NOT redirect to <atomic> before C++23, |
| 12 |
// since doing so is a breaking change. Several things can break when that happens, |
| 13 |
// because the type of _Atomic(T) changes from _Atomic(T) to std::atomic<T>. |
| 14 |
// |
| 15 |
// For example, redeclarations can become invalid depending on whether they |
| 16 |
// have been declared with <stdatomic.h> in scope or not. |
| 17 |
|
| 18 |
// REQUIRES: c++03 || c++11 || c++14 || c++17 || c++20 |
| 19 |
|
| 20 |
// On GCC, the compiler-provided <stdatomic.h> is not C++ friendly, so including <stdatomic.h> |
| 21 |
// doesn't work at all if we don't use the <stdatomic.h> provided by libc++ in C++23 and above. |
| 22 |
// XFAIL: (c++11 || c++14 || c++17 || c++20) && gcc |
| 23 |
|
| 24 |
#include <atomic> |
| 25 |
#include <stdatomic.h> |
| 26 |
#include <type_traits> |
| 27 |
|
| 28 |
static_assert(!std::is_same<_Atomic(int), std::atomic<int> >::value, ""); |