[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / builtin-std-move-nobuiltin.cpp
blobea6b5d81bcf259eb4fd63ddeadf33805bb5b7996
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
7 int nobuiltin;
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; }
16 template<typename T> constexpr T *addr(T &&r) { return &r; }
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);