1// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_2b,cxx11_2b,cxx2b %s 2// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_2b,cxx11_2b %s 3// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_2b,cxx11_2b %s 4// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98 %s 5 6#define TEST(T) void test_##T() { \ 7 __block T x; \ 8 (void)^(void) { (void)x; }; \ 9} 10 11struct CopyOnly { 12 CopyOnly(); // cxx2b-note {{not viable}} 13 CopyOnly(CopyOnly &); // cxx2b-note {{not viable}} 14}; 15TEST(CopyOnly); // cxx2b-error {{no matching constructor}} 16 17// Both ConstCopyOnly and NonConstCopyOnly are 18// "pure" C++98 tests (pretend 'delete' means 'private'). 19// However we may extend implicit moves into C++98, we must make sure the 20// 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_2b-note {{marked deleted here}} 32}; 33TEST(NonConstCopyOnly); // cxx11_2b-error {{call to deleted constructor}} 34 35struct CopyNoMove { 36 CopyNoMove(); 37 CopyNoMove(CopyNoMove &); 38 CopyNoMove(CopyNoMove &&) = delete; // cxx98_2b-note {{marked deleted here}} 39}; 40TEST(CopyNoMove); // cxx98_2b-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_2b-note {{marked deleted here}} 53}; 54TEST(NoCopyNoMove); // cxx98_2b-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_2b-note {{passing argument to parameter here}} 73 operator X() const &; 74 operator X() && = delete; // cxx98_2b-note {{marked deleted here}} 75}; 76TEST(ConvertingCLVRef); // cxx98_2b-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