[PATCH] D145362: [clang] Update test according to P1937
This revision was automatically updated to reflect the committed changes. Closed by commit rGd0db54e0dd32: [clang] Update test according to P1937 (authored by Fznamznon). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145362/new/ 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,22 @@ template constexpr void bad_assert_copyable() { T t; T t2 = t; } using ineffective = decltype(bad_assert_copyable()); -// bad_assert_copyable is not needed for constant evaluation -// (and thus not instantiated) template 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()); -// FIXME: this should give an error because assert_copyable is instantiated -// (because it is needed for constant evaluation), but the attempt to copy t is -// ill-formed. -} // namespace P1073R3 + +template +__add_rvalue_reference(T) declval(); + +constexpr auto add1(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add1(declval(), declval())); + +consteval auto add2(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add2(declval(), declval())); +} // namespace P1937R2 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,22 @@ template constexpr void bad_assert_copyable() { T t; T t2 = t; } using ineffective = decltype(bad_assert_copyable()); -// bad_assert_copyable is not needed for constant evaluation -// (and thus not instantiated) template 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()); -// FIXME: this should give an error because assert_copyable is instantiated -// (because it is needed for constant evaluation), but the attempt to copy t is -// ill-formed. -} // namespace P1073R3 + +template +__add_rvalue_reference(T) declval(); + +constexpr auto add1(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add1(declval(), declval())); + +consteval auto add2(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add2(declval(), declval())); +} // namespace P1937R2 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D145362: [clang] Update test according to P1937
Fznamznon added inline comments. Comment at: clang/test/CXX/expr/expr.const/p8-2a.cpp:14 -// bad_assert_copyable is not needed for constant evaluation -// (and thus not instantiated) +// consteval assert is not instantiated as well. template consteval void assert_copyable() { T t; T t2 = t; } shafik wrote: > How about "Prior to P1937R2 consteval functions were evaluated even in > otherwise unevaluated context, now this is well-formed" > > and move it right above the "using check" Ok, sure. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145362/new/ https://reviews.llvm.org/D145362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D145362: [clang] Update test according to P1937
Fznamznon updated this revision to Diff 502742. Fznamznon added a comment. Rebase and apply the nitpick Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145362/new/ 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,22 @@ template constexpr void bad_assert_copyable() { T t; T t2 = t; } using ineffective = decltype(bad_assert_copyable()); -// bad_assert_copyable is not needed for constant evaluation -// (and thus not instantiated) template 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()); -// FIXME: this should give an error because assert_copyable is instantiated -// (because it is needed for constant evaluation), but the attempt to copy t is -// ill-formed. -} // namespace P1073R3 + +template +__add_rvalue_reference(T) declval(); + +constexpr auto add1(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add1(declval(), declval())); + +consteval auto add2(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add2(declval(), declval())); +} // namespace P1937R2 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,22 @@ template constexpr void bad_assert_copyable() { T t; T t2 = t; } using ineffective = decltype(bad_assert_copyable()); -// bad_assert_copyable is not needed for constant evaluation -// (and thus not instantiated) template 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()); -// FIXME: this should give an error because assert_copyable is instantiated -// (because it is needed for constant evaluation), but the attempt to copy t is -// ill-formed. -} // namespace P1073R3 + +template +__add_rvalue_reference(T) declval(); + +constexpr auto add1(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add1(declval(), declval())); + +consteval auto add2(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add2(declval(), declval())); +} // namespace P1937R2 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D145362: [clang] Update test according to P1937
shafik accepted this revision. shafik added a comment. Besides the nitpick, LGTM Comment at: clang/test/CXX/expr/expr.const/p8-2a.cpp:14 -// bad_assert_copyable is not needed for constant evaluation -// (and thus not instantiated) +// consteval assert is not instantiated as well. template consteval void assert_copyable() { T t; T t2 = t; } How about "Prior to P1937R2 consteval functions were evaluated even in otherwise unevaluated context, now this is well-formed" and move it right above the "using check" Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145362/new/ https://reviews.llvm.org/D145362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D145362: [clang] Update test according to P1937
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, thank you for cleaning that test up! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145362/new/ https://reviews.llvm.org/D145362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D145362: [clang] Update test according to P1937
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 constexpr void bad_assert_copyable() { T t; T t2 = t; } using ineffective = decltype(bad_assert_copyable()); -// bad_assert_copyable is not needed for constant evaluation -// (and thus not instantiated) +// consteval assert is not instantiated as well. template consteval void assert_copyable() { T t; T t2 = t; } using check = decltype(assert_copyable()); -// FIXME: this should give an error because assert_copyable is instantiated -// (because it is needed for constant evaluation), but the attempt to copy t is -// ill-formed. -} // namespace P1073R3 + +template +__add_rvalue_reference(T) declval(); + +constexpr auto add1(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add1(declval(), declval())); + +consteval auto add2(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add2(declval(), declval())); +} // namespace P1937R2 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 constexpr void bad_assert_copyable() { T t; T t2 = t; } using ineffective = decltype(bad_assert_copyable()); -// bad_assert_copyable is not needed for constant evaluation -// (and thus not instantiated) +// consteval assert is not instantiated as well. template consteval void assert_copyable() { T t; T t2 = t; } using check = decltype(assert_copyable()); -// FIXME: this should give an error because assert_copyable is instantiated -// (because it is needed for constant evaluation), but the attempt to copy t is -// ill-formed. -} // namespace P1073R3 + +template +__add_rvalue_reference(T) declval(); + +constexpr auto add1(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add1(declval(), declval())); + +consteval auto add2(auto lhs, auto rhs) { +return lhs + rhs; +} +using T = decltype(add2(declval(), declval())); +} // namespace P1937R2 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits