| 1 |
// P2573R2 = delete("should have a reason"); |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
void foo () = delete ("reason"); // { dg-warning "'delete' reason only available with" "" { target c++23_down } } |
| 6 |
// { dg-message "declared here" "" { target *-*-* } .-1 } |
| 7 |
struct S { |
| 8 |
void bar () = delete ("another reason"); // { dg-warning "'delete' reason only available with" "" { target c++23_down } } |
| 9 |
}; // { dg-message "declared here" "" { target *-*-* } .-1 } |
| 10 |
int baz (int) = delete ("yet another reason"); // { dg-warning "'delete' reason only available with" "" { target c++23_down } } |
| 11 |
int baz (int); // { dg-message "declared here" } |
| 12 |
template <typename T> |
| 13 |
void qux (T) = delete ("some other reason"); // { dg-warning "'delete' reason only available with" "" { target c++23_down } } |
| 14 |
// { dg-message "declared here" "" { target *-*-* } .-1 } |
| 15 |
template <typename T> |
| 16 |
struct U { |
| 17 |
U () = delete ("my reasons"); // { dg-warning "'delete' reason only available with" "" { target c++23_down } } |
| 18 |
U (int); // { dg-message "declared here" "" { target *-*-* } .-1 } |
| 19 |
~U () = delete ("your reasons"); // { dg-warning "'delete' reason only available with" "" { target c++23_down } } |
| 20 |
}; // { dg-message "declared here" "" { target *-*-* } .-1 } |
| 21 |
template <> |
| 22 |
void qux (long long) = delete; // { dg-message "declared here" } |
| 23 |
template <typename T> |
| 24 |
void corge (T) = delete; // { dg-message "declared here" } |
| 25 |
template <> |
| 26 |
void corge (double) = delete ("their reasons"); // { dg-warning "'delete' reason only available with" "" { target c++23_down } } |
| 27 |
// { dg-message "declared here" "" { target *-*-* } .-1 } |
| 28 |
|
| 29 |
void |
| 30 |
test (U<int> &x) |
| 31 |
{ |
| 32 |
foo (); // { dg-error "use of deleted function 'void foo\\\(\\\)': reason" } |
| 33 |
S{}.bar (); // { dg-error "use of deleted function 'void S::bar\\\(\\\)': another reason" } |
| 34 |
baz (0); // { dg-error "use of deleted function 'int baz\\\(int\\\)': yet another reason" } |
| 35 |
qux (0L); // { dg-error "use of deleted function 'void qux\\\(T\\\) \\\[with T = long int\\\]': some other reason" } |
| 36 |
qux (0LL); // { dg-error "use of deleted function 'void qux\\\(T\\\) \\\[with T = long long int\\\]'" } |
| 37 |
U<long> u; // { dg-error "use of deleted function 'U<T>::U\\\(\\\) \\\[with T = long int\\\]': my reasons" } |
| 38 |
// { dg-error "use of deleted function 'U<T>::~U\\\(\\\) \\\[with T = long int\\\]': your reasons" "" { target *-*-* } .-1 } |
| 39 |
corge (0); // { dg-error "use of deleted function 'void corge\\\(T\\\) \\\[with T = int\\\]'" } |
| 40 |
corge (0.0); // { dg-error "use of deleted function 'void corge\\\(T\\\) \\\[with T = double\\\]': their reasons" } |
| 41 |
} |