| 1 |
// Core Issue #1331 (const mismatch with defaulted copy constructor) |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
struct M |
| 5 |
{ |
| 6 |
M& operator=(M&); |
| 7 |
}; |
| 8 |
|
| 9 |
struct R |
| 10 |
{ |
| 11 |
R& operator=(R&) = default; |
| 12 |
M m; |
| 13 |
}; |
| 14 |
|
| 15 |
struct S |
| 16 |
{ |
| 17 |
S& operator=(const S&) = default; // { dg-error "implicitly deleted" "" { target c++17_down } } |
| 18 |
// { dg-warning "implicitly deleted" "" { target c++20 } .-1 } |
| 19 |
M m; |
| 20 |
}; |
| 21 |
|
| 22 |
struct T |
| 23 |
{ |
| 24 |
// If F is an assignment operator, and the return type of T1 |
| 25 |
// differs from the return type of T2 the program is ill-formed. |
| 26 |
T operator=(T&) = default; // { dg-error "defaulted" } |
| 27 |
M m; |
| 28 |
}; |
| 29 |
|
| 30 |
struct U |
| 31 |
{ |
| 32 |
// If F is an assignment operator, and T1's parameter type is |
| 33 |
// not a reference, the program is ill-formed. |
| 34 |
U& operator=(U) = default; // { dg-error "defaulted" } |
| 35 |
M m; |
| 36 |
}; |