================ @@ -156,6 +156,37 @@ void test_noexcept(int *i) { #undef TEST_TYPE } // end namespace test_launder +namespace test_start_object_lifetime { +// The builtin is non-constant. +constexpr int test_non_constexpr(int i) { // expected-error {{constexpr function never produces a constant expression}} + __builtin_start_object_lifetime(&i); // expected-note {{subexpression not valid in a constant expression}} +#ifdef CXX11 + // expected-warning@-2 {{use of this statement in a constexpr function is a C++14 extension}} +#endif + return 0; +} + +struct Incomplete; // expected-note {{forward declaration}} +void test_incomplete(Incomplete *i) { + // Requires a complete type + __builtin_start_object_lifetime(i); // expected-error {{incomplete type 'Incomplete' where a complete type is required}} +} + +// The builtin is type-generic. +#define TEST_TYPE(Ptr, Type) \ + static_assert(__is_same(decltype(__builtin_launder(Ptr)), Type), "expected same type") ---------------- hokein wrote:
oops, yeah, it should be `__builtin_start_object_lifetime `. https://github.com/llvm/llvm-project/pull/82776 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits