| 1 |
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_23,cxx11_23,cxx23 %s |
| 2 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_23,cxx11_23 %s |
| 3 |
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks -verify=cxx98_23,cxx11_23 %s |
| 4 |
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_23,cxx98 %s |
| 5 |
|
| 6 |
#define TEST(T) void test_##T() { \ |
| 7 |
__block T x; \ |
| 8 |
(void)^(void) { (void)x; }; \ |
| 9 |
} |
| 10 |
|
| 11 |
struct CopyOnly { |
| 12 |
CopyOnly(); // cxx23-note {{not viable}} |
| 13 |
CopyOnly(CopyOnly &); // cxx23-note {{not viable}} |
| 14 |
}; |
| 15 |
TEST(CopyOnly); // cxx23-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. |
| 21 |
struct ConstCopyOnly { |
| 22 |
ConstCopyOnly(); |
| 23 |
ConstCopyOnly(ConstCopyOnly &) = delete; // cxx98-note {{marked deleted here}} |
| 24 |
ConstCopyOnly(const ConstCopyOnly &); |
| 25 |
}; |
| 26 |
TEST(ConstCopyOnly); // cxx98-error {{call to deleted constructor}} |
| 27 |
|
| 28 |
struct NonConstCopyOnly { |
| 29 |
NonConstCopyOnly(); |
| 30 |
NonConstCopyOnly(NonConstCopyOnly &); |
| 31 |
NonConstCopyOnly(const NonConstCopyOnly &) = delete; // cxx11_23-note {{marked deleted here}} |
| 32 |
}; |
| 33 |
TEST(NonConstCopyOnly); // cxx11_23-error {{call to deleted constructor}} |
| 34 |
|
| 35 |
struct CopyNoMove { |
| 36 |
CopyNoMove(); |
| 37 |
CopyNoMove(CopyNoMove &); |
| 38 |
CopyNoMove(CopyNoMove &&) = delete; // cxx98_23-note {{marked deleted here}} |
| 39 |
}; |
| 40 |
TEST(CopyNoMove); // cxx98_23-error {{call to deleted constructor}} |
| 41 |
|
| 42 |
struct MoveOnly { |
| 43 |
MoveOnly(); |
| 44 |
MoveOnly(MoveOnly &) = delete; |
| 45 |
MoveOnly(MoveOnly &&); |
| 46 |
}; |
| 47 |
TEST(MoveOnly); |
| 48 |
|
| 49 |
struct NoCopyNoMove { |
| 50 |
NoCopyNoMove(); |
| 51 |
NoCopyNoMove(NoCopyNoMove &) = delete; |
| 52 |
NoCopyNoMove(NoCopyNoMove &&) = delete; // cxx98_23-note {{marked deleted here}} |
| 53 |
}; |
| 54 |
TEST(NoCopyNoMove); // cxx98_23-error {{call to deleted constructor}} |
| 55 |
|
| 56 |
struct ConvertingRVRef { |
| 57 |
ConvertingRVRef(); |
| 58 |
ConvertingRVRef(ConvertingRVRef &) = delete; |
| 59 |
|
| 60 |
struct X {}; |
| 61 |
ConvertingRVRef(X &&); |
| 62 |
operator X() const & = delete; |
| 63 |
operator X() &&; |
| 64 |
}; |
| 65 |
TEST(ConvertingRVRef); |
| 66 |
|
| 67 |
struct 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 |
}; |
| 76 |
TEST(ConvertingCLVRef); // cxx98_23-error {{invokes a deleted function}} |
| 77 |
|
| 78 |
struct SubSubMove {}; |
| 79 |
struct SubMove : SubSubMove { |
| 80 |
SubMove(); |
| 81 |
SubMove(SubMove &) = delete; |
| 82 |
|
| 83 |
SubMove(SubSubMove &&); |
| 84 |
}; |
| 85 |
TEST(SubMove); |
| 86 |
|
| 87 |
|
| 88 |
#if __cplusplus >= 202302L |
| 89 |
// clang used to crash compiling this code. |
| 90 |
namespace 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 |
#endif |