|
6 | 6 | // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx14,since-cxx17,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s |
7 | 7 | // RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx14,since-cxx17,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s |
8 | 8 |
|
| 9 | +namespace std { |
| 10 | + __extension__ typedef __SIZE_TYPE__ size_t; |
| 11 | + |
| 12 | + template<typename E> struct initializer_list { |
| 13 | + const E *p; size_t n; |
| 14 | + initializer_list(const E *p, size_t n); |
| 15 | + initializer_list(); |
| 16 | + }; |
| 17 | +} |
| 18 | + |
9 | 19 | #if __cplusplus >= 201103L |
10 | 20 | namespace dr2303 { // dr2303: 12 |
11 | 21 | template <typename... T> |
@@ -47,6 +57,81 @@ void g() { |
47 | 57 | } //namespace dr2303 |
48 | 58 | #endif |
49 | 59 |
|
| 60 | +namespace dr2311 { // dr2311: 18 open |
| 61 | +#if __cplusplus >= 201707L |
| 62 | +template<typename T> |
| 63 | +void test() { |
| 64 | + // Ensure none of these try to call a move constructor. |
| 65 | + T a = T{T(0)}; |
| 66 | + T b{T(0)}; |
| 67 | + auto c{T(0)}; |
| 68 | + T d = {T(0)}; |
| 69 | + auto e = {T(0)}; |
| 70 | +#if __cplusplus >= 202302L |
| 71 | + auto f = auto{T(0)}; |
| 72 | +#endif |
| 73 | + void(*fn)(T); |
| 74 | + fn({T(0)}); |
| 75 | +} |
| 76 | + |
| 77 | +struct NonMovable { |
| 78 | + NonMovable(int); |
| 79 | + NonMovable(NonMovable&&) = delete; |
| 80 | +}; |
| 81 | +struct NonMovableNonApplicableIList { |
| 82 | + NonMovableNonApplicableIList(int); |
| 83 | + NonMovableNonApplicableIList(NonMovableNonApplicableIList&&) = delete; |
| 84 | + NonMovableNonApplicableIList(std::initializer_list<int>); |
| 85 | +}; |
| 86 | +struct ExplicitMovable { |
| 87 | + ExplicitMovable(int); |
| 88 | + explicit ExplicitMovable(ExplicitMovable&&); |
| 89 | +}; |
| 90 | +struct ExplicitNonMovable { |
| 91 | + ExplicitNonMovable(int); |
| 92 | + explicit ExplicitNonMovable(ExplicitNonMovable&&) = delete; |
| 93 | +}; |
| 94 | +struct ExplicitNonMovableNonApplicableIList { |
| 95 | + ExplicitNonMovableNonApplicableIList(int); |
| 96 | + explicit ExplicitNonMovableNonApplicableIList(ExplicitNonMovableNonApplicableIList&&) = delete; |
| 97 | + ExplicitNonMovableNonApplicableIList(std::initializer_list<int>); |
| 98 | +}; |
| 99 | +struct CopyOnly { |
| 100 | + CopyOnly(int); |
| 101 | + CopyOnly(const CopyOnly&); |
| 102 | + CopyOnly(CopyOnly&&) = delete; |
| 103 | +}; |
| 104 | +struct ExplicitCopyOnly { |
| 105 | + ExplicitCopyOnly(int); |
| 106 | + explicit ExplicitCopyOnly(const ExplicitCopyOnly&); |
| 107 | + explicit ExplicitCopyOnly(ExplicitCopyOnly&&) = delete; |
| 108 | +}; |
| 109 | + |
| 110 | +template void test<NonMovable>(); |
| 111 | +template void test<NonMovableNonApplicableIList>(); |
| 112 | +template void test<ExplicitMovable>(); |
| 113 | +template void test<ExplicitNonMovable>(); |
| 114 | +template void test<ExplicitNonMovableNonApplicableIList>(); |
| 115 | +template void test<CopyOnly>(); |
| 116 | +template void test<ExplicitCopyOnly>(); |
| 117 | + |
| 118 | +struct any { |
| 119 | + template<typename T> |
| 120 | + any(T&&); |
| 121 | +}; |
| 122 | + |
| 123 | +template<typename T> |
| 124 | +struct X { |
| 125 | + X(); |
| 126 | + X(T) = delete; // #dr2311-X |
| 127 | +}; |
| 128 | + |
| 129 | +X<std::initializer_list<any>> x{ X<std::initializer_list<any>>() }; |
| 130 | +// since-cxx17-error@-1 {{call to deleted constructor of 'X<std::initializer_list<any>>'}} |
| 131 | +// since-cxx17-note@#dr2311-X {{'X' has been explicitly marked deleted here}} |
| 132 | +#endif |
| 133 | +} |
| 134 | + |
50 | 135 | // dr2331: na |
51 | 136 | // dr2335 is in dr2335.cxx |
52 | 137 |
|
|
0 commit comments