104 lines · plain
1// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_23,cxx11_23,cxx23 %s2// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_23,cxx11_23 %s3// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_23,cxx11_23 %s4// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_23,cxx98 %s5 6#define TEST(T) void test_##T() { \7 __block T x; \8 (void)^(void) { (void)x; }; \9}10 11struct CopyOnly {12 CopyOnly(); // cxx23-note {{not viable}}13 CopyOnly(CopyOnly &); // cxx23-note {{not viable}}14};15TEST(CopyOnly); // cxx23-error {{no matching constructor}}16 17// Both ConstCopyOnly and NonConstCopyOnly are18// "pure" C++98 tests (pretend 'delete' means 'private').19// However we may extend implicit moves into C++98, we must make sure the20// results in these are not changed.21struct ConstCopyOnly {22 ConstCopyOnly();23 ConstCopyOnly(ConstCopyOnly &) = delete; // cxx98-note {{marked deleted here}}24 ConstCopyOnly(const ConstCopyOnly &);25};26TEST(ConstCopyOnly); // cxx98-error {{call to deleted constructor}}27 28struct NonConstCopyOnly {29 NonConstCopyOnly();30 NonConstCopyOnly(NonConstCopyOnly &);31 NonConstCopyOnly(const NonConstCopyOnly &) = delete; // cxx11_23-note {{marked deleted here}}32};33TEST(NonConstCopyOnly); // cxx11_23-error {{call to deleted constructor}}34 35struct CopyNoMove {36 CopyNoMove();37 CopyNoMove(CopyNoMove &);38 CopyNoMove(CopyNoMove &&) = delete; // cxx98_23-note {{marked deleted here}}39};40TEST(CopyNoMove); // cxx98_23-error {{call to deleted constructor}}41 42struct MoveOnly {43 MoveOnly();44 MoveOnly(MoveOnly &) = delete;45 MoveOnly(MoveOnly &&);46};47TEST(MoveOnly);48 49struct NoCopyNoMove {50 NoCopyNoMove();51 NoCopyNoMove(NoCopyNoMove &) = delete;52 NoCopyNoMove(NoCopyNoMove &&) = delete; // cxx98_23-note {{marked deleted here}}53};54TEST(NoCopyNoMove); // cxx98_23-error {{call to deleted constructor}}55 56struct ConvertingRVRef {57 ConvertingRVRef();58 ConvertingRVRef(ConvertingRVRef &) = delete;59 60 struct X {};61 ConvertingRVRef(X &&);62 operator X() const & = delete;63 operator X() &&;64};65TEST(ConvertingRVRef);66 67struct ConvertingCLVRef {68 ConvertingCLVRef();69 ConvertingCLVRef(ConvertingCLVRef &);70 71 struct X {};72 ConvertingCLVRef(X &&); // cxx98_23-note {{passing argument to parameter here}}73 operator X() const &;74 operator X() && = delete; // cxx98_23-note {{marked deleted here}}75};76TEST(ConvertingCLVRef); // cxx98_23-error {{invokes a deleted function}}77 78struct SubSubMove {};79struct SubMove : SubSubMove {80 SubMove();81 SubMove(SubMove &) = delete;82 83 SubMove(SubSubMove &&);84};85TEST(SubMove);86 87 88#if __cplusplus >= 202302L89// clang used to crash compiling this code.90namespace BlockInLambda {91 struct S {92 constexpr ~S();93 };94 95 void func(S const &a) {96 [a](auto b) {97 ^{98 (void)a;99 }();100 }(12);101 }102}103#endif104