| 1 |
// RUN: %clang_cc1 -std=c++20 -verify %s -DBUILTIN=builtin |
| 2 |
// RUN: %clang_cc1 -std=c++20 -verify %s -DBUILTIN=nobuiltin -fno-builtin |
| 3 |
// RUN: %clang_cc1 -std=c++20 -verify %s -DBUILTIN=nobuiltin -fno-builtin-std-move -fno-builtin-std-move_if_noexcept -fno-builtin-std-forward -fno-builtin-std-forward_like |
| 4 |
// RUN: %clang_cc1 -std=c++20 -verify %s -DBUILTIN=nobuiltin -ffreestanding |
| 5 |
// expected-no-diagnostics |
| 6 |
|
| 7 |
int nobuiltin; |
| 8 |
|
| 9 |
namespace std { |
| 10 |
template<typename T> constexpr T &&move(T &x) { return (T&&)nobuiltin; } |
| 11 |
template<typename T> constexpr T &&move_if_noexcept(T &x) { return (T&&)nobuiltin; } |
| 12 |
template<typename T> constexpr T &&forward(T &x) { return (T&&)nobuiltin; } |
| 13 |
template<typename U, typename T> constexpr T &&forward_like(T &X) { return (T&&)nobuiltin; } |
| 14 |
} |
| 15 |
|
| 16 |
template<typename T> constexpr T *addr(T &&r) { return &r; } |
| 17 |
|
| 18 |
int builtin; |
| 19 |
static_assert(addr(std::move(builtin)) == &BUILTIN); |
| 20 |
static_assert(addr(std::move_if_noexcept(builtin)) == &BUILTIN); |
| 21 |
static_assert(addr(std::forward(builtin)) == &BUILTIN); |
| 22 |
static_assert(addr(std::forward_like<int&>(builtin)) == &BUILTIN); |