[PATCH] D145362: [clang] Update test according to P1937
Mariya Podchishchaeva via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 6 01:54:31 PST 2023
Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145362
Files:
clang/test/CXX/expr/expr.const/p8-2a.cpp
Index: clang/test/CXX/expr/expr.const/p8-2a.cpp
===================================================================
--- clang/test/CXX/expr/expr.const/p8-2a.cpp
+++ clang/test/CXX/expr/expr.const/p8-2a.cpp
@@ -2,7 +2,7 @@
// expected-no-diagnostics
-namespace P1073R3 {
+namespace P1937R2 {
struct N {
constexpr N() {}
N(N const&) = delete;
@@ -11,12 +11,21 @@
template<typename T> constexpr void bad_assert_copyable() { T t; T t2 = t; }
using ineffective = decltype(bad_assert_copyable<N>());
-// bad_assert_copyable<N> is not needed for constant evaluation
-// (and thus not instantiated)
+// consteval assert is not instantiated as well.
template<typename T> consteval void assert_copyable() { T t; T t2 = t; }
using check = decltype(assert_copyable<N>());
-// FIXME: this should give an error because assert_copyable<N> is instantiated
-// (because it is needed for constant evaluation), but the attempt to copy t is
-// ill-formed.
-} // namespace P1073R3
+
+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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145362.502558.patch
Type: text/x-patch
Size: 1327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230306/f9ccd38e/attachment.bin>
More information about the cfe-commits
mailing list