Mariya Podchishchaeva d0db54e0dd [clang] Update test according to P1937
https://wg21.link/p1937 proposes that in unevaluated contexts, consteval
functions should not be immediately evaluated.
Clang implemented p1937 a while ago, its behavior is correct and the
test needs an update.

Reviewed By: aaron.ballman, shafik

Differential Revision: https://reviews.llvm.org/D145362
2023-03-07 11:30:25 -05:00

33 lines
856 B
C++

// RUN: %clang_cc1 -std=c++20 -verify %s
// expected-no-diagnostics
namespace P1937R2 {
struct N {
constexpr N() {}
N(N const&) = delete;
};
template<typename T> constexpr void bad_assert_copyable() { T t; T t2 = t; }
using ineffective = decltype(bad_assert_copyable<N>());
template<typename T> consteval void assert_copyable() { T t; T t2 = t; }
// Prior to P1937R2 consteval functions were evaluated even in otherwise
// unevaluated context, now this is well-formed.
using check = decltype(assert_copyable<N>());
template<typename T>
__add_rvalue_reference(T) declval();
constexpr auto add1(auto lhs, auto rhs) {
return lhs + rhs;
}
using T = decltype(add1(declval<int>(), declval<int>()));
consteval auto add2(auto lhs, auto rhs) {
return lhs + rhs;
}
using T = decltype(add2(declval<int>(), declval<int>()));
} // namespace P1937R2